[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a8d55e0d41a35a1a3c5d3590240d16b@paul-moore.com>
Date: Thu, 18 Jul 2024 22:08:03 -0400
From: Paul Moore <paul@...l-moore.com>
To: Xu Kuohai <xukuohai@...weicloud.com>, bpf@...r.kernel.org, netdev@...r.kernel.org, linux-security-module@...r.kernel.org, linux-kselftest@...r.kernel.org, linux-integrity@...r.kernel.org, apparmor@...ts.ubuntu.com, selinux@...r.kernel.org
Cc: Alexei Starovoitov <ast@...nel.org>, Andrii Nakryiko <andrii@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...gle.com>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Matt Bobrowski <mattbobrowski@...gle.com>,
Brendan Jackman <jackmanb@...omium.org>, James Morris <jmorris@...ei.org>,
"Serge E . Hallyn" <serge@...lyn.com>, Khadija Kamran <kamrankhadijadj@...il.com>,
Casey Schaufler <casey@...aufler-ca.com>, Ondrej Mosnacek <omosnace@...hat.com>,
Kees Cook <keescook@...omium.org>, John Johansen <john.johansen@...onical.com>,
Lukas Bulwahn <lukas.bulwahn@...il.com>, Roberto Sassu <roberto.sassu@...wei.com>,
Shung-Hsi Yu <shung-hsi.yu@...e.com>, Edward Cree <ecree.xilinx@...il.com>,
Alexander Viro <viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>,
Trond Myklebust <trond.myklebust@...merspace.com>, Anna Schumaker <anna@...nel.org>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Stephen Smalley <stephen.smalley.work@...il.com>
Subject: Re: [PATCH v4 5/20] lsm: Refactor return value of LSM hook inode_copy_up_xattr
On Jul 11, 2024 Xu Kuohai <xukuohai@...weicloud.com> wrote:
>
> To be consistent with most LSM hooks, convert the return value of
> hook inode_copy_up_xattr to 0 or a negative error code.
>
> Before:
> - Hook inode_copy_up_xattr returns 0 when accepting xattr, 1 when
> discarding xattr, -EOPNOTSUPP if it does not know xattr, or any
> other negative error code otherwise.
>
> After:
> - Hook inode_copy_up_xattr returns 0 when accepting xattr, *-ECANCELED*
> when discarding xattr, -EOPNOTSUPP if it does not know xattr, or
> any other negative error code otherwise.
>
> Signed-off-by: Xu Kuohai <xukuohai@...wei.com>
> ---
> fs/overlayfs/copy_up.c | 6 +++---
> security/integrity/evm/evm_main.c | 2 +-
> security/security.c | 12 ++++++------
> security/selinux/hooks.c | 4 ++--
> security/smack/smack_lsm.c | 6 +++---
> 5 files changed, 15 insertions(+), 15 deletions(-)
...
> diff --git a/security/security.c b/security/security.c
> index 26eea8f4cd74..12215ca286af 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -2675,18 +2675,18 @@ EXPORT_SYMBOL(security_inode_copy_up);
> * lower layer to the union/overlay layer. The caller is responsible for
> * reading and writing the xattrs, this hook is merely a filter.
> *
> - * Return: Returns 0 to accept the xattr, 1 to discard the xattr, -EOPNOTSUPP
> - * if the security module does not know about attribute, or a negative
> - * error code to abort the copy up.
> + * Return: Returns 0 to accept the xattr, -ECANCELED to discard the xattr,
> + * -EOPNOTSUPP if the security module does not know about attribute,
> + * or a negative error code to abort the copy up.
> */
> int security_inode_copy_up_xattr(struct dentry *src, const char *name)
> {
> int rc;
>
> /*
> - * The implementation can return 0 (accept the xattr), 1 (discard the
> - * xattr), -EOPNOTSUPP if it does not know anything about the xattr or
> - * any other error code in case of an error.
> + * The implementation can return 0 (accept the xattr), -ECANCELED
> + * (discard the xattr), -EOPNOTSUPP if it does not know anything
> + * about the xattr or any other error code in case of an error.
> */
Updating the comment here is good, but considering that we also discuss
the return value in the function header comment, I think it might be
better to just remove this comment entirely and leave the function header
comment as the single source. Duplicated comments/docs tend to fall out
of sync and create confusion.
> rc = call_int_hook(inode_copy_up_xattr, src, name);
> if (rc != LSM_RET_DEFAULT(inode_copy_up_xattr))
--
paul-moore.com
Powered by blists - more mailing lists