linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: syzbot <syzbot+ac3b41786a2d0565b6d5@syzkaller.appspotmail.com>,
	Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org, linux-next@vger.kernel.org,
	sfr@canb.auug.org.au, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [kernel?] linux-next test error: UBSAN: array-index-out-of-bounds in alloc_pid
Date: Wed, 17 May 2023 10:25:08 +0200	[thread overview]
Message-ID: <20230517-bushaltestelle-super-e223978c1ba6@brauner> (raw)
In-Reply-To: <000000000000c6de2a05fbdecbbb@google.com>

On Wed, May 17, 2023 at 12:40:03AM -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    065efa589871 Add linux-next specific files for 20230517
> git tree:       linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=17f27bb2280000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=821eeb02ef201bcc
> dashboard link: https://syzkaller.appspot.com/bug?extid=ac3b41786a2d0565b6d5
> compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> 
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/dbbd691e9e5a/disk-065efa58.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/e5b9541c3979/vmlinux-065efa58.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/44cf3f3aaabb/bzImage-065efa58.xz
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+ac3b41786a2d0565b6d5@syzkaller.appspotmail.com
> 
> ================================================================================
> UBSAN: array-index-out-of-bounds in kernel/pid.c:244:15

Only way I see this happening is if the logic in
kernel/pid_namespace.c:create_pid_cachep() which sets the object size
for the struct pid allocation of this pid namespace based on
parent_pid_namespace->level + 1 is broken. The way this works is:

    struct pid
    {
            [snip]
            struct upid numbers[1];
    };

    create_pid_namespace()
    {
            unsigned int level = parent_pid_ns->level + 1;
            ns->pid_cachep = create_pid_cachep(level);
    }

and then during fork:

    alloc_pid()
    {
            pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL);
    }

So effectively, the wrong level must've been set in
create_pid_namespace() so that the flexible array allocation is too
small.

I don't have time to debug this tbh. Ccing Kees maybe there's some
flexible array stuff going on I'm unaware of.

  reply	other threads:[~2023-05-17  8:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17  7:40 [syzbot] [kernel?] linux-next test error: UBSAN: array-index-out-of-bounds in alloc_pid syzbot
2023-05-17  8:25 ` Christian Brauner [this message]
2023-05-17 15:38   ` Kees Cook

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=20230517-bushaltestelle-super-e223978c1ba6@brauner \
    --to=brauner@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=syzbot+ac3b41786a2d0565b6d5@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 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).