Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6743611ybi; Wed, 29 May 2019 12:24:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwipOPHvoOT6cDth6nVYBuvXugIjq+KZs0Gzs3oeP3WH6vw+uiacCe9C7Om/uxmxH+kC3pE X-Received: by 2002:aa7:8a53:: with SMTP id n19mr152836076pfa.11.1559157859987; Wed, 29 May 2019 12:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559157859; cv=none; d=google.com; s=arc-20160816; b=q4wK61Nl8RHK262m9H2Uz915fCdktlkoA/NC+1YeTT+dxAxB2Rj5fKJwHeyGILPnor qYiQ603Q+0+DKJnLcgx252nzww5DYDtaS/F7zccG2yx+YFOAr2br7LE+qZ2DZthT//0H HVfOjfE991bCGUUGk9klD2U8RdpEW6XipDdfcG4MT2iJt/sKXTfIoQulihgqSse73tFd 7Oz9gydtZ8qqkM0zEunfIVoFE41zf304DKQj1htjgKB/AdqcpwZjCa5bOOszIlOsxpde 48QH+rRnUAJxHbA7XL9F0xcN4ZihiT4sWMoYRPda9IBPl69Ws3XU3goj8V/OoppenTVp c/Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JuDM8FzvWLq/3sIRx2I/nBmaXEAYcl3k6zr8OA+PA4Y=; b=Oxt5dCa0Q4uV+OmzUTSbDHOOEjcQWQcJ4KhBJyXld9v5lEBcw1u4cYWEP/ElA35UU2 pP25EXtOboufZzSs9V0YVbSPnBU386tLlFz/kRPfelWOrI4EUc+BcAhgeagRx5xpcYyS HlQwKuE0e6C3RvgTuBfVAQHYdU7dwEGRTFEnFa6RCrjnG+QI+u9jeJLvbCRf2Blaqh6q K60qDHfJiZ7ioVvkg+nWQ6UgAuw3PQCHN56GBhSYTwzYM9G2ynZK/Y/FlCjwuM0ijgOo MxkZFGkF2NHZjjgDkO7YHrDYp8+PtQpkI0ZUkuz1FBvXMS5/w9W4gqBmPjOVYQi2hIPR PDiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mwpduTF3; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1si647446pgj.504.2019.05.29.12.24.04; Wed, 29 May 2019 12:24:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mwpduTF3; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726054AbfE2TYA (ORCPT + 99 others); Wed, 29 May 2019 15:24:00 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:41714 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbfE2TYA (ORCPT ); Wed, 29 May 2019 15:24:00 -0400 Received: by mail-yb1-f195.google.com with SMTP id d2so1213658ybh.8; Wed, 29 May 2019 12:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JuDM8FzvWLq/3sIRx2I/nBmaXEAYcl3k6zr8OA+PA4Y=; b=mwpduTF3byaxqEeCOSCreMuPuJrkGWIKgXRJGLsuLpq6p0uNNZzzvccuynksvfadCH iSSfBrLe+JjgxxSxHkt9u3VBJz93VIQaQYyg9f4mnUPCv0Gl4IXuohqcllwnUIKcQIU2 jFEIRImoGlNHqdywAs/f+I24o+aTTAWltjselmjHzTP63okjUhu7mE2Wxi8TByYWImrX xhtdY6AsJjqvJogj4BE5qMXUJB1+x1U3LX+mMdqmM4eo8ebFDk+wjMMnUnEXb5FVsatY DkLdj5OtlG2e+rfIkqB6TRrO4hDsShWoo+xXnWJm6yZzE/+AtPqYCmEd8WwUSOsoUYEC Akiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JuDM8FzvWLq/3sIRx2I/nBmaXEAYcl3k6zr8OA+PA4Y=; b=T+Fwx6xscIEZWIEmNPxqYWlBnieTZlrhbZBuRYxO8BLQQ/XK69dUK9yBTt6grj9/Bh FPZnrCtRji3qgQVEf+RqozhKP9Xjay/+Mkf7f3XhjWVgcRj5CZF+UwdAyroeUDdhjc4u 3z1qdQ7OlrkL32jnllMDrlUL+O4QRU2I/TSNtK74Tg/frVvnDdMuYOcFB/bLA7WJUTzu REHVeThN6CeWnipFAw+CNZg4VvQEI5srTri5B31xr0jKLuvQiaQRe2v4UayCG8Kz5IGa WnkT2mxZ/RDiP+9kpveYGqI6rQISXAW7TSSwk3NIGL43DkBrL+bUv7ARYcqNGBa7m1V7 1Nvg== X-Gm-Message-State: APjAAAWg+BKta0BIUeLpPJ26IFvBopbhKLkgPIa0vGeRJHeF1gMEF4Cu 1gbWcDCHlDFbxIzW7GHc4JXEBr+TyHcQlDsRbQQ= X-Received: by 2002:a25:c983:: with SMTP id z125mr59252647ybf.45.1559157838918; Wed, 29 May 2019 12:23:58 -0700 (PDT) MIME-Version: 1.0 References: <20190529174318.22424-1-amir73il@gmail.com> <20190529174318.22424-7-amir73il@gmail.com> <20190529182748.GF5231@magnolia> In-Reply-To: From: Amir Goldstein Date: Wed, 29 May 2019 22:23:46 +0300 Message-ID: Subject: Re: [PATCH v3 06/13] vfs: introduce file_modified() helper To: "Darrick J. Wong" Cc: Dave Chinner , Christoph Hellwig , linux-xfs , Olga Kornievskaia , Luis Henriques , Al Viro , linux-fsdevel , linux-api@vger.kernel.org, ceph-devel@vger.kernel.org, Linux NFS Mailing List , CIFS Content-Type: text/plain; charset="UTF-8" Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, May 29, 2019 at 10:08 PM Amir Goldstein wrote: > > On Wed, May 29, 2019 at 9:27 PM Darrick J. Wong wrote: > > > > On Wed, May 29, 2019 at 08:43:10PM +0300, Amir Goldstein wrote: > > > The combination of file_remove_privs() and file_update_mtime() is > > > quite common in filesystem ->write_iter() methods. > > > > > > Modelled after the helper file_accessed(), introduce file_modified() > > > and use it from generic_remap_file_range_prep(). > > > > > > Note that the order of calling file_remove_privs() before > > > file_update_mtime() in the helper was matched to the more common order by > > > filesystems and not the current order in generic_remap_file_range_prep(). > > > > > > Signed-off-by: Amir Goldstein > > > --- > > > fs/inode.c | 20 ++++++++++++++++++++ > > > fs/read_write.c | 21 +++------------------ > > > include/linux/fs.h | 2 ++ > > > 3 files changed, 25 insertions(+), 18 deletions(-) > > > > > > diff --git a/fs/inode.c b/fs/inode.c > > > index df6542ec3b88..2885f2f2c7a5 100644 > > > --- a/fs/inode.c > > > +++ b/fs/inode.c > > > @@ -1899,6 +1899,26 @@ int file_update_time(struct file *file) > > > } > > > EXPORT_SYMBOL(file_update_time); > > > > > > +/* Caller must hold the file's inode lock */ > > > +int file_modified(struct file *file) > > > +{ > > > + int err; > > > + > > > + /* > > > + * Clear the security bits if the process is not being run by root. > > > + * This keeps people from modifying setuid and setgid binaries. > > > + */ > > > + err = file_remove_privs(file); > > > + if (err) > > > + return err; > > > + > > > + if (likely(file->f_mode & FMODE_NOCMTIME)) > > > > I would not have thought NOCMTIME is likely? > > > > Maybe it is for io requests coming from overlayfs, but for regular uses > > I don't think that's true. > > Nope that's a typo. Good spotting. > Overlayfs doesn't set FMODE_NOCMTIME (yet). Only xfs does from > XFS_IOC_OPEN_BY_HANDLE, but I think Dave said that is a deprecated > API. so should have been very_unlikely(). > Is that an ACK with likely converted to unlikely? Thanks, Amir.