Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6727769ybi; Wed, 29 May 2019 12:09:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwep/JLLA4l2AI+YeWwHG5LFcs0syEID+6oyrEU3//ObknBTtvuUW1bsJd9etlyE/kfSY+g X-Received: by 2002:a17:902:5c2:: with SMTP id f60mr12821622plf.61.1559156982417; Wed, 29 May 2019 12:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559156982; cv=none; d=google.com; s=arc-20160816; b=NMShwmFewrvjkTqqrFkLyCrZ7gDFkm2IZ/7f0QFB0UlgBqN6tmKlXjWNZxbSJL6yP4 J3zpT8d+9KW48y4dFPy8yWOY4utNH5O97eBT2U09+TsrSjwL2kd8JCfJDMFq1nBUHliK G8Xvk9ixRZ14QCuZTsIOOPCyTvRotSMb4Iqv/hY7hA5E3o+7peLE3RpHLRZIbZwN/R/p kBMrFdcU7nH/eW4HRLKIHXeEQ/5XY8WWD7R/gpbckdU5//S+Olu2vb7R6V/24AZ7RT+U Z8yaBGsAQ1LreKv/d5Q+dy2SVPxWZ7gFN82Bsv6Xai602SSYEgDfaMZb0mqS4aSdOsLO 3Fxg== 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=3OGwXMfFFQztZM039mI0WMSn1MvrOmZGR4oYkysJC3w=; b=ovTReRi+sTJ25fm6sM8oz+lva46x8dZQaWS6lMJ2Ws9vsImxgE4QbViHlMvHv7ya0K y7KoyL7TqueGaxrwyky0bFRn8F9gmVD3iEzPQCJZHFtsXaE3PdeQ5Wjz9cvsh6R7aGob toFPX7Hpdf34v7Tq/13yEO+X/71YwGm0gH1ucPiKkLaV9lRu+/RwEl+jYD5CvcqhzL2c x1MHu0jWTuPxYB+s0Ql3dPNWAhXCiDBJ8POwHl4c1+1FHGsRvo0pRzZyDzF0nfNpnX+h t2hBzlCUuxIPkBABS+Kb7Kkxz3imZ3pKa6P5zLkJyOUPxM7NvjDdfMlV21mGEyvPxnhn n/tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SDTngy90; 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 j1si480693pld.399.2019.05.29.12.09.22; Wed, 29 May 2019 12:09:42 -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=SDTngy90; 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 S1726720AbfE2TI5 (ORCPT + 99 others); Wed, 29 May 2019 15:08:57 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:40938 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbfE2TI5 (ORCPT ); Wed, 29 May 2019 15:08:57 -0400 Received: by mail-yb1-f195.google.com with SMTP id g62so1198844ybg.7; Wed, 29 May 2019 12:08:56 -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=3OGwXMfFFQztZM039mI0WMSn1MvrOmZGR4oYkysJC3w=; b=SDTngy90DbeR+MzZDVKcRdkaLP1+vir+e/4EefAKUMh01+y3AxKsaTOgp8UXv9u/kE egvD3XMOaKIO6mAc28kewQPQfnR83nClWMseWJaKp6CGzxyo/3PIg6zwwDWixnB/rYvH TcQ4nbmzhMoJhgDROtSC68zFbYomgFQ+GGp/aBW2MLFRaJHBiLgo2XwXk5Fy5cLJxctl MhVPs2nmEpM6VLxLWpNAmlhW6wThw4YTXdQlFp6qXiHtXlnA7i6fuL3Oljw97t2qYByJ q61wR5WFYO+WhuKLMDDSg2TCWuoFvAzc4R6x2qrUWUFk+LqKNw55xJcOPmUqSsmGDzot 5dAw== 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=3OGwXMfFFQztZM039mI0WMSn1MvrOmZGR4oYkysJC3w=; b=tepq9LwD9Q65AtPHy2K92Beyy2IpUQkMCou9NP4F9Cen5KkIwN9j0c1ZTc4YGtKIUy bC6Wjj+hbq0tXmN6MT+rW0OmTAKf/yltwpGqiPF5s6nK5Zb4/Cy6dUWzQhys1Xy+/xdw uIzgqTSGMvZ7byukaRgM7cyqWEVcHpwvzYnLmiH8z7tC6uehLEYMy9QhLhx4ED8NdCwu ZYqLp5oa8gcBS9avMtk8f6CmIIJEViV4yV//k4PSjyDsNbl1gRfz/oL+1f5tHvMJEfdY peovjMeBBk3B1X4mKw/Q09jd37jc8MeXfjePLJQ/8H/pes4RLwv84STHQ3iwUdM/grGX F44g== X-Gm-Message-State: APjAAAWNgHqyv9WAHhwOXBzfGxKbmjAnyL6+jNqXfbeA56iuXQk4tMUg gMhpDbCfOXYOu/SkXOpMWYmFsfSqlbSIoZsGtNQ= X-Received: by 2002:a05:6902:4c3:: with SMTP id v3mr247877ybs.144.1559156935937; Wed, 29 May 2019 12:08:55 -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: <20190529182748.GF5231@magnolia> From: Amir Goldstein Date: Wed, 29 May 2019 22:08:44 +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 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(). Thanks, Amir.