From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796399936; b=jHgsYp8/muyzRf24tX3PLGwCEAHbN/Ufo470qCx4Y5HevefXH2YERvj0PjNEWmsdfj7s jX44pV8vjC8Ud+KqfJMPivWX3ydw+G7jQxP/MzLcWPLMBpaW7M7C+EEIZAX+DI2qjlYEZ fiYMdPvf57gnRwo72q69LYoCykR/0ida5mxoVTizF1p7yFJdizw36rzvjja7PocGXKDvC Ov2DJwuJ4jKZaEjoMQk0BcPesPBDQNNiSsby1Y6WizeHAIwUnlNjwoWGoVboH1Vyi1X4W kvG9pwHE0RTdg8BgtBLmgxAZjM2yc7wqLRYKjUv2pVXkQUYxH63C8S1TYFF5e/s5SNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796399936; h=Received:DKIM-Signature:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=1l5OUokTty/J7ElHMSk6LoZpCPtjkET2bjqyF/qCELE=; b=kK9CfYskMkVKn1911N7saoeyGtoWPCuSPqcY+PBE6GtXxAVOUr/gM79lA8a/h9hOVYCG lnhfK2i0fAigCXKk86uKr0sZiFKYcvbSAV0sFB2ceDwu/dIZE26hjR3D0MyDv0873HAWB 4Q7LZ5QA8jn/a/N7d7nQvrqgajxxXU2E8oAzIlsRjHm7R/m/KUyVgEx7Y70DgkKuOEsMw YuFVWvPs+arj4ngPUN4UghRVdGb1yXUXmBcUXWUtGwMxffzMGcXFuoWNz1dY9X2+fLixS 5Ag0TibryOyodPYmKtEc1pKhPS8yrFKs1xsNfmuSogVlyQQAtm8POtq03jDOxGvzqtw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AkVG9KRf; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81DCA606A335; Fri, 4 Dec 2026 15:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AkVG9KRf Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9EF41F00936; Fri, 4 Dec 2026 15:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796399936; bh=1l5OUokTty/J7ElHMSk6LoZpCPtjkET2bjqyF/qCELE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=AkVG9KRf3GXT96YSgT5pPpDrqaQHpcQXQJoHFhN9/VYMqHUDnunDnU6ewaVA7uh+p J3vvYSRD0w6tbOnKXMRGmKace6OE3XProXftmiLMN1gWyNrWUzZdn3us+AmfiJ9O+3 PPSitinA1Wg2uMlnsr06ChT/ZDIVQ9U5JGpBMV6r6s2xoBMZpyOXHTpQy+ZersOsKQ VKEpQAGeZYtRUyTXfnUYZRFdF0KZuH+uDvi3Pv+F6d8CEkBKVxMUXBiOpZ6qOV0pMu KiVuxI2CArBmSJdkUj69ymlArm5xbz6YmRe6NvoyNjLSmBMKxeb+ldmgpRCixytR+2 aD766CEP/whNA== Date: Fri, 04 Dec 2026 05:58:55 -1000 Message-ID: From: Tejun Heo To: Josef Bacik Cc: Greg Kroah-Hartman , Christian Brauner , driver-core@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernfs: use the refreshed mode to drop setid on chown In-Reply-To: <20261203-b4-kernfs-chown-mode-v1-1-8dfef37010fb@bacik.io> References: <20261203-b4-kernfs-chown-mode-v1-1-8dfef37010fb@bacik.io> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit On Fri, Dec 04, 2026 at 10:35:15AM -0500, Josef Bacik wrote: > A chown through an inode with an old copy of the mode can leave setuid > or setgid set on the node, drop a setgid bit that should stay, or fail > with EPERM for a caller that neither owns the node nor has CAP_FOWNER. > All three reproduce with sysfs mounted in two network namespaces, a > chmod through one mount and the chown through the other. > > notify_change() sets ATTR_MODE only if the copy has a bit to drop, and > chown_common() goes by the copy for ATTR_KILL_SGID. "kernfs: refresh > the inode before changing attributes", which this builds on, computes > the mode again but keeps both decisions. > > Fix by making both decisions again from the refreshed inode, which also > means EPERM for such a caller where only the node has a bit to drop, as > with a current copy. > > Fixes: 3ff195b011d7 ("sysfs: Implement sysfs tagged directory support.") > Reported-by: Tejun Heo > Closes: https://lore.kernel.org/all/1347ee3f0a83e14e2ef5db37147e3966@kernel.org/ > Signed-off-by: Josef Bacik Acked-by: Tejun Heo Thanks. -- tejun