public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Jann Horn <jannh@google.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Alex Lyakas <alex.bolshoy.btrfs@gmail.com>,
	Alexander Block <ablock84@googlemail.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] btrfs: send: Ensure send_fd is writable
Date: Fri, 24 Nov 2023 18:43:56 +0100	[thread overview]
Message-ID: <20231124174356.GH18929@suse.cz> (raw)
In-Reply-To: <20231124164831.2191549-1-jannh@google.com>

On Fri, Nov 24, 2023 at 05:48:31PM +0100, Jann Horn wrote:
> kernel_write() requires the caller to ensure that the file is writable.
> Let's do that directly after looking up the ->send_fd.
> 
> (We don't need a separate bailout path because the "out" path already
> does fput() if ->send_filp is non-NULL.)
> 
> This has no security impact for two reasons:
> 
>  - the ioctl requires CAP_SYS_ADMIN
>  - __kernel_write() bails out on read-only files - but only since 5.8,
>    see commit a01ac27be472 ("fs: check FMODE_WRITE in __kernel_write")
> 
> Reported-and-tested-by: syzbot+12e098239d20385264d3@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=12e098239d20385264d3
> Fixes: 31db9f7c23fb ("Btrfs: introduce BTRFS_IOC_SEND for btrfs send/receive")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jann Horn <jannh@google.com>

Added to misc-next, thanks.

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-24 16:48 [PATCH] btrfs: send: Ensure send_fd is writable Jann Horn
2023-11-24 17:43 ` David Sterba [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=20231124174356.GH18929@suse.cz \
    --to=dsterba@suse.cz \
    --cc=ablock84@googlemail.com \
    --cc=alex.bolshoy.btrfs@gmail.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=jannh@google.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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