tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NULL pointer arithmetic issues



On 24.02.2020 15:04, Jason Thorpe wrote:
> 
>> On Feb 24, 2020, at 4:22 AM, Kamil Rytarowski <n54%gmx.com@localhost> wrote:
>>
>> A compiler once being smart enough can introduce ILL/SEGV traps into
>> code that performs operations on NULL pointers. This already bitten us
>> when we were registering a handler at address 0x0 for the kernel code,
>> GCC changed the operation into a cpu trap. (IIRC it was in the sparc code.)
> 
> Nonsense, I think it's fair to classify that as a bug.  That sort of stuff is *not* supposed to happen if -ffreestanding is passed to the compiler.
> 
> -- thorpej
> 

If we use 0x0, it can be a valid pointer.

If we use NULL, it's not expected to work and will eventually generate a
syntax erro.

UBSan as a runtime tool tries to indirectly catch the latter with the
former and is prone to some rare false positives (so far not reported).

If a compiler is too smart for 0x0 pointers, transforming them to abort
traps, it is a compiler bug. I noted that this already happens.

On 24.02.2020 15:05, Mouse wrote:
> (3) If you have reason to think the C committee would be interested in
> having me as a member, let me know whom to talk to.  I might or might
> not actually end up interested in joining, but I'd like more info.

http://www.open-std.org/jtc1/sc22/wg14/

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index