History

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)

Eric W. Biederman committed 13 years ago

Commit ca24a231 parent fc582ae3 files · +8 −10Browse files

Unified · Split

3 files
  1. include/linux/audit.h +5 −5
  2. kernel/auditsc.c +2 −4
  3. kernel/capability.c +1 −1
include/linux/audit.h+5−5
@@ -220,7 +220,7 @@ extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); · 219 unmodified lines
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, · 58 unmodified lines
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, · 101 unmodified lines
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+2−4
@@ -2321,18 +2321,16 @@ int __audit_log_bprm_fcaps(struct linux_binprm *bprm, · 2320 unmodified lines
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+1−1
@@ -277,7 +277,7 @@ SYSCALL_DEFINE2(capset, cap_user_header_t, header, const cap_user_data_t, data) · 276 unmodified lines
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