lkml.org 
[lkml]   [2021]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [syzbot] UBSAN: shift-out-of-bounds in xfrm_set_default
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


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
\
 
 \ /
  Last update: 2021-07-27 16:43    [W:0.184 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site