All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jann Horn <jannh@google.com>
To: dsterba@suse.cz
Cc: syzbot <syzbot+12e098239d20385264d3@syzkaller.appspotmail.com>,
	clm@fb.com,  dsterba@suse.com, josef@toxicpanda.com,
	linux-btrfs@vger.kernel.org,  linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] WARNING in __kernel_write_iter
Date: Fri, 24 Nov 2023 18:26:37 +0100	[thread overview]
Message-ID: <CAG48ez0hPQciXnpK8M1wqcD5qfHGLDbqEvjYk4mLS6zN3BNR5g@mail.gmail.com> (raw)
In-Reply-To: <20231124171707.GF18929@twin.jikos.cz>

On Fri, Nov 24, 2023 at 6:24 PM David Sterba <dsterba@suse.cz> wrote:
> On Fri, Nov 24, 2023 at 05:21:20PM +0100, Jann Horn wrote:
> > On Mon, Oct 10, 2022 at 9:04 AM syzbot
> > <syzbot+12e098239d20385264d3@syzkaller.appspotmail.com> wrote:
> > > HEAD commit:    a6afa4199d3d Merge tag 'mailbox-v6.1' of git://git.linaro...
> > > git tree:       upstream
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=110f6f0a880000
> > > kernel config:  https://syzkaller.appspot.com/x/.config?x=d19f5d16783f901
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=12e098239d20385264d3
> > > compiler:       Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
> > >
> > > Unfortunately, I don't have any reproducer for this issue yet.
> > >
> > > Downloadable assets:
> > > disk image: https://storage.googleapis.com/syzbot-assets/12e24d042ff9/disk-a6afa419.raw.xz
> > > vmlinux: https://storage.googleapis.com/syzbot-assets/4862ae4e2edf/vmlinux-a6afa419.xz
> > >
> > > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > > Reported-by: syzbot+12e098239d20385264d3@syzkaller.appspotmail.com
> > >
> > > ------------[ cut here ]------------
> > > WARNING: CPU: 1 PID: 20347 at fs/read_write.c:504 __kernel_write_iter+0x639/0x740
> > [...]
> > >  __kernel_write fs/read_write.c:537 [inline]
> > >  kernel_write+0x1c5/0x340 fs/read_write.c:558
> > >  write_buf fs/btrfs/send.c:590 [inline]
> > >  send_header fs/btrfs/send.c:708 [inline]
> > >  send_subvol+0x1a7/0x4b60 fs/btrfs/send.c:7648
> > >  btrfs_ioctl_send+0x1e34/0x2340 fs/btrfs/send.c:8014
> > >  _btrfs_ioctl_send+0x2e8/0x420 fs/btrfs/ioctl.c:5233
> > >  btrfs_ioctl+0x5eb/0xc10
> > >  vfs_ioctl fs/ioctl.c:51 [inline]
> >
> > The issue here is that BTRFS_IOC_SEND looks up an fd with fget() and
> > then writes into it with kernel_write(). Luckily the ioctl requires
> > CAP_SYS_ADMIN, and also Linux >=5.8 bails out on __kernel_write() on a
> > read-only file, so this has no security impact.
>
> I'm not sure if we could make the send ioctl safe for a non-root user,
> the code there has been doing tricks that have security implications.
>
> > I'm about to send a fix, let's have syzkaller check it beforehand:
> >
> > #syz test https://github.com/thejh/linux.git 573fd2562e0f
>
> The fix looks correct to me, thanks.

(I sent the fix to you and the other btrfs maintainers separately with
subject "[PATCH] btrfs: send: Ensure send_fd is writable", see
<https://lore.kernel.org/lkml/20231124164831.2191549-1-jannh@google.com/T/>.)

      reply	other threads:[~2023-11-24 17:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10  7:04 [syzbot] WARNING in __kernel_write_iter syzbot
2022-11-27  2:44 ` syzbot
2023-11-24 16:21 ` Jann Horn
2023-11-24 16:41   ` [syzbot] [btrfs?] " syzbot
2023-11-24 17:17   ` [syzbot] " David Sterba
2023-11-24 17:26     ` Jann Horn [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=CAG48ez0hPQciXnpK8M1wqcD5qfHGLDbqEvjYk4mLS6zN3BNR5g@mail.gmail.com \
    --to=jannh@google.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+12e098239d20385264d3@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.