Thread (47 messages) 47 messages, 6 authors, 2024-07-23

Re: [PATCH bpf-next v4 02/20] lsm: Refactor return value of LSM hook inode_need_killpriv

From: Xu Kuohai <xukuohai@huaweicloud.com>
Date: 2024-07-13 08:07:10
Also in: bpf, linux-integrity, linux-kselftest, linux-security-module, selinux

On 7/11/2024 10:15 PM, Serge Hallyn wrote:
Jul 11, 2024 06:14:09 Xu Kuohai [off-list ref]:
quoted
From: Xu Kuohai <redacted>

To be consistent with most LSM hooks, convert the return value of
hook inode_need_killpriv to 0 or a negative error code.

Before:
- Both hook inode_need_killpriv and func security_inode_need_killpriv
   return > 0 if security_inode_killpriv is required, 0 if not, and < 0
   to abort the operation.

After:
- Both hook inode_need_killpriv and func security_inode_need_killpriv
   return 0 on success and a negative error code on failure.
   On success, hook inode_need_killpriv sets output param @need to true
   if security_inode_killpriv is required, and false if not. When @need
   is true, func security_inode_need_killpriv sets ATTR_KILL_PRIV flag
   in @attr; when false, it clears the flag.
   On failure, @need and @attr remains unchanged.

Signed-off-by: Xu Kuohai <redacted>
It looks ok - though unnecessary (I'm assuming a later patch works better with this) - , but I'd be more comfortable if it was documented that any callers of the need_killpriv hook must set need to false before calling. Or if the hooks set need to false at start.
I believe this is the only patch in the set that modifies 'inode_need_killpriv'.
I'll add an explanation for the initial value of '@need'.
Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help