Overview
| Artifact ID: | 66bf6e763755beb64e51e8db82bdc680443f8c69e3125d88bbc54e47ccb72032 |
|---|---|
| Ticket: | 37108037b980ea6e705f56a9d983e05ee218dd0c
Code cleanups to support CHERI |
| User & Date: | jrtc27 on 2023-03-28 10:41:19 |
Changes
- icomment:
Not sure how I missed these comments from last August and only saw today's follow-up, but here's my response: It's been long enough that I don't recall whether patch 2 is needed for correctness. However, we do emit a warning on pointer<->integer casts that don't go through (u)intptr_t because there's a high chance the code is wrong (and it's quite hard to tell statically for certain), so even if none of the users need to be able to do pointer->integer->pointer losslessly it's going to warn as-is, which is a warning we often like to make an error so we can catch all such potentially-problematic cases. If what you say is true then the way we'd express it would be `((void *)(intptr_t)(ptrdiff_t)(p))` and `((ptrdiff_t)(intptr_t)(p))`, which are semantically equivalent to the original code, but use a redundant intermediary cast to express to the compiler that your intent is indeed to be using just a plain integer. Would you accept such a patch instead? Either way I'll need to test that there is indeed nothing trying to use these for actual pointers. Re custom/wrapping allocators, yes, those are a nuisance to deal with and these days are often a bad idea for performance anyway (though maybe still with some allocators). You can either make your allocator use the necessary intrinsics to apply bounds (and be able to cope with the reduced bounds on free) or turn it off; which is the right option depends on the use case. Our porting of most software of late has been focused on just getting it working without extensively auditing it for things like custom memory allocators where adaptation is needed to avoid slight holes in the security story. Re __LP64__ I don't think I spotted such usage, but it may well be there are cases not exercised by the test suite where stupid things end up happening because it thinks it's 32-bit. There only seem to be 16 results between the tcl and tk repos (at least according to GitHub search, which can be a bit dodgy) though so perhaps not, and it wouldn't take long to audit them.
- login: "jrtc27"
- mimetype: "text/plain"