Skip to content

Commit 3cd013a

Browse files
committed
Merge branch 'stable-4.9' of git://git.infradead.org/users/pcmoore/audit
Pull audit updates from Paul Moore: "Another relatively small pull request for v4.9 with just two patches. The patch from Richard updates the list of features we support and report back to userspace; this should have been sent earlier with the rest of the v4.8 patches but it got lost in my inbox. The second patch fixes a problem reported by our Android friends where we weren't very consistent in recording PIDs" * 'stable-4.9' of git://git.infradead.org/users/pcmoore/audit: audit: add exclude filter extension to feature bitmap audit: consistently record PIDs with task_tgid_nr()
2 parents e46cae4 + 7ff89ac commit 3cd013a

4 files changed

Lines changed: 18 additions & 10 deletions

File tree

‎include/uapi/linux/audit.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,11 @@ enum {
329329
#define AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT 0x00000001
330330
#define AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME 0x00000002
331331
#define AUDIT_FEATURE_BITMAP_EXECUTABLE_PATH 0x00000004
332+
#define AUDIT_FEATURE_BITMAP_EXCLUDE_EXTEND 0x00000008
332333
#define AUDIT_FEATURE_BITMAP_ALL (AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT | \
333334
AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME | \
334-
AUDIT_FEATURE_BITMAP_EXECUTABLE_PATH)
335+
AUDIT_FEATURE_BITMAP_EXECUTABLE_PATH | \
336+
AUDIT_FEATURE_BITMAP_EXCLUDE_EXTEND)
335337

336338
/* deprecated: AUDIT_VERSION_* */
337339
#define AUDIT_VERSION_LATEST AUDIT_FEATURE_BITMAP_ALL

‎kernel/audit.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,12 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
877877
return err;
878878
}
879879
if (s.mask & AUDIT_STATUS_PID) {
880+
/* NOTE: we are using task_tgid_vnr() below because
881+
* the s.pid value is relative to the namespace
882+
* of the caller; at present this doesn't matter
883+
* much since you can really only run auditd
884+
* from the initial pid namespace, but something
885+
* to keep in mind if this changes */
880886
int new_pid = s.pid;
881887
pid_t requesting_pid = task_tgid_vnr(current);
882888

@@ -1917,7 +1923,7 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
19171923
" euid=%u suid=%u fsuid=%u"
19181924
" egid=%u sgid=%u fsgid=%u tty=%s ses=%u",
19191925
task_ppid_nr(tsk),
1920-
task_pid_nr(tsk),
1926+
task_tgid_nr(tsk),
19211927
from_kuid(&init_user_ns, audit_get_loginuid(tsk)),
19221928
from_kuid(&init_user_ns, cred->uid),
19231929
from_kgid(&init_user_ns, cred->gid),

‎kernel/auditsc.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static int audit_filter_rules(struct task_struct *tsk,
457457

458458
switch (f->type) {
459459
case AUDIT_PID:
460-
pid = task_pid_nr(tsk);
460+
pid = task_tgid_nr(tsk);
461461
result = audit_comparator(pid, f->op, f->val);
462462
break;
463463
case AUDIT_PPID:
@@ -1993,7 +1993,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
19931993
loginuid = from_kuid(&init_user_ns, kloginuid),
19941994
tty = audit_get_tty(current);
19951995

1996-
audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid);
1996+
audit_log_format(ab, "pid=%d uid=%u", task_tgid_nr(current), uid);
19971997
audit_log_task_context(ab);
19981998
audit_log_format(ab, " old-auid=%u auid=%u tty=%s old-ses=%u ses=%u res=%d",
19991999
oldloginuid, loginuid, tty ? tty_name(tty) : "(none)",
@@ -2220,7 +2220,7 @@ void __audit_ptrace(struct task_struct *t)
22202220
{
22212221
struct audit_context *context = current->audit_context;
22222222

2223-
context->target_pid = task_pid_nr(t);
2223+
context->target_pid = task_tgid_nr(t);
22242224
context->target_auid = audit_get_loginuid(t);
22252225
context->target_uid = task_uid(t);
22262226
context->target_sessionid = audit_get_sessionid(t);
@@ -2245,7 +2245,7 @@ int __audit_signal_info(int sig, struct task_struct *t)
22452245

22462246
if (audit_pid && t->tgid == audit_pid) {
22472247
if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1 || sig == SIGUSR2) {
2248-
audit_sig_pid = task_pid_nr(tsk);
2248+
audit_sig_pid = task_tgid_nr(tsk);
22492249
if (uid_valid(tsk->loginuid))
22502250
audit_sig_uid = tsk->loginuid;
22512251
else
@@ -2345,7 +2345,7 @@ int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
23452345
void __audit_log_capset(const struct cred *new, const struct cred *old)
23462346
{
23472347
struct audit_context *context = current->audit_context;
2348-
context->capset.pid = task_pid_nr(current);
2348+
context->capset.pid = task_tgid_nr(current);
23492349
context->capset.cap.effective = new->cap_effective;
23502350
context->capset.cap.inheritable = new->cap_effective;
23512351
context->capset.cap.permitted = new->cap_permitted;
@@ -2377,7 +2377,7 @@ static void audit_log_task(struct audit_buffer *ab)
23772377
from_kgid(&init_user_ns, gid),
23782378
sessionid);
23792379
audit_log_task_context(ab);
2380-
audit_log_format(ab, " pid=%d comm=", task_pid_nr(current));
2380+
audit_log_format(ab, " pid=%d comm=", task_tgid_nr(current));
23812381
audit_log_untrustedstring(ab, get_task_comm(comm, current));
23822382
audit_log_d_path_exe(ab, current->mm);
23832383
}

‎security/lsm_audit.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
220220
*/
221221
BUILD_BUG_ON(sizeof(a->u) > sizeof(void *)*2);
222222

223-
audit_log_format(ab, " pid=%d comm=", task_pid_nr(current));
223+
audit_log_format(ab, " pid=%d comm=", task_tgid_nr(current));
224224
audit_log_untrustedstring(ab, memcpy(comm, current->comm, sizeof(comm)));
225225

226226
switch (a->type) {
@@ -294,7 +294,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
294294
case LSM_AUDIT_DATA_TASK: {
295295
struct task_struct *tsk = a->u.tsk;
296296
if (tsk) {
297-
pid_t pid = task_pid_nr(tsk);
297+
pid_t pid = task_tgid_nr(tsk);
298298
if (pid) {
299299
char comm[sizeof(tsk->comm)];
300300
audit_log_format(ab, " opid=%d ocomm=", pid);

0 commit comments

Comments
 (0)