Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'stable-4.7' of git://git.infradead.org/users/pcmoore/audit

Pull audit fixes from Paul Moore:
"Two small patches to fix audit problems in 4.7-rcX: the first fixes a
potential kref leak, the second removes some header file noise.

The first is an important bug fix that really should go in before 4.7
is released, the second is not critical, but falls into the very-nice-
to-have category so I'm including in the pull request.

Both patches are straightforward, self-contained, and pass our
testsuite without problem"

* 'stable-4.7' of git://git.infradead.org/users/pcmoore/audit:
audit: move audit_get_tty to reduce scope and kabi changes
audit: move calcs after alloc and check when logging set loginuid

+25 -28
-24
include/linux/audit.h
··· 26 26 #include <linux/sched.h> 27 27 #include <linux/ptrace.h> 28 28 #include <uapi/linux/audit.h> 29 - #include <linux/tty.h> 30 29 31 30 #define AUDIT_INO_UNSET ((unsigned long)-1) 32 31 #define AUDIT_DEV_UNSET ((dev_t)-1) ··· 347 348 return tsk->sessionid; 348 349 } 349 350 350 - static inline struct tty_struct *audit_get_tty(struct task_struct *tsk) 351 - { 352 - struct tty_struct *tty = NULL; 353 - unsigned long flags; 354 - 355 - spin_lock_irqsave(&tsk->sighand->siglock, flags); 356 - if (tsk->signal) 357 - tty = tty_kref_get(tsk->signal->tty); 358 - spin_unlock_irqrestore(&tsk->sighand->siglock, flags); 359 - return tty; 360 - } 361 - 362 - static inline void audit_put_tty(struct tty_struct *tty) 363 - { 364 - tty_kref_put(tty); 365 - } 366 - 367 351 extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); 368 352 extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); 369 353 extern void __audit_bprm(struct linux_binprm *bprm); ··· 504 522 { 505 523 return -1; 506 524 } 507 - static inline struct tty_struct *audit_get_tty(struct task_struct *tsk) 508 - { 509 - return NULL; 510 - } 511 - static inline void audit_put_tty(struct tty_struct *tty) 512 - { } 513 525 static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) 514 526 { } 515 527 static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid,
+17
kernel/audit.c
··· 1883 1883 audit_log_format(ab, " exe=(null)"); 1884 1884 } 1885 1885 1886 + struct tty_struct *audit_get_tty(struct task_struct *tsk) 1887 + { 1888 + struct tty_struct *tty = NULL; 1889 + unsigned long flags; 1890 + 1891 + spin_lock_irqsave(&tsk->sighand->siglock, flags); 1892 + if (tsk->signal) 1893 + tty = tty_kref_get(tsk->signal->tty); 1894 + spin_unlock_irqrestore(&tsk->sighand->siglock, flags); 1895 + return tty; 1896 + } 1897 + 1898 + void audit_put_tty(struct tty_struct *tty) 1899 + { 1900 + tty_kref_put(tty); 1901 + } 1902 + 1886 1903 void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk) 1887 1904 { 1888 1905 const struct cred *cred;
+4
kernel/audit.h
··· 23 23 #include <linux/audit.h> 24 24 #include <linux/skbuff.h> 25 25 #include <uapi/linux/mqueue.h> 26 + #include <linux/tty.h> 26 27 27 28 /* AUDIT_NAMES is the number of slots we reserve in the audit_context 28 29 * for saving names from getname(). If we get more names we will allocate ··· 262 261 263 262 extern void audit_log_d_path_exe(struct audit_buffer *ab, 264 263 struct mm_struct *mm); 264 + 265 + extern struct tty_struct *audit_get_tty(struct task_struct *tsk); 266 + extern void audit_put_tty(struct tty_struct *tty); 265 267 266 268 /* audit watch functions */ 267 269 #ifdef CONFIG_AUDIT_WATCH
+4 -4
kernel/auditsc.c
··· 63 63 #include <asm/unistd.h> 64 64 #include <linux/security.h> 65 65 #include <linux/list.h> 66 - #include <linux/tty.h> 67 66 #include <linux/binfmts.h> 68 67 #include <linux/highmem.h> 69 68 #include <linux/syscalls.h> ··· 1984 1985 if (!audit_enabled) 1985 1986 return; 1986 1987 1988 + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); 1989 + if (!ab) 1990 + return; 1991 + 1987 1992 uid = from_kuid(&init_user_ns, task_uid(current)); 1988 1993 oldloginuid = from_kuid(&init_user_ns, koldloginuid); 1989 1994 loginuid = from_kuid(&init_user_ns, kloginuid), 1990 1995 tty = audit_get_tty(current); 1991 1996 1992 - ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); 1993 - if (!ab) 1994 - return; 1995 1997 audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid); 1996 1998 audit_log_task_context(ab); 1997 1999 audit_log_format(ab, " old-auid=%u auid=%u tty=%s old-ses=%u ses=%u res=%d",