Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp130583pxk; Tue, 15 Sep 2020 23:25:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMfQjBQHFmQVrHmEd96oF6QqZsiUIPgufQccC0+BZB4lf3R6ASlclsTFFYDx9J0/u2O4BP X-Received: by 2002:a17:906:fb97:: with SMTP id lr23mr24232147ejb.257.1600237514659; Tue, 15 Sep 2020 23:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600237514; cv=none; d=google.com; s=arc-20160816; b=FoX42YMdG/Gjxzkfk6PnJdRqd364yDnqlgvQGACYn5I0vrEN8W07+w/cLsQQKhHo0g OL/IshqEXPnbc/RsBDq7aHM66isMntIVE2VuXzAC+BWCBGA6D99B7H+3PUeH3hWdtJYq DmuFtvDnPCCdFPmVHW2MAS43Fq22MoiTznDL8Q5uUNfS8aMRHx024pocpvy83i0yrfk/ 7NICvR7/QQaoYj0CU+3B06MrfM6rOMmMKWBIJZIGXLSUIeOrbkgYVAzwTjlBBYctTvX1 R2i/u/7nhbQqGdMI5+ErlaiMQcJfPvCnN7XzE/hlbcjcAI22E+UObmF+TSnDFXp/QvdD g4hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=GIuJACXDqRQn158Nzy0RYapTVzHeVav6evih4PqISa8=; b=snJ2Q9OvCiVWJ/JfYLc3MtnWHzAdXRM46EpSpuJO8HnZC4/gOKId6C7oRZA5HH+mT5 ymrlTdi8JbQIiPqxl2EuvqEOG2k2fxdrIyKR8LqT7FpsdbfLI20kLhEnuOAso0wl2e1b mSMqmnRd/zyRafKr+mBh9lVx8iKDl6bOXUzJstzhXbUCJV4k2CYaWFr1Yhwp2sN8ixRR /+aBv7gy0s55GO0RJZKpxLzzj+7Sg7X1TLweMLQsKqkYqQHqSmGqqtKvyTPTmVYUTWxI Rero3AvB0yeYBX7U3AFq0C8/503m4mwpJRMKNn/q+4QpY5gbRZSHHRqU7Kct5gY3w6AX pOzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=Je8keS+B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n3si11263403edv.590.2020.09.15.23.24.52; Tue, 15 Sep 2020 23:25:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=Je8keS+B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726505AbgIPGXJ (ORCPT + 99 others); Wed, 16 Sep 2020 02:23:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbgIPGXH (ORCPT ); Wed, 16 Sep 2020 02:23:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D34C1C06174A; Tue, 15 Sep 2020 23:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GIuJACXDqRQn158Nzy0RYapTVzHeVav6evih4PqISa8=; b=Je8keS+BKmOmABK7Ae3+2AGN5R x9h2/kRzXT0poM6NwiRUUTwZPfBPr9E+tI7MbvgoC+3jVwZb8PkFGMmhjbs0FFrHv55MwWMDAc7oW rVntaaHYdCcRGnyUGktC+sB1a8J5Y88Clu0aLwmgCjB0mVyoycPJhksee566g4bP0Msnoedbp+hbz Q49qC5+fyhoey1jq4wOlYyx6Y9lwQqHKS8Q+uKJoCYvNJezubmLiUYEa7+tIHfZ0YNiND+MQ1c6l9 8b/EyiQU67nPibI/Zg3/gtZBVmQP/8ruINhLM1UJS/KWRw0VTy+mjpdaAHfpZOd3QRD77ZQLYY8qy 6B0ykUQw==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIQqK-0007Ip-T4; Wed, 16 Sep 2020 06:23:00 +0000 Date: Wed, 16 Sep 2020 07:23:00 +0100 From: Christoph Hellwig To: Greg KH Cc: Rich Felker , linux-api@vger.kernel.org, Alexander Viro , Christoph Hellwig , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] vfs: block chmod of symlinks Message-ID: <20200916062300.GA27867@infradead.org> References: <20200916002157.GO3265@brightrain.aerifal.cx> <20200916002253.GP3265@brightrain.aerifal.cx> <20200916061815.GB142621@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200916061815.GB142621@kroah.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 16, 2020 at 08:18:15AM +0200, Greg KH wrote: > On Tue, Sep 15, 2020 at 08:22:54PM -0400, Rich Felker wrote: > > It was discovered while implementing userspace emulation of fchmodat > > AT_SYMLINK_NOFOLLOW (using O_PATH and procfs magic symlinks; otherwise > > it's not possible to target symlinks with chmod operations) that some > > filesystems erroneously allow access mode of symlinks to be changed, > > but return failure with EOPNOTSUPP (see glibc issue #14578 and commit > > a492b1e5ef). This inconsistency is non-conforming and wrong, and the > > consensus seems to be that it was unintentional to allow link modes to > > be changed in the first place. > > > > Signed-off-by: Rich Felker > > --- > > fs/open.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/fs/open.c b/fs/open.c > > index 9af548fb841b..cdb7964aaa6e 100644 > > --- a/fs/open.c > > +++ b/fs/open.c > > @@ -570,6 +570,12 @@ int chmod_common(const struct path *path, umode_t mode) > > struct iattr newattrs; > > int error; > > > > + /* Block chmod from getting to fs layer. Ideally the fs would either > > + * allow it or fail with EOPNOTSUPP, but some are buggy and return > > + * an error but change the mode, which is non-conforming and wrong. */ > > + if (S_ISLNK(inode->i_mode)) > > + return -EOPNOTSUPP; > > I still fail to understand why these "buggy" filesystems can not be > fixed. Why are you papering over a filesystem-specific-bug with this > core kernel change that we will forever have to keep? Because checking this once in the VFS is much saner than trying to patch up a gazillion file systems.