Skip to content

Commit

Permalink
btrfs: send: Ensure send_fd is writable
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
thejh committed Nov 24, 2023
1 parent 98b1cc8 commit 573fd25
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/send.c
Expand Up @@ -8158,7 +8158,7 @@ long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
}

sctx->send_filp = fget(arg->send_fd);
if (!sctx->send_filp) {
if (!sctx->send_filp || !(sctx->send_filp->f_mode & FMODE_WRITE)) {
ret = -EBADF;
goto out;
}
Expand Down

0 comments on commit 573fd25

Please sign in to comment.