diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-08-10 09:45:24 +0300 |
|---|---|---|
| committer | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-08-10 09:45:24 +0300 |
| commit | 3b228d5c750ba76694bacf75e7be40a024927a31 (patch) | |
| tree | d83ebabc480f355dc3500d20cc8373ec9c782ed1 | |
| parent | 7c98f320c3ef7e863a9c7d30bb81735bb4fec46d (diff) | |
| download | accel-ppp-3b228d5c750ba76694bacf75e7be40a024927a31.tar.gz accel-ppp-3b228d5c750ba76694bacf75e7be40a024927a31.zip | |
triton: use offsetof() in list_entry()
list_entry() computed the member offset as &((type *)0)->member, which
is a member access on a null pointer and undefined. UBSan reports it on
every list traversal in the tree:
runtime error: member access within null pointer of type
'struct dhcpv6_option'
The generated code is the same either way, and the offset happens to be
zero for many of the structures involved, so nothing misbehaves today.
offsetof() is what the standard provides for this.
| -rw-r--r-- | accel-pppd/triton/list.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/accel-pppd/triton/list.h b/accel-pppd/triton/list.h index 20b917d4..6352aa82 100644 --- a/accel-pppd/triton/list.h +++ b/accel-pppd/triton/list.h @@ -1,6 +1,8 @@ #ifndef _LINUX_LIST_H #define _LINUX_LIST_H +#include <stddef.h> + //#if defined(__KERNEL__) || defined(_LVM_H_INCLUDE) //#include <linux/prefetch.h> @@ -211,7 +213,7 @@ static inline void list_splice_init(struct list_head *list, * @member: the name of the list_struct within the struct. */ #define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + ((type *)((char *)(ptr)-offsetof(type, member))) /** * list_first_entry - get the first element from a list |
