Skip to content

Commit

Permalink
Merge tag 'audit-pr-20190507' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/pcmoore/audit

Pull audit updates from Paul Moore:
 "We've got a reasonably broad set of audit patches for the v5.2 merge
  window, the highlights are below:

   - The biggest change, and the source of all the arch/* changes, is
     the patchset from Dmitry to help enable some of the work he is
     doing around PTRACE_GET_SYSCALL_INFO.

     To be honest, including this in the audit tree is a bit of a
     stretch, but it does help move audit a little further along towards
     proper syscall auditing for all arches, and everyone else seemed to
     agree that audit was a "good" spot for this to land (or maybe they
     just didn't want to merge it? dunno.).

   - We can now audit time/NTP adjustments.

   - We continue the work to connect associated audit records into a
     single event"

* tag 'audit-pr-20190507' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: (21 commits)
  audit: fix a memory leak bug
  ntp: Audit NTP parameters adjustment
  timekeeping: Audit clock adjustments
  audit: purge unnecessary list_empty calls
  audit: link integrity evm_write_xattrs record to syscall event
  syscall_get_arch: add "struct task_struct *" argument
  unicore32: define syscall_get_arch()
  Move EM_UNICORE to uapi/linux/elf-em.h
  nios2: define syscall_get_arch()
  nds32: define syscall_get_arch()
  Move EM_NDS32 to uapi/linux/elf-em.h
  m68k: define syscall_get_arch()
  hexagon: define syscall_get_arch()
  Move EM_HEXAGON to uapi/linux/elf-em.h
  h8300: define syscall_get_arch()
  c6x: define syscall_get_arch()
  arc: define syscall_get_arch()
  Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
  audit: Make audit_log_cap and audit_copy_inode static
  audit: connect LOGIN record to its syscall record
  ...
  • Loading branch information
torvalds committed May 8, 2019
2 parents f72dae2 + 70c4cf1 commit 02aff8d
Show file tree
Hide file tree
Showing 43 changed files with 331 additions and 107 deletions.
2 changes: 1 addition & 1 deletion arch/alpha/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <uapi/linux/audit.h>

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_ALPHA;
}
Expand Down
6 changes: 1 addition & 5 deletions arch/arc/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
#define __ASM_ARC_ELF_H

#include <linux/types.h>
#include <linux/elf-em.h>
#include <uapi/asm/elf.h>

/* These ELF defines belong to uapi but libc elf.h already defines them */
#define EM_ARCOMPACT 93

#define EM_ARCV2 195 /* ARCv2 Cores */

#define EM_ARC_INUSE (IS_ENABLED(CONFIG_ISA_ARCOMPACT) ? \
EM_ARCOMPACT : EM_ARCV2)

Expand Down
11 changes: 11 additions & 0 deletions arch/arc/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef _ASM_ARC_SYSCALL_H
#define _ASM_ARC_SYSCALL_H 1

#include <uapi/linux/audit.h>
#include <linux/err.h>
#include <linux/sched.h>
#include <asm/unistd.h>
Expand Down Expand Up @@ -67,4 +68,14 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
}
}

static inline int
syscall_get_arch(struct task_struct *task)
{
return IS_ENABLED(CONFIG_ISA_ARCOMPACT)
? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
? AUDIT_ARCH_ARCOMPACTBE : AUDIT_ARCH_ARCOMPACT)
: (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
? AUDIT_ARCH_ARCV2BE : AUDIT_ARCH_ARCV2);
}

#endif
2 changes: 1 addition & 1 deletion arch/arm/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
memcpy(&regs->ARM_r0 + 1, args, 5 * sizeof(args[0]));
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
/* ARM tasks don't change audit architectures on the fly. */
return AUDIT_ARCH_ARM;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
* We don't care about endianness (__AUDIT_ARCH_LE bit) here because
* AArch64 has the same system calls both on little- and big- endian.
*/
static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
if (is_compat_task())
if (is_compat_thread(task_thread_info(task)))
return AUDIT_ARCH_ARM;

return AUDIT_ARCH_AARCH64;
Expand Down
7 changes: 7 additions & 0 deletions arch/c6x/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef __ASM_C6X_SYSCALL_H
#define __ASM_C6X_SYSCALL_H

#include <uapi/linux/audit.h>
#include <linux/err.h>
#include <linux/sched.h>

Expand Down Expand Up @@ -69,4 +70,10 @@ static inline void syscall_set_arguments(struct task_struct *task,
regs->a9 = *args;
}

static inline int syscall_get_arch(struct task_struct *task)
{
return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
? AUDIT_ARCH_C6XBE : AUDIT_ARCH_C6X;
}

#endif /* __ASM_C6X_SYSCALLS_H */
2 changes: 1 addition & 1 deletion arch/csky/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
}

static inline int
syscall_get_arch(void)
syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_CSKY;
}
Expand Down
6 changes: 6 additions & 0 deletions arch/h8300/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/linkage.h>
#include <linux/types.h>
#include <linux/ptrace.h>
#include <uapi/linux/audit.h>

static inline int
syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
Expand All @@ -27,6 +28,11 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
*args = regs->er6;
}

static inline int
syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_H8300;
}


/* Misc syscall related bits */
Expand Down
6 changes: 1 addition & 5 deletions arch/hexagon/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@

#include <asm/ptrace.h>
#include <asm/user.h>

/*
* This should really be in linux/elf-em.h.
*/
#define EM_HEXAGON 164 /* QUALCOMM Hexagon */
#include <linux/elf-em.h>

struct elf32_hdr;

Expand Down
8 changes: 8 additions & 0 deletions arch/hexagon/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef _ASM_HEXAGON_SYSCALL_H
#define _ASM_HEXAGON_SYSCALL_H

#include <uapi/linux/audit.h>

typedef long (*syscall_fn)(unsigned long, unsigned long,
unsigned long, unsigned long,
unsigned long, unsigned long);
Expand All @@ -41,4 +43,10 @@ static inline void syscall_get_arguments(struct task_struct *task,
{
memcpy(args, &(&regs->r00)[0], 6 * sizeof(args[0]));
}

static inline int syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_HEXAGON;
}

#endif
2 changes: 1 addition & 1 deletion arch/ia64/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
ia64_syscall_get_set_arguments(task, regs, args, 1);
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_IA64;
}
Expand Down
12 changes: 12 additions & 0 deletions arch/m68k/include/asm/syscall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_M68K_SYSCALL_H
#define _ASM_M68K_SYSCALL_H

#include <uapi/linux/audit.h>

static inline int syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_M68K;
}

#endif /* _ASM_M68K_SYSCALL_H */
2 changes: 1 addition & 1 deletion arch/microblaze/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs);
asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_MICROBLAZE;
}
Expand Down
6 changes: 3 additions & 3 deletions arch/mips/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ extern const unsigned long sys_call_table[];
extern const unsigned long sys32_call_table[];
extern const unsigned long sysn32_call_table[];

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
int arch = AUDIT_ARCH_MIPS;
#ifdef CONFIG_64BIT
if (!test_thread_flag(TIF_32BIT_REGS)) {
if (!test_tsk_thread_flag(task, TIF_32BIT_REGS)) {
arch |= __AUDIT_ARCH_64BIT;
/* N32 sets only TIF_32BIT_ADDR */
if (test_thread_flag(TIF_32BIT_ADDR))
if (test_tsk_thread_flag(task, TIF_32BIT_ADDR))
arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
unsigned long args[6];

sd.nr = syscall;
sd.arch = syscall_get_arch();
sd.arch = syscall_get_arch(current);
syscall_get_arguments(current, regs, args);
for (i = 0; i < 6; i++)
sd.args[i] = args[i];
Expand Down
3 changes: 1 addition & 2 deletions arch/nds32/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

#include <asm/ptrace.h>
#include <asm/fpu.h>
#include <linux/elf-em.h>

typedef unsigned long elf_greg_t;
typedef unsigned long elf_freg_t[3];

extern unsigned int elf_hwcap;

#define EM_NDS32 167

#define R_NDS32_NONE 0
#define R_NDS32_16_RELA 19
#define R_NDS32_32_RELA 20
Expand Down
9 changes: 9 additions & 0 deletions arch/nds32/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef _ASM_NDS32_SYSCALL_H
#define _ASM_NDS32_SYSCALL_H 1

#include <uapi/linux/audit.h>
#include <linux/err.h>
struct task_struct;
struct pt_regs;
Expand Down Expand Up @@ -145,4 +146,12 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,

memcpy(&regs->uregs[0] + 1, args, 5 * sizeof(args[0]));
}

static inline int
syscall_get_arch(struct task_struct *task)
{
return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
? AUDIT_ARCH_NDS32BE : AUDIT_ARCH_NDS32;
}

#endif /* _ASM_NDS32_SYSCALL_H */
6 changes: 6 additions & 0 deletions arch/nios2/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef __ASM_NIOS2_SYSCALL_H__
#define __ASM_NIOS2_SYSCALL_H__

#include <uapi/linux/audit.h>
#include <linux/err.h>
#include <linux/sched.h>

Expand Down Expand Up @@ -79,4 +80,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
regs->r9 = *args;
}

static inline int syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_NIOS2;
}

#endif
2 changes: 1 addition & 1 deletion arch/openrisc/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
memcpy(&regs->gpr[3], args, 6 * sizeof(args[0]));
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_OPENRISC;
}
Expand Down
4 changes: 2 additions & 2 deletions arch/parisc/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ static inline void syscall_rollback(struct task_struct *task,
/* do nothing */
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
int arch = AUDIT_ARCH_PARISC;
#ifdef CONFIG_64BIT
if (!is_compat_task())
if (!__is_compat_task(task))
arch = AUDIT_ARCH_PARISC64;
#endif
return arch;
Expand Down
10 changes: 8 additions & 2 deletions arch/powerpc/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ static inline void syscall_set_arguments(struct task_struct *task,
regs->orig_gpr3 = args[0];
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
int arch = is_32bit_task() ? AUDIT_ARCH_PPC : AUDIT_ARCH_PPC64;
int arch;

if (IS_ENABLED(CONFIG_PPC64) && !test_tsk_thread_flag(task, TIF_32BIT))
arch = AUDIT_ARCH_PPC64;
else
arch = AUDIT_ARCH_PPC;

#ifdef __LITTLE_ENDIAN__
arch |= __AUDIT_ARCH_LE;
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
memcpy(&regs->a1, args, 5 * sizeof(regs->a1));
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
#ifdef CONFIG_64BIT
return AUDIT_ARCH_RISCV64;
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ static inline void syscall_set_arguments(struct task_struct *task,
regs->orig_gpr2 = args[0];
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
#ifdef CONFIG_COMPAT
if (test_tsk_thread_flag(current, TIF_31BIT))
if (test_tsk_thread_flag(task, TIF_31BIT))
return AUDIT_ARCH_S390;
#endif
return AUDIT_ARCH_S390X;
Expand Down
2 changes: 1 addition & 1 deletion arch/sh/include/asm/syscall_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
regs->regs[4] = args[0];
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
int arch = AUDIT_ARCH_SH;

Expand Down
2 changes: 1 addition & 1 deletion arch/sh/include/asm/syscall_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
memcpy(&regs->regs[2], args, 6 * sizeof(args[0]));
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
int arch = AUDIT_ARCH_SH;

Expand Down
5 changes: 3 additions & 2 deletions arch/sparc/include/asm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ static inline void syscall_set_arguments(struct task_struct *task,
regs->u_regs[UREG_I0 + i] = args[i];
}

static inline int syscall_get_arch(void)
static inline int syscall_get_arch(struct task_struct *task)
{
#if defined(CONFIG_SPARC64) && defined(CONFIG_COMPAT)
return in_compat_syscall() ? AUDIT_ARCH_SPARC : AUDIT_ARCH_SPARC64;
return test_tsk_thread_flag(task, TIF_32BIT)
? AUDIT_ARCH_SPARC : AUDIT_ARCH_SPARC64;
#elif defined(CONFIG_SPARC64)
return AUDIT_ARCH_SPARC64;
#else
Expand Down
3 changes: 1 addition & 2 deletions arch/unicore32/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* ELF register definitions..
*/
#include <asm/ptrace.h>
#include <linux/elf-em.h>

typedef unsigned long elf_greg_t;
typedef unsigned long elf_freg_t[3];
Expand All @@ -28,8 +29,6 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];

typedef struct fp_state elf_fpregset_t;

#define EM_UNICORE 110

#define R_UNICORE_NONE 0
#define R_UNICORE_PC24 1
#define R_UNICORE_ABS32 2
Expand Down
12 changes: 12 additions & 0 deletions arch/unicore32/include/asm/syscall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_UNICORE_SYSCALL_H
#define _ASM_UNICORE_SYSCALL_H

#include <uapi/linux/audit.h>

static inline int syscall_get_arch(struct task_struct *task)
{
return AUDIT_ARCH_UNICORE;
}

#endif /* _ASM_UNICORE_SYSCALL_H */
Loading

0 comments on commit 02aff8d

Please sign in to comment.