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=1796384532; b=nNA+cbVEATQLU6aaVaogcPOVANg9Hfmf806vw9LW8QmZDbTmFiY4BJQolMGxgwTGkY73 Lv89eMyPqPf4BQ4V9QCnTsakIBOm1V0PBb/r/GYzVYm2ZBtGFo1mh/4yR/ak8t9OxGwsS OQwEfaCz1J0VS66GuKk5m4WNRfB31ATEOHAfvd/BDeejHZzJV+JHF/vTCsZCY+IM83w5T vjD7WCQRD1fUmKkmwSg1gLW1gZzcqfOjfB2N+kww9zR2YOMj6R4jmH5MZfv6l4BCmaF3u N4GhTYpW7WKiEIvEjzsNco8h7Lj0WmK03yel0khH1vac5NotPxA4L4AfLxfXaxNxijA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384532; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=SRzpCQXCxqLJ5LiM4qqQ0VN1u1fflwgzMzLInXUrCmw=; b=CndJyyACSaYEL9vHqVzphDKR0jfPopPBziJAH18wB3B9qCFnT9AMNl4SwI/cvXSjdF1o Fp9hFKDPhAFX+Ek+ggaD43woaZ0py1MneM2h9jcW9P8finQ8RcrTVNKKnhVLLO7WQdLce 31djqCaV6lsUUafYOehY8aXi0VCEH0799LMT0ATyK8SXyOJUAoOtguICNafoHpOAfbUy9 QXm8ZmYyi6QBg1s+BSowl8yFKsaJarTEwtHZI/UvqKqgwczdZJFWAfQ6uqszk4KNhUC5x T18UVNeG/BHWorfr7/RALQXR/CFfn+su7Wna7GvlQyYViwqunUiuMGOEceROaKs4Lmw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=AkQlvfYc; 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 3637F606A322; Fri, 4 Dec 2026 11:42:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=AkQlvfYc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9604B1F00937; Fri, 4 Dec 2026 11:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384532; bh=SRzpCQXCxqLJ5LiM4qqQ0VN1u1fflwgzMzLInXUrCmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AkQlvfYcaRk5qRfpktYBOlZ/0KG80TfgmtqOwCNPre3vCIR5pVvZgBfcNrfKPGKOJ TCUjlszB7zu4M8TZhK47DCoEAzORNsF9FINVJCXk1ckkMqgtLg60N7K0pmJ0b7K6pp zEsWPV7xJJPZRfNyuZijWVNpBOPhb0vUD17dlr84= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , Jeff Layton , Christoph Hellwig , "Christian Brauner (Amutable)" , Sasha Levin Subject: [PATCH 6.6 0188/1167] statx: dont leak STATX_ATTR_CHANGE_MONOTONIC in stx_attributes_mask Date: Fri, 4 Dec 2026 18:53:35 +0900 Message-ID: <20261204100706.963665329@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeff Layton [ Upstream commit 925d238324c79bcb75ad0add1d1b9d31d5f48115 ] STATX_ATTR_CHANGE_MONOTONIC is kernel-internal. cp_statx() strips it from stx_attributes but copies attributes_mask verbatim, so it leaks to userland on filesystems that advertise it (nfs, ceph), e.g. stx_attributes_mask = 0x8000000000303000 on NFS. Add a new mask constant and apply it to both fields. Fixes: a1175d6b1bda ("vfs: plumb i_version handling into struct kstat") Reviewed-by: Jan Kara Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20261103-statx-v2-1-8b09aa8118ab@kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Christian Brauner (Amutable) Signed-off-by: Sasha Levin --- fs/stat.c | 6 +++--- include/linux/stat.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index 7c20f34207d20..95ab7120e2ed9 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -632,8 +632,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) /* STATX_CHANGE_COOKIE is kernel-only for now */ tmp.stx_mask = stat->result_mask & ~STATX_CHANGE_COOKIE; tmp.stx_blksize = stat->blksize; - /* STATX_ATTR_CHANGE_MONOTONIC is kernel-only for now */ - tmp.stx_attributes = stat->attributes & ~STATX_ATTR_CHANGE_MONOTONIC; + tmp.stx_attributes = stat->attributes & ~STATX_ATTR_INTERNAL_MASK; tmp.stx_nlink = stat->nlink; tmp.stx_uid = from_kuid_munged(current_user_ns(), stat->uid); tmp.stx_gid = from_kgid_munged(current_user_ns(), stat->gid); @@ -641,7 +640,8 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) tmp.stx_ino = stat->ino; tmp.stx_size = stat->size; tmp.stx_blocks = stat->blocks; - tmp.stx_attributes_mask = stat->attributes_mask; + tmp.stx_attributes_mask = stat->attributes_mask & + ~STATX_ATTR_INTERNAL_MASK; tmp.stx_atime.tv_sec = stat->atime.tv_sec; tmp.stx_atime.tv_nsec = stat->atime.tv_nsec; tmp.stx_btime.tv_sec = stat->btime.tv_sec; diff --git a/include/linux/stat.h b/include/linux/stat.h index 52150570d37a5..122c75d8fb3cb 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -63,4 +63,7 @@ struct kstat { /* file attribute values */ #define STATX_ATTR_CHANGE_MONOTONIC 0x8000000000000000ULL /* version monotonically increases */ +/* mask of STATX_ATTR_* bits that is private to the kernel */ +#define STATX_ATTR_INTERNAL_MASK (STATX_ATTR_CHANGE_MONOTONIC) + #endif -- 2.53.0