Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 120652
b: refs/heads/master
c: e68b75a
h: refs/heads/master
v: v3
  • Loading branch information
Eric Paris authored and James Morris committed Nov 11, 2008
1 parent f19ddaa commit e8d9377
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3fc689e96c0c90b6fede5946d6c31075e9464f69
refs/heads/master: e68b75a027bb94066576139ee33676264f867b87
10 changes: 10 additions & 0 deletions trunk/include/linux/audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
#define AUDIT_TTY 1319 /* Input on an administrative TTY */
#define AUDIT_EOE 1320 /* End of multi-record event */
#define AUDIT_BPRM_FCAPS 1321 /* Information about fcaps increasing perms */
#define AUDIT_CAPSET 1322 /* Record showing argument to sys_capset */

#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
Expand Down Expand Up @@ -454,6 +455,7 @@ extern int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __u
extern int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification);
extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
extern void __audit_log_bprm_fcaps(struct linux_binprm *bprm, kernel_cap_t *pP, kernel_cap_t *pE);
extern int __audit_log_capset(pid_t pid, kernel_cap_t *eff, kernel_cap_t *inh, kernel_cap_t *perm);

static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp)
{
Expand Down Expand Up @@ -526,6 +528,13 @@ static inline void audit_log_bprm_fcaps(struct linux_binprm *bprm, kernel_cap_t
__audit_log_bprm_fcaps(bprm, pP, pE);
}

static inline int audit_log_capset(pid_t pid, kernel_cap_t *eff, kernel_cap_t *inh, kernel_cap_t *perm)
{
if (unlikely(!audit_dummy_context()))
return __audit_log_capset(pid, eff, inh, perm);
return 0;
}

extern int audit_n_rules;
extern int audit_signals;
#else
Expand Down Expand Up @@ -558,6 +567,7 @@ extern int audit_signals;
#define audit_mq_notify(d,n) ({ 0; })
#define audit_mq_getsetattr(d,s) ({ 0; })
#define audit_log_bprm_fcaps(b, p, e) do { ; } while (0)
#define audit_log_capset(pid, e, i, p) ({ 0; })
#define audit_ptrace(t) ((void)0)
#define audit_n_rules 0
#define audit_signals 0
Expand Down
48 changes: 48 additions & 0 deletions trunk/kernel/auditsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ struct audit_aux_data_bprm_fcaps {
struct audit_cap_data new_pcap;
};

struct audit_aux_data_capset {
struct audit_aux_data d;
pid_t pid;
struct audit_cap_data cap;
};

struct audit_tree_refs {
struct audit_tree_refs *next;
struct audit_chunk *c[31];
Expand Down Expand Up @@ -1397,6 +1403,14 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
audit_log_cap(ab, "new_pe", &axs->new_pcap.effective);
break; }

case AUDIT_CAPSET: {
struct audit_aux_data_capset *axs = (void *)aux;
audit_log_format(ab, "pid=%d", axs->pid);
audit_log_cap(ab, "cap_pi", &axs->cap.inheritable);
audit_log_cap(ab, "cap_pp", &axs->cap.permitted);
audit_log_cap(ab, "cap_pe", &axs->cap.effective);
break; }

}
audit_log_end(ab);
}
Expand Down Expand Up @@ -2569,6 +2583,40 @@ void __audit_log_bprm_fcaps(struct linux_binprm *bprm, kernel_cap_t *pP, kernel_
ax->new_pcap.effective = current->cap_effective;
}

/**
* __audit_log_capset - store information about the arguments to the capset syscall
* @pid target pid of the capset call
* @eff effective cap set
* @inh inheritible cap set
* @perm permited cap set
*
* Record the aguments userspace sent to sys_capset for later printing by the
* audit system if applicable
*/
int __audit_log_capset(pid_t pid, kernel_cap_t *eff, kernel_cap_t *inh, kernel_cap_t *perm)
{
struct audit_aux_data_capset *ax;
struct audit_context *context = current->audit_context;

if (likely(!audit_enabled || !context || context->dummy))
return 0;

ax = kmalloc(sizeof(*ax), GFP_KERNEL);
if (!ax)
return -ENOMEM;

ax->d.type = AUDIT_CAPSET;
ax->d.next = context->aux;
context->aux = (void *)ax;

ax->pid = pid;
ax->cap.effective = *eff;
ax->cap.inheritable = *eff;
ax->cap.permitted = *perm;

return 0;
}

/**
* audit_core_dumps - record information about processes that end abnormally
* @signr: signal value
Expand Down
5 changes: 5 additions & 0 deletions trunk/kernel/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* 30 May 2002: Cleanup, Robert M. Love <rml@tech9.net>
*/

#include <linux/audit.h>
#include <linux/capability.h>
#include <linux/mm.h>
#include <linux/module.h>
Expand Down Expand Up @@ -468,6 +469,10 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data)
i++;
}

ret = audit_log_capset(pid, &effective, &inheritable, &permitted);
if (ret)
return ret;

if (pid && (pid != task_pid_vnr(current)))
ret = do_sys_capset_other_tasks(pid, &effective, &inheritable,
&permitted);
Expand Down

0 comments on commit e8d9377

Please sign in to comment.