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=1796025634; b=MPHL9pQXLxRb2GsjUylnKVVrP4F5A+vl3rcKbXrzAcdEqluoFJ0ry++LfKdDgmZxZfiv xGO1jCL0lyg+W0hpPQHEgmvi7l80j+6X88SGC3PrND92LK7srFEF1H9umWFyHJMf23V2p suZARD3oW+jk5xMQ7rUMPI8VHoHTrW3TQGtRsaiLvA3LEk+wz5yqJiG8BMgyJebwvL3g5 jobuWgy5mWp08dyCduFofRBhAQcMQRgNUx4WZGxhjwI4Gzkoia/4+qKFuAHc1yQ0GVu2X nKE8n8uwjAuv7Ks3IIKikgmoYymYmM97cAZSJWVi5fvwOJegT/p6n2Y+V8qhEbH/4+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796025634; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=JVxgFb+iQnFZgkT4JCmel2kGiQY1wgn1yIAb9a8TyPk=; b=Mj4pLU5+Q6HPJ8wdxyY5hK7a9zR067dqiiZ63gfPdg5I2D+MxDwrh5zhoPBKHRCJnHeT VKFTctkhlIb2ImlBVZgEek1MujoeYlvuYU9q8uvBo4qYUygOHhmk7vTwSxXQWUAhxirKT PXgpSspOC9hn/YZCy7ZRQAQXb+3ksv4mNlJkyK9qSfA4o6G2Gx8sGIWvuDKu2iie+xxDo C/D3yP6CGrxrHTtDzQZqRvCCe07COMw/CJA0bHH64o9h5M/CqdWXIbhdsruJ2mmWN/ypB OldB0RWP9rbUEyqD1yYW9LymXJm18dscn2rO36CTttxCT6RorqLdEIVqnOlOb8ckCPw== 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=Do8ZQp4D; 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 36964606A32C for ; Mon, 30 Nov 2026 08:00:33 +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=Do8ZQp4D Received: by smtp.kernel.org (Postfix) with ESMTPSA id BED4D1F00897 for ; Mon, 30 Nov 2026 08:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796025633; bh=JVxgFb+iQnFZgkT4JCmel2kGiQY1wgn1yIAb9a8TyPk=; h=From:Subject:Reply-To:Cc:In-Reply-To:References:Date; b=Do8ZQp4DgMlXt1ogLHfKNAc5/cNy4KR/81my61MqyNeXafWPz53E5dQmkDkyRmrVP 5qFlmA3Ik7hbtUQrgaJqOZCQ9m1Cydh1z9wQMUNFIiZ8ArwDYp5X98tmRNH8BfXAdn ohDR+Rp7bWCHBYL5Vv5UcveOonujV0MYLG5x2RLGiisnU5Cvb091rIuw/DADx9L5/H JsLqYv7uCZYW48eauvGBis4DlTuwuQx0PQF6ISfm75c5lo2TmEsjsjuFWaRa37+yUD KW8mSHuoqFTJE9bAPiB5VK/ysJeGGz0GpVn2MHQzHdQgtDUmCs5uhpO9OnPLK8vt3l zv/3228FQrQBw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] smack: mediate file attribute syscalls Reply-To: sashiko-reviews@lists.linux.dev Cc: linux-security-module@vger.kernel.org In-Reply-To: <20261130074845.2537541-1-shawnq1@163.com> References: <20261128082823.3074924-1-shawnq1@163.com> <9cd7e2c5-22a0-45fc-ad41-56bac8bcbbeb@schaufler-ca.com> <20261130074845.2537541-1-shawnq1@163.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 08:00:33 +0000 X-Mailing-List: linux-security-module@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 2 potential issues to consider: - [Medium] smack: missing IS_PRIVATE() check in smack_inode_file_getattr() and setattr - [Low] smack: conversational reply and revision notes in commit message -- commit def34cb2a8662edb62c35fd5980f1b8b6195ff82 Author: Shawn Shao > smack: mediate file attribute syscalls > > Hello, > > Thanks for the review. I added kernel-doc comments to both new hook > functions, including their parameters and return value. > > Smack lacks the inode_file_getattr and inode_file_setattr hooks. As a > result, file_getattr() and file_setattr() could bypass Smack's existing > read and write checks. The patch implements both hooks with the same acce= ss > checks as the existing getattr and setattr hooks. > > The reproducer runs as uid 1000 without capabilities and changes its Smack > label to Subject. A stat() on /mnt/secret is denied, but file_getattr() on > the same file succeeds. Subject can read the Control label but cannot wri= te > it. Yet file_setattr() clears flags on /mnt/control. Ordinary > open() checks continue to be enforced. With the patch, denied calls return > -EACCES, while permitted operations on /mnt/public still succeed. > > Tested source: v7.3-23903-g7cd8495c0f162 > compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0 > > The CONFIG_SECURITY_SMACK-enabled smack_lsm.o build completed with > KCFLAGS=3D-Wframe-larger-than=3D1280. The kernel-doc check for both callb= acks > completed without warnings. The behavioral reproducer and console output > are unchanged from v1: > https://gist.github.com/shaos26/fbf8b7f663ee82593d7d41623aa2e2c4 > > Fixes: defdd02d783c ("lsm: introduce new hooks for setting/getting inode = fsxattr") > Signed-off-by: Shawn Shao [Severity: Low] This isn't a bug, but the conversational reply ("Hello, Thanks for the review..."), v1 comparison notes, local build environment details, and external gist URL should be moved below the "---" tearline so they do not become part of the permanent git commit log. > diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c > index 8e88ac65fd7fc..da0aab6812b99 100644 > --- a/security/smack/smack_lsm.c > +++ b/security/smack/smack_lsm.c > @@ -1308,6 +1308,48 @@ static int smack_inode_getattr(const struct path *= path) > return rc; > } > =20 > +/** > + * smack_inode_file_getattr - Smack check for retrieving file attributes > + * @dentry: file to retrieve filesystem attributes from > + * @fa: attributes to get > + * > + * Returns 0 if access is permitted, an error code otherwise. > + */ > +static int smack_inode_file_getattr(struct dentry *dentry, > + struct file_kattr *fa) > +{ > + struct smk_audit_info ad; > + struct inode *inode =3D d_backing_inode(dentry); > + int rc; > + > + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); > + smk_ad_setfield_u_fs_path_dentry(&ad, dentry); > + rc =3D smk_curacc(smk_of_inode(inode), MAY_READ, &ad); > + rc =3D smk_bu_inode(inode, MAY_READ, rc); > + return rc; > +} > + > +/** > + * smack_inode_file_setattr - Smack check for setting file attributes > + * @dentry: file to set filesystem attributes on > + * @fa: attributes to set > + * > + * Returns 0 if access is permitted, an error code otherwise. > + */ > +static int smack_inode_file_setattr(struct dentry *dentry, > + struct file_kattr *fa) > +{ > + struct smk_audit_info ad; > + struct inode *inode =3D d_backing_inode(dentry); > + int rc; > + > + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); > + smk_ad_setfield_u_fs_path_dentry(&ad, dentry); > + rc =3D smk_curacc(smk_of_inode(inode), MAY_WRITE, &ad); > + rc =3D smk_bu_inode(inode, MAY_WRITE, rc); > + return rc; > +} [Severity: Medium] Should smack_inode_file_getattr() and smack_inode_file_setattr() return 0 when IS_PRIVATE(inode) is true? Unlike security_inode_getattr() and security_inode_setattr(), security_inode_file_getattr() and security_inode_file_setattr() do not filter out S_PRIVATE inodes before invoking the LSM hooks: security/security.c:security_inode_file_setattr() { return call_int_hook(inode_file_setattr, dentry, fa); } Other Smack hooks whose LSM wrappers do not check IS_PRIVATE(), such as smack_file_ioctl() and smack_file_receive(), explicitly check IS_PRIVATE(inode). Without that check here, vfs_fileattr_get() and vfs_fileattr_set() (for example via FS_IOC_GETFLAGS or file_getattr()) on an S_PRIVATE tmpfs inode received over SCM_RIGHTS or retained across a Smack label change will fail with -EACCES when the caller's label lacks access to the allocator's label. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130074845.2537= 541-1-shawnq1@163.com?part=3D1