Skip to content

Commit 0715881

Browse files
WOnder93Serge Hallyn
authored andcommitted
ipc: don't audit capability check in ipc_permissions()
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>
1 parent 24e9b43 commit 0715881

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

include/linux/capability.h

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

206+
static inline bool checkpoint_restore_ns_capable_noaudit(struct user_namespace *ns)
207+
{
208+
return ns_capable_noaudit(ns, CAP_CHECKPOINT_RESTORE) ||
209+
ns_capable_noaudit(ns, CAP_SYS_ADMIN);
210+
}
211+
206212
/* audit system wants to get cap info from files as well */
207213
int get_vfs_caps_from_disk(struct mnt_idmap *idmap,
208214
const struct dentry *dentry,

ipc/ipc_sysctl.c

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

0 commit comments

Comments
 (0)