tech-kern archive

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

Re: NULL pointer arithmetic issues



On 23.02.2020 20:08, Taylor R Campbell wrote:
>> Date: Sat, 22 Feb 2020 17:25:42 +0100
>> From: Kamil Rytarowski <n54%gmx.com@localhost>
>>
>> When running the ATF tests under MKLIBCSANITIZER [1], there are many
>> NULL pointer arithmetic issues .
>>
>> http://netbsd.org/~kamil/mksanitizer-reports/ubsan-2020-02-22-null-pointer.txt
>>
>> These issues are in macros like:
>>  - IN_ADDRHASH_READER_FOREACH()
>>  - IN_ADDRLIST_WRITER_INSERT_TAIL()
>>  - IFADDR_READER_FOREACH()
>>  - etc
>>
>> These macros wrap internally pserialize-safe linked lists.
>>
>> What's the proper approach to address this issue?
> 
> What do these reports mean?
> 
> UBSan: Undefined Behavior in /usr/src/sys/rump/net/lib/libnet/../../../../netinet6/in6.c:2351:2, pointer expression with base 0 overflowed to 0
> 

We added 0 to a NULL pointer.

They can be triggered by code like:

char *p = NULL;
p += 0;

or

char *p = NULL;
if (p[0] == NULL) {}

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index