Skip to content

Clang: avoid undefined behavior in llist iterators

Alexander Potapenko lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2include/linux: provide a safe version of container_of()include/linux/kernel.h+15 -00 replies
2/2llist: introduce llist_entry_safe()include/linux/llist.h+19 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Clang: avoid undefined behavior in llist iterators

This patch set fixes problems with pointer arithmetics overflow in llist iterators, llist_for_each_entry() and llist_for_each_entry_safe(). Clang turns those macros into infinite loops, because they're operating with "negative" pointers.

As a follow-up it may make sense to convert other uses of llist_entry() to llist_entry_safe(), or even replace uses of container_of() with container_of_safe().

Alexander Potapenko (2):
include/linux: provide a safe version of container_of()
llist: introduce llist_entry_safe()

 include/linux/kernel.h | 15 +++++++++++++++
 include/linux/llist.h  | 26 +++++++++++++++++++-------
 2 files changed, 34 insertions(+), 7 deletions(-)
Signature · 1 line
2.8.0.rc3.226.g39d4020