From: Alice Ferrazzi <alicef@gentoo.org>
To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, broonie@kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC] ubsan: signed integer overflow in atomc.h atomic_add_return
Date: Fri, 16 Jun 2017 22:48:02 +0900 [thread overview]
Message-ID: <20170616134802.GH20222@alitoo> (raw)
[-- Attachment #1: Type: text/plain, Size: 2058 bytes --]
A Gentoo user reported a UBSAN signed integer overflow in atomic_add_return.
/**
* atomic_add_return - add integer and return
* @i: integer value to add
* @v: pointer of type atomic_t
*
* Atomically adds @i to @v and returns @i + @v
*/
static __always_inline int atomic_add_return(int i, atomic_t *v)
{
return i + xadd(&v->counter, i);
}
shall we change something?
================================================================================
kernel: UBSAN: Undefined behaviour in ./arch/x86/include/asm/atomic.h:156:2
kernel: signed integer overflow:
kernel: 2147483647 + 1 cannot be represented in type 'int'
kernel: CPU: 1 PID: 37 Comm: kswapd0 Tainted: P W O
4.9.25-gentoo #4
kernel: Hardware name: XXXXXX, BIOS YYYYYY
kernel: ec38fc0c d1f444f2 00000007 ec38fc3c 00000001 ec38fc1c d1fc8ffe
ec38fc1c
kernel: d2b1146c ec38fca0 d1fc934b d28b15c0 ec38fc40 0000002b ec38fc68
d2b1146c
kernel: 0000002b 00000002 37343132 36333834 00003734 c2f91260 00000025
ec38fc74
kernel: Call Trace:
kernel: [<d1f444f2>] dump_stack+0x59/0x87
kernel: [<d1fc8ffe>] ubsan_epilogue+0xe/0x40
kernel: [<d1fc934b>] handle_overflow+0xbb/0xf0
kernel: [<d1f50884>] ? radix_tree_clear_tags+0x34/0xa0
kernel: [<d189e464>] ? __delete_from_page_cache+0x464/0x9c0
kernel: [<d1fc9392>] __ubsan_handle_add_overflow+0x12/0x20
kernel: [<d18fd266>] workingset_eviction+0xe6/0x120
kernel: [<d18c869b>] __remove_mapping+0x1bb/0x390
kernel: [<d18cb786>] shrink_page_list+0x3a6/0x14d0
kernel: [<d18cd7fa>] shrink_inactive_list+0x2aa/0x8f0
kernel: [<d18ceb62>] shrink_node_memcg+0x742/0xd70
kernel: [<d18cf282>] shrink_node+0xf2/0x7c0
kernel: [<d18d12f2>] kswapd+0x362/0xb00
kernel: [<d18d0f90>] ? mem_cgroup_shrink_node+0x210/0x210
kernel: [<d16dca33>] kthread+0xe3/0x170
kernel: [<d26590e8>] ? _raw_spin_unlock_irq+0x8/0x10
kernel: [<d18d0f90>] ? mem_cgroup_shrink_node+0x210/0x210
kernel: [<d16dc950>] ? kthread_park+0x50/0x50
kernel: [<d2659383>] ret_from_fork+0x1b/0x28
kernel:
================================================================================
Thanks,
Alice
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
reply other threads:[~2017-06-16 13:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170616134802.GH20222@alitoo \
--to=alicef@gentoo.org \
--cc=broonie@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.