Skip to content
/ linux Public

Commit 7dc4778

Browse files
WOnder93Sasha Levin
authored andcommitted
ipc: don't audit capability check in ipc_permissions()
[ Upstream commit 0715881 ] The IPC sysctls implement the ctl_table_root::permissions hook and they override the file access mode based on the CAP_CHECKPOINT_RESTORE capability, which is being checked regardless of whether any access is actually denied or not, so if an LSM denies the capability, an audit record may be logged even when access is in fact granted. It wouldn't be viable to restructure the sysctl permission logic to only check the capability when the access would be actually denied if it's not granted. Thus, do the same as in net_ctl_permissions() (net/sysctl_net.c) - switch from ns_capable() to ns_capable_noaudit(), so that the check never emits an audit record. Fixes: 0889f44 ("ipc: Check permissions for checkpoint_restart sysctls at open time") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Acked-by: Alexey Gladkov <legion@kernel.org> Acked-by: Serge Hallyn <serge@hallyn.com> Signed-off-by: Serge Hallyn <sergeh@kernel.org> Stable-dep-of: 8924336 ("ipc: don't audit capability check in ipc_permissions()") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2c80b09 commit 7dc4778

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

include/linux/capability.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ static inline bool checkpoint_restore_ns_capable(struct user_namespace *ns)
208208
ns_capable(ns, CAP_SYS_ADMIN);
209209
}
210210

211+
static inline bool checkpoint_restore_ns_capable_noaudit(struct user_namespace *ns)
212+
{
213+
return ns_capable_noaudit(ns, CAP_CHECKPOINT_RESTORE) ||
214+
ns_capable_noaudit(ns, CAP_SYS_ADMIN);
215+
}
216+
211217
/* audit system wants to get cap info from files as well */
212218
int get_vfs_caps_from_disk(struct mnt_idmap *idmap,
213219
const struct dentry *dentry,

ipc/ipc_sysctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int ipc_permissions(struct ctl_table_header *head, struct ctl_table *tabl
215215
if (((table->data == &ns->ids[IPC_SEM_IDS].next_id) ||
216216
(table->data == &ns->ids[IPC_MSG_IDS].next_id) ||
217217
(table->data == &ns->ids[IPC_SHM_IDS].next_id)) &&
218-
checkpoint_restore_ns_capable(ns->user_ns))
218+
checkpoint_restore_ns_capable_noaudit(ns->user_ns))
219219
mode = 0666;
220220
else
221221
#endif

0 commit comments

Comments
 (0)