stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Nikolay Borisov <nborisov@suse.com>
Cc: stable@vger.kernel.org, dsterba@suse.com, osandov@fb.com
Subject: Re: [PATCH] Btrfs: fix clone vs chattr NODATASUM race
Date: Sun, 1 Jul 2018 13:33:27 +0200	[thread overview]
Message-ID: <20180701113327.GC21328@kroah.com> (raw)
In-Reply-To: <1529921616-28934-1-git-send-email-nborisov@suse.com>

On Mon, Jun 25, 2018 at 01:13:36PM +0300, Nikolay Borisov wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> In btrfs_clone_files(), we must check the NODATASUM flag while the
> inodes are locked. Otherwise, it's possible that btrfs_ioctl_setflags()
> will change the flags after we check and we can end up with a party
> checksummed file.
> 
> The race window is only a few instructions in size, between the if and
> the locks which is:
> 
> 3834         if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode))
> 3835                 return -EISDIR;
> 
> where the setflags must be run and toggle the NODATASUM flag (provided
> the file size is 0).  The clone will block on the inode lock, segflags
> takes the inode lock, changes flags, releases log and clone continues.
> 
> Not impossible but still needs a lot of bad luck to hit unintentionally.
> 
> Fixes: 0e7b824c4ef9 ("Btrfs: don't make a file partly checksummed through file clone")
> CC: stable@vger.kernel.org # 4.4+
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> Reviewed-by: David Sterba <dsterba@suse.com>
> [ update changelog ]
> Signed-off-by: David Sterba <dsterba@suse.com>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> [ adjusted for 4.4 ]
> ---
> 
> Hello Greg, 
> 
> Here is a fixed version of the above patch for 4.4. 

Next time please let me know what the original git commit id is, that
makes it easier for me to apply.

thanks,

greg k-h

      reply	other threads:[~2018-07-01 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21 21:17 FAILED: patch "[PATCH] Btrfs: fix clone vs chattr NODATASUM race" failed to apply to 4.4-stable tree gregkh
2018-06-25 10:13 ` [PATCH] Btrfs: fix clone vs chattr NODATASUM race Nikolay Borisov
2018-07-01 11:33   ` Greg KH [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=20180701113327.GC21328@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=dsterba@suse.com \
    --cc=nborisov@suse.com \
    --cc=osandov@fb.com \
    --cc=stable@vger.kernel.org \
    /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).