Skip to content

Commit ca24a23

Browse files
ebiedermeparis
authored andcommitted
audit: Simplify and correct audit_log_capset
- Always report the current process as capset now always only works on the current process. This prevents reporting 0 or a random pid in a random pid namespace. - Don't bother to pass the pid as is available. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> (cherry picked from commit bcc85f0af31af123e32858069eb2ad8f39f90e67) (cherry picked from commit f911cac4556a7a23e0b3ea850233d13b32328692) Signed-off-by: Richard Guy Briggs <rgb@redhat.com> [eparis: fix build error when audit disabled] Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent fc582ae commit ca24a23

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

include/linux/audit.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
220220
extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
221221
const struct cred *new,
222222
const struct cred *old);
223-
extern void __audit_log_capset(pid_t pid, const struct cred *new, const struct cred *old);
223+
extern void __audit_log_capset(const struct cred *new, const struct cred *old);
224224
extern void __audit_mmap_fd(int fd, int flags);
225225

226226
static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
@@ -285,11 +285,11 @@ static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
285285
return 0;
286286
}
287287

288-
static inline void audit_log_capset(pid_t pid, const struct cred *new,
288+
static inline void audit_log_capset(const struct cred *new,
289289
const struct cred *old)
290290
{
291291
if (unlikely(!audit_dummy_context()))
292-
__audit_log_capset(pid, new, old);
292+
__audit_log_capset(new, old);
293293
}
294294

295295
static inline void audit_mmap_fd(int fd, int flags)
@@ -397,8 +397,8 @@ static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
397397
{
398398
return 0;
399399
}
400-
static inline void audit_log_capset(pid_t pid, const struct cred *new,
401-
const struct cred *old)
400+
static inline void audit_log_capset(const struct cred *new,
401+
const struct cred *old)
402402
{ }
403403
static inline void audit_mmap_fd(int fd, int flags)
404404
{ }

kernel/auditsc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,18 +2321,16 @@ int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
23212321

23222322
/**
23232323
* __audit_log_capset - store information about the arguments to the capset syscall
2324-
* @pid: target pid of the capset call
23252324
* @new: the new credentials
23262325
* @old: the old (current) credentials
23272326
*
23282327
* Record the aguments userspace sent to sys_capset for later printing by the
23292328
* audit system if applicable
23302329
*/
2331-
void __audit_log_capset(pid_t pid,
2332-
const struct cred *new, const struct cred *old)
2330+
void __audit_log_capset(const struct cred *new, const struct cred *old)
23332331
{
23342332
struct audit_context *context = current->audit_context;
2335-
context->capset.pid = pid;
2333+
context->capset.pid = task_pid_nr(current);
23362334
context->capset.cap.effective = new->cap_effective;
23372335
context->capset.cap.inheritable = new->cap_effective;
23382336
context->capset.cap.permitted = new->cap_permitted;

kernel/capability.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ SYSCALL_DEFINE2(capset, cap_user_header_t, header, const cap_user_data_t, data)
277277
if (ret < 0)
278278
goto error;
279279

280-
audit_log_capset(pid, new, current_cred());
280+
audit_log_capset(new, current_cred());
281281

282282
return commit_creds(new);
283283

0 commit comments

Comments
 (0)