Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1260552pxk; Thu, 10 Sep 2020 10:53:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfOgmfKAwuMggTGyBNkD3VgZ5LCey1fLbMYwxPq5wq1mqlRhwz38gy9+jk3hkQfWjNgY+f X-Received: by 2002:a50:d2d1:: with SMTP id q17mr10551214edg.167.1599760426246; Thu, 10 Sep 2020 10:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599760426; cv=none; d=google.com; s=arc-20160816; b=WnGpu5MFf/QU+xLLePsGvxebzn8MUpbXaK/dzh49OpHMqBrgYtaVdiHsDcAazzJN1s A3FQuwuJR/yktb7bfPy+n7KEwLRs915C15iPAcsdqGPieeYXwM0f0i6At366D9IMJeb/ ef7qodisYN7P6k8dyUtmIJFDG3i9XhA1uI/RATur/oum0atJAgHNY4ZFEuSeGsbeZTMQ HIcthzIB/WjBWd+3lJFe6doWS6kuVJaliKH/cSrpmcwriLwo0bT40O0Fil68n3woatjr ubUgoKr4r5Q0iABr1RkftKBsrbb2hH+UlozR+hbfLLYV/isMPa+A7wkGpATFfXGvsFMt 4QVw== 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=T37+wIzHobUUPVu8uG8zyMAjACa68QQHwU22tHUCOYw=; b=DJ9Wi84B9k4MknVF/y0qIXikhls5v6D8Zh+Ml1Jg0Xru6W4g1C0eJNyToG0QtCr3Yi TyFji9j1h72j7eyy8zt6pZXi1iA0J0DB7I8hU56pMdUbY2DivE5uVT1Xwfy4+dB/VgjX iat6zksXeFn6Ru+fACGas9q4vtB1Kjj0khxp4onf7PqyPYUFJnE3TQOB3plIlfyvFF7A +UG6sBG2f8xott8gGhJx79CmsghHyApk+DiK+YMf3egObR5NBzUTCnQM7d0sPsli0nRS Edej3Bfoj2if8t0T1hV5AXaR/kkbSzrfC7df4no6aGHUgnVv3kE9uTswDiXkUI3s/XDB Zulw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KHCKfGsK; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si3949494ejt.14.2020.09.10.10.53.23; Thu, 10 Sep 2020 10:53:46 -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=pass header.i=@kernel.org header.s=default header.b=KHCKfGsK; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727807AbgIJRwf (ORCPT + 99 others); Thu, 10 Sep 2020 13:52:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:33952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbgIJQQ1 (ORCPT ); Thu, 10 Sep 2020 12:16:27 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F0D97206A1; Thu, 10 Sep 2020 16:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599754568; bh=OgY5Qs0sNgX7gxePvw0EADB/4fq3LgqYdQ2QJdS4vac=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KHCKfGsKA3ReD9imzv70TocLnWw5iHbWlUxyg+ll6jDcY60h4lO0g7s+W6Ct8yzhG lCmmijbG5GERgZMqeUjlrk7McAxgRxlhbzTsY+czFzji3d7z+JpmMa4X2Zk1o7G6pe xnDuwaLrL1mnY2X5VtddJI7Uu9VMBJ37O1HHfmQg= Date: Thu, 10 Sep 2020 18:16:15 +0200 From: Greg KH To: Rich Felker Cc: linux-api@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vfs: add fchmodat2 syscall Message-ID: <20200910161615.GA1180022@kroah.com> References: <20200910142335.GG3265@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910142335.GG3265@brightrain.aerifal.cx> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 10, 2020 at 10:23:37AM -0400, Rich Felker wrote: > POSIX defines fchmodat as having a 4th argument, flags, that can be > AT_SYMLINK_NOFOLLOW. Support for changing the access mode of symbolic > links is optional (EOPNOTSUPP allowed if not supported), but this flag > is important even on systems where symlinks do not have access modes, > since it's the only way to safely change the mode of a file which > might be asynchronously replaced with a symbolic link, without a race > condition whereby the link target is changed. > > It's possible to emulate AT_SYMLINK_NOFOLLOW in userspace, and both > musl libc and glibc do this, by opening an O_PATH file descriptor and > performing chmod on the corresponding magic symlink in /proc/self/fd. > However, this requires procfs to be mounted and accessible. > > It was determined (see glibc issue #14578 and commit a492b1e5ef) that, > on some filesystems, performing chmod on the link itself produces a > change in the inode's access mode, but returns an EOPNOTSUPP error. > This is non-conforming and wrong. Rather than try to fix all the > broken filesystem backends, block attempts to change the symlink > access mode via fchmodat2 at the frontend layer. This matches the > userspace emulation done in libc implementations. No change is made to > the underlying chmod_common(), so it's still possible to attempt > changes via procfs, if desired. If at some point all filesystems have > been fixed, this could be relaxed to allow filesystems to make their > own decision whether changing access mode of links is supported. A new syscall just because we have broken filesystems seems really odd, why not just fix the filesystems instead? thanks, greg k-h