From: Pavel Skripkin <paskripkin@gmail.com>
To: syzbot <syzbot+9cd5837a045bbee5b810@syzkaller.appspotmail.com>
Cc: davem@davemloft.net, herbert@gondor.apana.org.au,
kuba@kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, steffen.klassert@secunet.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] UBSAN: shift-out-of-bounds in xfrm_set_default
Date: Tue, 27 Jul 2021 17:43:18 +0300 [thread overview]
Message-ID: <20210727174318.53806d27@gmail.com> (raw)
In-Reply-To: <0000000000004f5de905c81a45e7@google.com>
[-- Attachment #1: Type: text/plain, Size: 1256 bytes --]
On Tue, 27 Jul 2021 05:47:21 -0700
syzbot <syzbot+9cd5837a045bbee5b810@syzkaller.appspotmail.com> wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 90d856e71443 Add linux-next specific files for
> 20210723 git tree: linux-next
> console output:
> https://syzkaller.appspot.com/x/log.txt?x=133fd00a300000 kernel
> config: https://syzkaller.appspot.com/x/.config?x=298516715f6ad5cd
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=9cd5837a045bbee5b810
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU
> Binutils for Debian) 2.35.1 syz repro:
> https://syzkaller.appspot.com/x/repro.syz?x=1263bba6300000 C
> reproducer: https://syzkaller.appspot.com/x/repro.c?x=1066b4d4300000
>
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit: Reported-by:
> syzbot+9cd5837a045bbee5b810@syzkaller.appspotmail.com
>
> netlink: 228 bytes leftover after parsing attributes in process
> `syz-executor669'.
> ================================================================================
The first thing that comes in mind is to check up->dirmask value
#syz test
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
With regards,
Pavel Skripkin
[-- Attachment #2: 0001-net-xfrm-fix-shift-out-of-bounce.patch --]
[-- Type: text/x-patch, Size: 1152 bytes --]
From 30db223b1f724ca241c7fa15769d0c65eada3b66 Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <paskripkin@gmail.com>
Date: Tue, 27 Jul 2021 17:38:24 +0300
Subject: [PATCH] net: xfrm: fix shift-out-of-bounce
We need to check up->dirmask to avoid shift-out-of-bounce bug,
since up->dirmask comes from userspace.
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
net/xfrm/xfrm_user.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index acc3a0dab331..5f3fe2295519 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1966,9 +1966,14 @@ static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh,
{
struct net *net = sock_net(skb->sk);
struct xfrm_userpolicy_default *up = nlmsg_data(nlh);
- u8 dirmask = (1 << up->dirmask) & XFRM_POL_DEFAULT_MASK;
+ u8 dirmask;
u8 old_default = net->xfrm.policy_default;
+ if (up->dirmask >= sizeof(up->action) * 8)
+ return -EINVAL;
+
+ dirmask = (1 << up->dirmask) & XFRM_POL_DEFAULT_MASK
+
net->xfrm.policy_default = (old_default & (0xff ^ dirmask))
| (up->action << up->dirmask);
--
2.32.0
next prev parent reply other threads:[~2021-07-27 14:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 12:47 [syzbot] UBSAN: shift-out-of-bounds in xfrm_set_default syzbot
2021-07-27 14:43 ` Pavel Skripkin [this message]
2021-07-27 17:25 ` [PATCH] net: xfrm: fix shift-out-of-bounce kernel test robot
2021-07-27 17:25 ` kernel test robot
2021-07-27 17:30 ` Pavel Skripkin
2021-07-27 17:30 ` Pavel Skripkin
2021-07-28 0:13 ` [syzbot] UBSAN: shift-out-of-bounds in xfrm_set_default syzbot
2021-07-28 0:13 ` syzbot
2021-07-27 17:46 ` [PATCH] net: xfrm: fix shift-out-of-bounce kernel test robot
2021-07-27 17:46 ` kernel test robot
2021-07-27 23:28 ` [syzbot] UBSAN: shift-out-of-bounds in xfrm_set_default syzbot
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=20210727174318.53806d27@gmail.com \
--to=paskripkin@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=syzbot+9cd5837a045bbee5b810@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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 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.