netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Vasily Averin <vvs@virtuozzo.com>
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>,
	Florian Westphal <fw@strlen.de>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH v2] netfilter: ipset: fix shift-out-of-bounds in htable_bits()
Date: Thu, 17 Dec 2020 19:44:00 +0100	[thread overview]
Message-ID: <20201217184400.GB17365@salvia> (raw)
In-Reply-To: <e954ad22-83dc-e553-37a3-f0adb11cebb2@virtuozzo.com>

On Thu, Dec 17, 2020 at 05:53:18PM +0300, Vasily Averin wrote:
> htable_bits() can call jhash_size(32) and trigger shift-out-of-bounds
> 
> UBSAN: shift-out-of-bounds in net/netfilter/ipset/ip_set_hash_gen.h:151:6
> shift exponent 32 is too large for 32-bit type 'unsigned int'
> CPU: 0 PID: 8498 Comm: syz-executor519
>  Not tainted 5.10.0-rc7-next-20201208-syzkaller #0
> Call Trace:
>  __dump_stack lib/dump_stack.c:79 [inline]
>  dump_stack+0x107/0x163 lib/dump_stack.c:120
>  ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
>  __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:395
>  htable_bits net/netfilter/ipset/ip_set_hash_gen.h:151 [inline]
>  hash_mac_create.cold+0x58/0x9b net/netfilter/ipset/ip_set_hash_gen.h:1524
>  ip_set_create+0x610/0x1380 net/netfilter/ipset/ip_set_core.c:1115
>  nfnetlink_rcv_msg+0xecc/0x1180 net/netfilter/nfnetlink.c:252
>  netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
>  nfnetlink_rcv+0x1ac/0x420 net/netfilter/nfnetlink.c:600
>  netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
>  netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1330
>  netlink_sendmsg+0x907/0xe40 net/netlink/af_netlink.c:1919
>  sock_sendmsg_nosec net/socket.c:652 [inline]
>  sock_sendmsg+0xcf/0x120 net/socket.c:672
>  ____sys_sendmsg+0x6e8/0x810 net/socket.c:2345
>  ___sys_sendmsg+0xf3/0x170 net/socket.c:2399
>  __sys_sendmsg+0xe5/0x1b0 net/socket.c:2432
>  do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
>  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> 
> This patch replaces htable_bits() by simple fls(hashsize - 1) call:
> it alone returns valid nbits both for round and non-round hashsizes.
> It is normal to set any nbits here because it is validated inside
> following htable_size() call which returns 0 for nbits>31.

Applied, thanks.

      parent reply	other threads:[~2020-12-17 18:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4d915d3a-6a95-7784-4057-2faa17a061@blackhole.kfki.hu>
2020-12-17 14:53 ` [PATCH v2] netfilter: ipset: fix shift-out-of-bounds in htable_bits() Vasily Averin
2020-12-17 17:12   ` Jozsef Kadlecsik
2020-12-17 18:44   ` Pablo Neira Ayuso [this message]

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=20201217184400.GB17365@salvia \
    --to=pablo@netfilter.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=vvs@virtuozzo.com \
    /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 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).