- 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)
Unified · Split
| @@ -220,7 +220,7 @@ extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); · 219 unmodified lines | |||
| 220 | extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, | 220 | extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, |
| 221 | const struct cred *new, | 221 | const struct cred *new, |
| 222 | const struct cred *old); | 222 | 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); |
| 224 | extern void __audit_mmap_fd(int fd, int flags); | 224 | extern void __audit_mmap_fd(int fd, int flags); |
| 225 | 225 | ||
| 226 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) | 226 | 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, · 58 unmodified lines | |||
| 285 | return 0; | 285 | return 0; |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 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, |
| 289 | const struct cred *old) | 289 | const struct cred *old) |
| 290 | { | 290 | { |
| 291 | if (unlikely(!audit_dummy_context())) | 291 | if (unlikely(!audit_dummy_context())) |
| 292 | __audit_log_capset(pid, new, old); | 292 | __audit_log_capset(new, old); |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | static inline void audit_mmap_fd(int fd, int flags) | 295 | 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, · 101 unmodified lines | |||
| 397 | { | 397 | { |
| 398 | return 0; | 398 | return 0; |
| 399 | } | 399 | } |
| 400 | static inline void audit_log_capset(pid_t pid, const struct cred *new, | 400 | static inline void audit_log_capset(const struct cred *new, |
| 401 | const struct cred *old) | 401 | const struct cred *old) |
| 402 | { } | 402 | { } |
| 403 | static inline void audit_mmap_fd(int fd, int flags) | 403 | static inline void audit_mmap_fd(int fd, int flags) |
| 404 | { } | 404 | { } |
| @@ -2321,18 +2321,16 @@ int __audit_log_bprm_fcaps(struct linux_binprm *bprm, · 2320 unmodified lines | |||
| 2321 | 2321 | ||
| 2322 | /** | 2322 | /** |
| 2323 | * __audit_log_capset - store information about the arguments to the capset syscall | 2323 | * __audit_log_capset - store information about the arguments to the capset syscall |
| 2324 | * @pid: target pid of the capset call | ||
| 2325 | * @new: the new credentials | 2324 | * @new: the new credentials |
| 2326 | * @old: the old (current) credentials | 2325 | * @old: the old (current) credentials |
| 2327 | * | 2326 | * |
| 2328 | * Record the aguments userspace sent to sys_capset for later printing by the | 2327 | * Record the aguments userspace sent to sys_capset for later printing by the |
| 2329 | * audit system if applicable | 2328 | * audit system if applicable |
| 2330 | */ | 2329 | */ |
| 2331 | void __audit_log_capset(pid_t pid, | 2330 | void __audit_log_capset(const struct cred *new, const struct cred *old) |
| 2332 | const struct cred *new, const struct cred *old) | ||
| 2333 | { | 2331 | { |
| 2334 | struct audit_context *context = current->audit_context; | 2332 | struct audit_context *context = current->audit_context; |
| 2335 | context->capset.pid = pid; | 2333 | context->capset.pid = task_pid_nr(current); |
| 2336 | context->capset.cap.effective = new->cap_effective; | 2334 | context->capset.cap.effective = new->cap_effective; |
| 2337 | context->capset.cap.inheritable = new->cap_effective; | 2335 | context->capset.cap.inheritable = new->cap_effective; |
| 2338 | context->capset.cap.permitted = new->cap_permitted; | 2336 | context->capset.cap.permitted = new->cap_permitted; |
| @@ -277,7 +277,7 @@ SYSCALL_DEFINE2(capset, cap_user_header_t, header, const cap_user_data_t, data) · 276 unmodified lines | |||
| 277 | if (ret < 0) | 277 | if (ret < 0) |
| 278 | goto error; | 278 | goto error; |
| 279 | 279 | ||
| 280 | audit_log_capset(pid, new, current_cred()); | 280 | audit_log_capset(new, current_cred()); |
| 281 | 281 | ||
| 282 | return commit_creds(new); | 282 | return commit_creds(new); |
| 283 | 283 | ||