netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* UBSAN: annotation to skip sanitization in variable that will wrap
@ 2024-08-14 17:10 Breno Leitao
  2024-08-14 21:05 ` Justin Stitt
  0 siblings, 1 reply; 6+ messages in thread
From: Breno Leitao @ 2024-08-14 17:10 UTC (permalink / raw)
  To: kees, elver, andreyknvl, ryabinin.a.a
  Cc: kasan-dev, linux-hardening, axboe, asml.silence, netdev

Hello,

I am seeing some signed-integer-overflow in percpu reference counters.

	UBSAN: signed-integer-overflow in ./arch/arm64/include/asm/atomic_lse.h:204:1
	-9223372036854775808 - 1 cannot be represented in type 's64' (aka 'long long')
	Call trace:

	 handle_overflow
	 __ubsan_handle_sub_overflow
	 percpu_ref_put_many
	 css_put
	 cgroup_sk_free
	 __sk_destruct
	 __sk_free
	 sk_free
	 unix_release_sock
	 unix_release
	 sock_close

This overflow is probably happening in percpu_ref->percpu_ref_data->count.

Looking at the code documentation, it seems that overflows are fine in
per-cpu values. The lib/percpu-refcount.c code comment says:

 * Note that the counter on a particular cpu can (and will) wrap - this
 * is fine, when we go to shutdown the percpu counters will all sum to
 * the correct value

Is there a way to annotate the code to tell UBSAN that this overflow is
expected and it shouldn't be reported?

Thanks
--breno


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-16 19:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-14 17:10 UBSAN: annotation to skip sanitization in variable that will wrap Breno Leitao
2024-08-14 21:05 ` Justin Stitt
2024-08-15 16:20   ` Kees Cook
2024-08-15 17:58   ` Breno Leitao
2024-08-15 18:40     ` Jens Axboe
2024-08-16 19:47       ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).