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=1796225828; b=X0EawTMVoImYzDkcyA9Kwq4dZ1gNYO6eu78inFAi/Vm5xIOki47Z9g+aSYDYzRmoFngL 4b62Y/LLsy/r/lbswE9vD0z/l7PDgDLihWilbWpG8UjTdh2Aor1K8PKVvuPa5hZKLHr93 ddTrVMR0DtsYXFaTCir/SYpHIHjHrQBQzBQJDOdID6d3rhIHIi3M4LivWlFsLrUEu1Gg4 GQ4jVUHTU3PrEn4iNOA+gV7gJbsUaW/6Yhfyi93ht10Tm4qDvrEwNLHpwXloSyL31m6GK HrgvZgbI2xiL7RA2DmZoCkIC7ecS1JrQ4gUvza0gdZgSyN1nttg8jJKL2cA8Hv1n/iw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225828; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=eNmCxfRwVkZ3h8y+dj0LACtDnkHiv5LJ/piE3uWDj+I=; b=XjPMzzmFPUFwwyZ7s+b3c0WiHiyP+YA7UQERW7EzBw3IKW4d4xrokhIglvNbYqqswByc f40NnKRIB7ykGKKLeBc80sEk50lvaC2TA3uHsmeKUmqeYHkd+KwoY1+pKv00YAKnJpyzH 6g+KaMbzbQ6Br3YGs5UMu+zcZ/N7gJWkMIBuZqZ3hH6fvHGSgZoPQAU9CzWKyrJNhAnSy Q0Uv3zbH/3/JKwSLs4W8wo4CeVNO+xFqdhDQEW8QIwNoSbUE5qoSE0iUzAhZKhxUj72cL 6TAKb4m1STPfvQR1/SQ/Cs85vaUd6lMikO5X2wogC3u1gwneaC4+HnQyc2Rpqa8MV2Q== 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=NM6kLMrX; 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 E7851606A31A for ; Wed, 2 Dec 2026 15:37:07 +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=NM6kLMrX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EEE31F00893; Wed, 2 Dec 2026 15:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796225827; bh=eNmCxfRwVkZ3h8y+dj0LACtDnkHiv5LJ/piE3uWDj+I=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NM6kLMrXFpf2Ru0Tjwo2mPB44sONhkUqZUAMjtpXzDhukohW4gXdnCUUYS48ZbpYH w3FzY54fFgmgaf4dq0dcrQYo26Rkq6wCrS7eAT4sKJYf9t+VbIpn6ZlpA0A9S4Rpow 3Qx2Z/NGX3TjMOvveacrP4lnw9Uy+ZR/VUcIVt4E9PRuZdqLHoA7qH8Fob3cpfffGw 5/TBw9mpivrnZdau/JyeHBXDhfK9MOZwmKpqx4u8Yyvnd3nmaUqs5jVW5Dc0BVXUFK 1wviW8cQaftaLA/YgAWmBJQvEOGriH8wiLQwlSJUc8IJHb0tN/3tGjbAc8wVvpv+NZ dsu2oh8TN38Zw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ext4: restore the old mode if the ACL update fails Reply-To: sashiko-reviews@lists.linux.dev To: Alan <3164729207@qq.com> Cc: linux-ext4@vger.kernel.org, tytso@mit.edu In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 15:37:07 +0000 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] ext4: restoring old_mode in ext4_setattr() re-enables S_ISUID/S_ISGID -- commit 25d855847832145fc418799835c609dfdd478477 Author: Alan <3164729207@qq.com> ext4: restore the old mode if the ACL update fails This commit saves the previous inode->i_mode in ext4_setattr() and restores it if posix_acl_chmod() fails after setattr_copy() has already dirtied the new mode. > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index b4d581aa5ee1a..9de412540ddef 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -7029,6 +7029,7 @@ int ext4_setattr(const struct mnt_idmap *idmap, str= uct dentry *dentry, > struct iattr *attr) > { > struct inode *inode =3D d_inode(dentry); > + umode_t old_mode =3D inode->i_mode; > int error, rc =3D 0; > int orphan =3D 0; > const unsigned int ia_valid =3D attr->ia_valid; > @@ -7173,8 +7174,19 @@ int ext4_setattr(const struct mnt_idmap *idmap, st= ruct dentry *dentry, > if (orphan && inode->i_nlink) > ext4_orphan_del(NULL, inode); > =20 > - if (!error && (ia_valid & ATTR_MODE)) > + if (!error && (ia_valid & ATTR_MODE)) { > rc =3D posix_acl_chmod(idmap, dentry, inode->i_mode); > + if (rc) { > + /* > + * The mode was already copied into the inode and marked > + * dirty. If the ACL update failed, chmod() returns an > + * error but the new mode must not remain on disk while > + * the ACL still describes the old mode. > + */ > + inode->i_mode =3D old_mode; > + mark_inode_dirty(inode); > + } > + } [Severity: High] Can restoring the full old_mode re-enable S_ISUID or S_ISGID after the file has already been truncated or chowned? During truncate() or chown() on a setuid or setgid file, notify_change() translates ATTR_KILL_SUID and ATTR_KILL_SGID into ATTR_MODE with those bits cleared in attr->ia_mode. ext4_setattr() commits UID/GID updates and performs truncation before calling setattr_copy() and posix_acl_chmod(). If posix_acl_chmod() then fails (for example with -ENOSPC when unsharing a shared xattr block), writing back old_mode restores S_ISUID and S_ISGID on an inode whose ownership or contents have already been modified on disk. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/tencent_9246D288C78= 18FCDAA2F130315D73AFDEE05@qq.com?part=3D1