arm64: Add audit support
Subsystems (13)
cover arm64: Add audit support
This patchset adds audit support on arm64.
The implementation is just like in other architectures, and so I think little explanation is needed.
I verified this patch with some commands on both 64-bit rootfs and 32-bit rootfs(, but only in little-endian):
# auditctl -a exit,always -S openat -F path=/etc/inittab # auditctl -a exit,always -F dir=/tmp -F perm=rw # auditctl -a task,always # autrace /bin/ls What else? (Thanks to Clayton for his cross-compiling patch)
I'd like to discuss about the following issues:
(issues)
* AUDIT_ARCH_*
Why do we need to distiguish big-endian and little-endian? [2/4]
* AArch32
We need to add a check for identifying the endian in 32-bit tasks. [3/4]
* syscall no in AArch32
Currently all the definitions are added in unistd32.h with "ifdef __AARCH32_AUDITSYSCALL" to use asm-generic/audit_*.h. [3/4] "ifdef" is necessary to avoid a conflict with 64-bit definitions. Do we need a more sophisticated way?
* TIF_AUDITSYSCALL
Most architectures, except x86, do not check TIF_AUDITSYSCALL. Why not? [4/4]
* Userspace audit package
There are some missing syscall definitions in lib/aarch64_table.h. There is no support for AUDIT_ARCH_ARM (I mean LE. armeb is BE).
AKASHI Takahiro (4):
audit: Enable arm64 support
arm64: Add audit support
arm64: audit: Add AArch32 support
arm64: audit: Add audit hook in ptrace/syscall_trace
arch/arm64/Kconfig | 3 + arch/arm64/include/asm/audit32.h | 12 ++ arch/arm64/include/asm/ptrace.h | 5 + arch/arm64/include/asm/syscall.h | 18 ++ arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/include/asm/unistd32.h | 387 ++++++++++++++++++++++++++++++++++ arch/arm64/kernel/Makefile | 4 + arch/arm64/kernel/audit.c | 77 +++++++ arch/arm64/kernel/audit32.c | 46 ++++ arch/arm64/kernel/entry.S | 3 + arch/arm64/kernel/ptrace.c | 12 ++ include/uapi/linux/audit.h | 2 + init/Kconfig | 2 +- 13 files changed, 571 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/audit32.h create mode 100644 arch/arm64/kernel/audit.c create mode 100644 arch/arm64/kernel/audit32.c
Signature · 1 line
1.7.9.5
PATCH 1/4 audit: Enable arm64 support
--- include/uapi/linux/audit.h | 2 ++ init/Kconfig | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/uapi/linux/audit.h +2 -0
@@ -324,6 +324,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
init/Kconfig +1 -1
@@ -284,7 +284,7 @@ config AUDIT config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64) default y if SECURITY_SELINUX help Enable low-overhead system-call auditing infrastructure that
Signature · 1 line
1.7.9.5
PATCH 2/4 arm64: Add audit support
In reply to AKASHI Takahiro--- arch/arm64/Kconfig | 3 ++ arch/arm64/include/asm/ptrace.h | 5 ++++ arch/arm64/include/asm/syscall.h | 18 ++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/audit.c | 59 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 arch/arm64/kernel/audit.c
arch/arm64/Kconfig +3 -0
@@ -46,6 +46,9 @@ config 64BIT config ARCH_PHYS_ADDR_T_64BIT def_bool y +config AUDIT_ARCH + def_bool y + config MMU def_bool y
arch/arm64/include/asm/ptrace.h +5 -0
@@ -133,6 +133,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ ((regs)->sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
arch/arm64/include/asm/syscall.h +18 -0
@@ -16,7 +16,10 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <linux/audit.h> #include <linux/err.h> +#include <linux/sched.h> +#include <asm/compat.h> static inline int syscall_get_nr(struct task_struct *task,
@@ -98,4 +101,19 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +static inline int syscall_get_arch (struct task_struct *task, +struct pt_regs *regs) +{ +#ifdef CONFIG_COMPAT +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ;/* FIXME: big endian? */ +#endif + +#ifdef __AARCH64EB__ +return AUDIT_ARCH_AARCH64EB ; +#else +return AUDIT_ARCH_AARCH64 ; +#endif +} +#endif /* __ASM_SYSCALL_H */
arch/arm64/kernel/Makefile +1 -0
@@ -11,6 +11,7 @@ arm64-obj-y := cputable.o debug-monitors.o entry.o irq.o fpsimd.o \ sys.o stacktrace.o time.o traps.o io.o vdso.o \ hyp-stub.o psci.o +arm64-obj-$(CONFIG_AUDIT) += audit.o arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ sys_compat.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o
arch/arm64/kernel/audit.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 2/4 arm64: Add audit support
Quoted 24 lines · AKASHI Takahiro
arch/arm64/kernel/audit.c new file +18
-0@@ -0,0 +1,59 @@ +#include <linux/audit.h> +#include <linux/init.h> +#include <asm/unistd.h> + +static unsigned dir_class[] = { +#include <asm-generic/audit_dir_write.h> +~0U +}; + +static unsigned read_class[] = { +#include <asm-generic/audit_read.h> +~0U +}; + +static unsigned write_class[] = { +#include <asm-generic/audit_write.h> +~0U +};
arch/arm64/kernel/audit.c line 28
Quoted 10 lines
arch/arm64/kernel/audit.c new file +10
-0+ +static unsigned chattr_class[] = { +#include <asm-generic/audit_change_attr.h> +~0U +}; + +static unsigned signal_class[] = { +#include <asm-generic/audit_signal.h> +~0U +};
This looks like a copy of lib/audit.c to me. Why can't we use that instead?
Will
PATCH 2/4 arm64: Add audit support
Quoted 29 lines · Will Deacon
Quoted 28 lines · AKASHI Takahiro
arch/arm64/kernel/audit.c new file +22
-0@@ -0,0 +1,59 @@ +#include <linux/audit.h> +#include <linux/init.h> +#include <asm/unistd.h> + +static unsigned dir_class[] = { +#include <asm-generic/audit_dir_write.h> +~0U +}; + +static unsigned read_class[] = { +#include <asm-generic/audit_read.h> +~0U +}; + +static unsigned write_class[] = { +#include <asm-generic/audit_write.h> +~0U +}; + +static unsigned chattr_class[] = { +#include <asm-generic/audit_change_attr.h> +~0U
Quoted 8 lines
arch/arm64/kernel/audit.c line 28
Quoted 6 lines
arch/arm64/kernel/audit.c new file +6
-0+}; + +static unsigned signal_class[] = { +#include <asm-generic/audit_signal.h> +~0U +};This looks like a copy of
lib/audit.cto me. Why can't we use that instead?
As you might notice, we need to have copies both for aarch64 and arch32 (compat system calls).
-Takahiro AKASHI
Quoted 2 lines
Will
PATCH 3/4 arm64: audit: Add AArch32 support
In reply to AKASHI Takahiro--- arch/arm64/include/asm/audit32.h | 12 ++ arch/arm64/include/asm/unistd32.h | 387 +++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/Makefile | 3 + arch/arm64/kernel/audit.c | 18 ++ arch/arm64/kernel/audit32.c | 46 +++++ 5 files changed, 466 insertions(+) create mode 100644 arch/arm64/include/asm/audit32.h create mode 100644 arch/arm64/kernel/audit32.c
arch/arm64/include/asm/audit32.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_AUDIT32_H +#define __ASM_AUDIT32_H + +extern unsigned aarch32_dir_class[]; +extern unsigned aarch32_read_class[]; +extern unsigned aarch32_write_class[]; +extern unsigned aarch32_chattr_class[]; +extern unsigned aarch32_signal_class[]; + +extern int aarch32_classify_syscall (unsigned ); + +#endif /* __ASM_AUDIT32_H */
arch/arm64/include/asm/unistd32.h +387 -0
393 lines not on this page · raw message
arch/arm64/kernel/Makefile +3 -0
@@ -12,6 +12,9 @@ arm64-obj-y := cputable.o debug-monitors.o entry.o irq.o fpsimd.o \ hyp-stub.o psci.o arm64-obj-$(CONFIG_AUDIT) += audit.o +ifeq ($(CONFIG_COMPAT),y) +arm64-obj-$(CONFIG_AUDIT) += audit32.o +endif arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ sys_compat.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o
arch/arm64/kernel/audit.c +18 -0
@@ -1,5 +1,8 @@#include <linux/audit.h> #include <linux/init.h> +#ifdef CONFIG_COMPAT +#include <asm/audit32.h> +#endif #include <asm/unistd.h> static unsigned dir_class[] = {
@@ -29,12 +32,20 @@ static unsigned signal_class[] = {int audit_classify_arch (int arch) { +#ifdef CONFIG_COMPAT +if (arch ==AUDIT_ARCH_ARM || arch ==AUDIT_ARCH_ARMEB ) +return 1 ;/* 32-bit on biarch */ +#endif return 0 ;/* native */ }/* AUTH_PERM support */ int audit_classify_syscall (int abi,unsigned syscall) { +#ifdef CONFIG_COMPAT +if (abi ==AUDIT_ARCH_ARM || abi ==AUDIT_ARCH_ARMEB ) +return aarch32_classify_syscall (syscall); +#endif switch (syscall) {case __NR_openat:return 3 ;
@@ -47,6 +58,13 @@ int audit_classify_syscall(int abi, unsigned syscall)static int __init audit_classes_init (void ) { +#ifdef CONFIG_COMPAT +audit_register_class (AUDIT_CLASS_DIR_WRITE_32 , aarch32_dir_class); +audit_register_class (AUDIT_CLASS_READ_32 , aarch32_read_class); +audit_register_class (AUDIT_CLASS_WRITE_32 , aarch32_write_class); +audit_register_class (AUDIT_CLASS_CHATTR_32 , aarch32_chattr_class); +audit_register_class (AUDIT_CLASS_SIGNAL_32 , aarch32_signal_class); +#endif audit_register_class (AUDIT_CLASS_DIR_WRITE , dir_class);audit_register_class (AUDIT_CLASS_READ , read_class);audit_register_class (AUDIT_CLASS_WRITE , write_class);
arch/arm64/kernel/audit32.c new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 3/4 arm64: audit: Add AArch32 support
Quoted 35 lines · AKASHI Takahiro
--- arch/arm64/include/asm/audit32.h | 12 ++ arch/arm64/include/asm/unistd32.h | 387 +++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/Makefile | 3 + arch/arm64/kernel/audit.c | 18 ++ arch/arm64/kernel/audit32.c | 46 +++++ 5 files changed, 466 insertions(+) create mode 100644 arch/arm64/include/asm/audit32.h create mode 100644 arch/arm64/kernel/audit32.carch/arm64/include/asm/audit32.h new file +12
-0@@ -0,0 +1,12 @@ +#ifndef __ASM_AUDIT32_H +#define __ASM_AUDIT32_H + +extern unsigned aarch32_dir_class[]; +extern unsigned aarch32_read_class[]; +extern unsigned aarch32_write_class[]; +extern unsigned aarch32_chattr_class[]; +extern unsigned aarch32_signal_class[]; + +extern int aarch32_classify_syscall (unsigned ); + +#endif /* __ASM_AUDIT32_H */ arch/arm64/include/asm/unistd32.h +0
-0@@ -21,6 +21,393 @@#define __SYSCALL (x, y)#endif
arch/arm64/include/asm/unistd32.h line 32
Quoted 10 lines
arch/arm64/include/asm/unistd32.h +9
-0+#ifdef __AARCH32_AUDITSYSCALL +/* +* FIXME: Currenty only audit uses (part of) these definitions. +* See audit32.c +*/ +#define __NR_restart_syscall 0 +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3
Don't bother with this file. It's a needless replication of data already in the file and you don't even need it all.
Quoted 41 lines
arch/arm64/kernel/audit32.c new file +35
-0@@ -0,0 +1,46 @@ +#define __AARCH32_AUDITSYSCALL +#include <asm/unistd32.h> + +unsigned aarch32_dir_class[] = { +#include <asm-generic/audit_dir_write.h> +~0U +}; + +unsigned aarch32_read_class[] = { +#include <asm-generic/audit_read.h> +~0U +}; + +unsigned aarch32_write_class[] = { +#include <asm-generic/audit_write.h> +~0U +}; + +unsigned aarch32_chattr_class[] = { +#include <asm-generic/audit_change_attr.h> +~0U +}; + +unsigned aarch32_signal_class[] = { +#include <asm-generic/audit_signal.h> +~0U +}; + +int aarch32_classify_syscall (unsigned syscall) +{ +switch (syscall) { +case __NR_open: +return 2 ; +case __NR_openat: +return 3 ;
arch/arm64/kernel/audit32.c line 45
Quoted 10 lines
arch/arm64/kernel/audit32.c new file +10
-0+/* +* obsolute in EABI +* case __NR_socketcall: +* return 4; +*/ +case __NR_execve: +return 5 ; +default : +return 1 ;/* 32-bit on biarch */ + }
Instead, just add __NR_compat_{open,openat,execve}, like we have done for the signal-related syscalls.
Also, can't the generic lib/audit.c be reworked to work with compat too?
Will
PATCH 3/4 arm64: audit: Add AArch32 support
Quoted 37 lines · Will Deacon
Quoted 36 lines · AKASHI Takahiro
--- arch/arm64/include/asm/audit32.h | 12 ++ arch/arm64/include/asm/unistd32.h | 387 +++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/Makefile | 3 + arch/arm64/kernel/audit.c | 18 ++ arch/arm64/kernel/audit32.c | 46 +++++ 5 files changed, 466 insertions(+)create mode 100644
arch/arm64/include/asm/audit32.hcreate mode 100644arch/arm64/kernel/audit32.carch/arm64/include/asm/audit32.h new file +12
-0@@ -0,0 +1,12 @@ +#ifndef __ASM_AUDIT32_H +#define __ASM_AUDIT32_H + +extern unsigned aarch32_dir_class[]; +extern unsigned aarch32_read_class[]; +extern unsigned aarch32_write_class[]; +extern unsigned aarch32_chattr_class[]; +extern unsigned aarch32_signal_class[]; + +extern int aarch32_classify_syscall (unsigned ); + +#endif /* __ASM_AUDIT32_H */ arch/arm64/include/asm/unistd32.h +0
-0@@ -21,6 +21,393 @@#define __SYSCALL (x, y)#endif
Quoted 12 lines
arch/arm64/include/asm/unistd32.h line 32
Quoted 9 lines
arch/arm64/include/asm/unistd32.h +9
-0+#ifdef __AARCH32_AUDITSYSCALL +/* +* FIXME: Currenty only audit uses (part of) these definitions. +* See audit32.c +*/ +#define __NR_restart_syscall 0 +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3Don't bother with this file. It's a needless replication of data already in the file and you don't even need it all.
Unfortunately, I need them not only for aarch32_classify_syscall(), but also in asm-generic/audit_*.h. Actually 47 of __NR_xxx are referred to in those files.
The problem is that aarch64 and aarch32 have different system call numbers, but that there are no __NR_xxx definitions for aarch32 in asm/unistd32.h.
Quoted 46 lines
Quoted 46 lines
arch/arm64/kernel/audit32.c new file +40
-0@@ -0,0 +1,46 @@ +#define __AARCH32_AUDITSYSCALL +#include <asm/unistd32.h> + +unsigned aarch32_dir_class[] = { +#include <asm-generic/audit_dir_write.h> +~0U +}; + +unsigned aarch32_read_class[] = { +#include <asm-generic/audit_read.h> +~0U +}; + +unsigned aarch32_write_class[] = { +#include <asm-generic/audit_write.h> +~0U +}; + +unsigned aarch32_chattr_class[] = { +#include <asm-generic/audit_change_attr.h> +~0U +}; + +unsigned aarch32_signal_class[] = { +#include <asm-generic/audit_signal.h> +~0U +}; + +int aarch32_classify_syscall (unsigned syscall) +{ +switch (syscall) { +case __NR_open: +return 2 ; +case __NR_openat: +return 3 ; +/* +* obsolute in EABI +* case __NR_socketcall: +* return 4; +*/
Quoted 8 lines
arch/arm64/kernel/audit32.c line 45
Quoted 5 lines
arch/arm64/kernel/audit32.c new file +5
-0+case __NR_execve: +return 5 ; +default : +return 1 ;/* 32-bit on biarch */ + }Instead, just add __NR_compat_{open,openat,execve}, like we have done for the signal-related syscalls.
As far as xxx_classify_syscall is concerned, it is possible to change the code to use __NR_compat_..., but it is difficult to remove __NR_... from unistd32.h because, as I mentioned above, asm-generic/audit_xxx.h use __NR_...
Quoted 1 line
Also, can't the generic
lib/audit.cbe reworked to work with compat too?
I hope so, but don't think re-work is practical unless we have generic solution against this issue.
(In addition, other architectures already have their own implementation.)
-Takahiro AKASHI
Quoted 2 lines
Will
PATCH 4/4 arm64: audit: Add audit hook in ptrace/syscall_trace
In reply to AKASHI Takahiro--- arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 12 ++++++++++++ 3 files changed, 16 insertions(+)
arch/arm64/include/asm/thread_info.h +1 -0
@@ -107,6 +107,7 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
arch/arm64/kernel/entry.S +3 -0
@@ -646,6 +646,9 @@ el0_svc_naked: // compat entry point get_thread_info tsk ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? +#ifdef CONFIG_AUDITSYSCALL + tbnz x16, #TIF_SYSCALL_AUDIT, __sys_trace // auditing syscalls? +#endif adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
arch/arm64/kernel/ptrace.c +12 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1066,6 +1068,16 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; +#ifdef CONFIG_AUDITSYSCALL +if (dir) +audit_syscall_exit (regs); +else +audit_syscall_entry (syscall_get_arch (current, regs), + regs->syscallno, + regs->regs[0 ], regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]); +#endif /* CONFIG_AUDITSYSCALL */ +if (!test_thread_flag (TIF_SYSCALL_TRACE ))return regs->syscallno;
Signature · 1 line
1.7.9.5
cover arm64: Add audit support
In reply to AKASHI TakahiroQuoted 3 lines · AKASHI Takahiro
This patchset adds audit support on arm64.
The implementation is just like in other architectures, and so I think little explanation is needed.
That doesn't mean you can just omit the commit messages!
Quoted 4 lines
I'd like to discuss about the following issues:
(issues)
* AUDIT_ARCH_*
Why do we need to distiguish big-endian and little-endian? [2/4]
We don't. This is only the case if the syscall ABIs differ between them (for AArch32, people mistakenly thought __ARMEB__ was related to AEABI.
Quoted 3 lines
* Userspace audit package
There are some missing syscall definitions inlib/aarch64_table.h. There is no support forAUDIT_ARCH_ARM(I mean LE. armeb is BE).
I did post something over a year ago... did it not get picked up?
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/165266
Will
cover arm64: Add audit support
Quoted 6 lines · Will Deacon
Quoted 3 lines · AKASHI Takahiro
This patchset adds audit support on arm64.
The implementation is just like in other architectures, and so I think little explanation is needed.That doesn't mean you can just omit the commit messages!
I will include some commit messages in the next version.
Quoted 7 lines
Quoted 4 lines
I'd like to discuss about the following issues:
(issues)
* AUDIT_ARCH_*
Why do we need to distiguish big-endian and little-endian? [2/4]We don't. This is only the case if the syscall ABIs differ between them (for AArch32, people mistakenly thought
__ARMEB__was related to AEABI.
I guessed so, but ...
Quoted 7 lines
Quoted 3 lines
* Userspace audit package
There are some missing syscall definitions inlib/aarch64_table.h. There is no support forAUDIT_ARCH_ARM(I mean LE. armeb is BE).I did post something over a year ago... did it not get picked up?
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/165266
Sounds great, but the reality is that AUDIT_ARCH_ARMEB is still used in the latest v2.3.2, and due to this, ausearch cannot pretty-print the architecture name in the audit log for LE.
I will ask this in linux-audit ML.
-Takahiro AKASHI
Quoted 2 lines
Will
v2 cover arm64: Add audit support
In reply to AKASHI TakahiroThis patchset adds system call audit support on arm64.
Both 32-bit (AUIDT_ARCH_ARM[EB]) and 64-bit tasks (AUDIT_ARCH_AARCH64[EB]) are supported, but presuming 32-LE on 64-LE or 32-BE on 64-BE.
There are some prerequisites for this patch to work correctly:
* "generic compat system call audit support" patch
* "correct a type mismatch in audit_syscall_exit()" patch (already accepted and queued in 3.14)
* "Modify a set of system calls in audit class" patch
* userspace audit tool (v2.3.2 + my patch for arm64)
All those were already or will be soon posted separately. Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace
# auditctl -a exit,always -S openat -F path=/etc/inittab
# auditctl -a exit,always -F dir=/tmp -F perm=rw
# auditctl -a task,always
# autrace /bin/ls
by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.
Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header, unistd_32.h, is automatically generated from unistd32.h.
* Refer to regs->orig_x0 instead of regs->x0 as the first argument of system call in audit_syscall_entry() [6/6]
* Include "Add regs_return_value() in syscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".
AKASHI Takahiro (6):
audit: Enable arm64 support
arm64: Add regs_return_value() in syscall.h
arm64: Add audit support
arm64: audit: Add 32-bit (compat) syscall support
arm64: audit: Add makefile rule to create unistd_32.h for compat
syscalls
arm64: audit: Add audit hook in ptrace/syscall_trace
arch/arm64/Makefile | 4 ++++ arch/arm64/include/asm/audit.h | 20 ++++++++++++++++++++ arch/arm64/include/asm/ptrace.h | 5 +++++ arch/arm64/include/asm/syscall.h | 22 ++++++++++++++++++++++ arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 12 ++++++++++++ arch/arm64/kernel/syscalls/Makefile | 20 ++++++++++++++++++++ include/uapi/linux/audit.h | 2 ++ init/Kconfig | 2 +- 10 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/audit.h create mode 100644 arch/arm64/kernel/syscalls/Makefile
Signature · 1 line
1.7.9.5
PATCH v2 1/6 audit: Enable arm64 support
This patch adds AUDIT_ARCH_* identifiers for arm64(AArch64), and makes CONFIG_AUDITSYSCALL selectable.
--- include/uapi/linux/audit.h | 2 ++ init/Kconfig | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/uapi/linux/audit.h +2 -0
@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
init/Kconfig +1 -1
@@ -284,7 +284,7 @@ config AUDIT config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64) default y if SECURITY_SELINUX help Enable low-overhead system-call auditing infrastructure that
Signature · 1 line
1.7.9.5
Catalin Marinas
maintainerRe: [PATCH v2 1/6] audit: Enable arm64 support
Quoted 16 lines · AKASHI Takahiro
include/uapi/linux/audit.h +2
-0@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)init/Kconfig +0
-0
init/Kconfig config AUDIT · line 287
Quoted 5 lines
init/Kconfig +1
-1@@ -284,7 +284,7 @@ config AUDIT config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64)
The usual comment for such changes: could you please clean this up and just use something like "depends on HAVE_ARCH_AUDITSYSCALL"?
Signature · 1 line
Catalin
Re: [PATCH v2 1/6] audit: Enable arm64 support
[To audit maintainers]
Quoted 18 lines · Catalin Marinas
Quoted 17 lines · AKASHI Takahiro
include/uapi/linux/audit.h +2
-0@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)init/Kconfig +0
-0@@ -284,7 +284,7 @@ config AUDIT
Quoted 7 lines
init/Kconfig config AUDIT · line 287
Quoted 4 lines
init/Kconfig +1
-1config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64)The usual comment for such changes: could you please clean this up and just use something like "depends on
HAVE_ARCH_AUDITSYSCALL"?
Do you agree to this change?
If so, I can create a patch, but have some concerns:
1) I can't verify it on other architectures than (arm &) arm64.
2) Some architectures (microblaze, mips, openrisc) are not listed here, but their ptrace.c have a call to audit_syscall_entry/exit(). (audit_syscall_entry/exit are null if !AUDITSYSCALL, though)
So I'm afraid that the change might break someone's assumption.
Thanks,
-Takahiro AKASHI
Catalin Marinas
maintainerRe: [PATCH v2 1/6] audit: Enable arm64 support
Quoted 29 lines · AKASHI Takahiro
[To audit maintainers]
Quoted 18 lines · Catalin Marinas
Quoted 17 lines · AKASHI Takahiro
include/uapi/linux/audit.h +2
-0@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)init/Kconfig +0
-0@@ -284,7 +284,7 @@ config AUDITQuoted 7 lines
init/Kconfig config AUDIT · line 287
Quoted 4 lines
init/Kconfig +1
-1config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64)The usual comment for such changes: could you please clean this up and just use something like "depends on
HAVE_ARCH_AUDITSYSCALL"?
Quoted 4 lines
Do you agree to this change?
If so, I can create a patch, but have some concerns:
1) I can't verify it on other architectures than (arm &) arm64.
You could try to build. It's really a trivial change, could get away with code inspection (and some automatic building when it gets to linux-next).
In init/Kconfig:
config HAVE_ARCH_AUDITSYSCALL
bool
and:
- depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT))
+ depends on HAVE_ARCH_AUDITSYSCALL
In the corresponding arch/*/Kconfig:
select HAVE_ARCH_AUDITSYSCALL
Quoted 1 line
2) Some architectures (microblaze, mips, openrisc) are not listed here, but
For those, you don't need to select HAVE_ARCH_AUDITSYSCALL.
Quoted 2 lines
their
ptrace.chave a call to audit_syscall_entry/exit(). (audit_syscall_entry/exit are null if !AUDITSYSCALL, though)
They are not NULL but empty inline functions, so they don't have any effect.
Quoted 1 line
So I'm afraid that the change might break someone's assumption.
I'm pretty sure it won't ;).
Signature · 1 line
Catalin
Re: [PATCH v2 1/6] audit: Enable arm64 support
In reply to AKASHI TakahiroQuoted 29 lines · AKASHI Takahiro
[To audit maintainers]
Quoted 18 lines · Catalin Marinas
Quoted 17 lines · AKASHI Takahiro
include/uapi/linux/audit.h +2
-0@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)init/Kconfig +0
-0@@ -284,7 +284,7 @@ config AUDITQuoted 7 lines
init/Kconfig config AUDIT · line 287
Quoted 4 lines
init/Kconfig +1
-1config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64)The usual comment for such changes: could you please clean this up and just use something like "depends on
HAVE_ARCH_AUDITSYSCALL"?
Quoted 7 lines
Do you agree to this change?
If so, I can create a patch, but have some concerns:
1) I can't verify it on other architectures than (arm &) arm64.
2) Some architectures (microblaze, mips, openrisc) are not listed here, but theirptrace.chave a call to audit_syscall_entry/exit(). (audit_syscall_entry/exit are null if !AUDITSYSCALL, though)
I can try: ppc s390 x86_64 ppc64 i686 s390x
Quoted 4 lines
So I'm afraid that the change might break someone's assumption.
Thanks,
-Takahiro AKASHI
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH v2 1/6] audit: Enable arm64 support
Quoted 32 lines · Richard Guy Briggs
Quoted 31 lines · AKASHI Takahiro
[To audit maintainers]
Quoted 18 lines · Catalin Marinas
Quoted 17 lines · AKASHI Takahiro
include/uapi/linux/audit.h +2
-0@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)init/Kconfig +0
-0@@ -284,7 +284,7 @@ config AUDITQuoted 7 lines
init/Kconfig config AUDIT · line 287
Quoted 4 lines
init/Kconfig +1
-1config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64)The usual comment for such changes: could you please clean this up and just use something like "depends on
HAVE_ARCH_AUDITSYSCALL"?Do you agree to this change?
Quoted 7 lines
Quoted 5 lines
If so, I can create a patch, but have some concerns:
1) I can't verify it on other architectures than (arm &) arm64.
2) Some architectures (microblaze, mips, openrisc) are not listed here, but theirptrace.chave a call to audit_syscall_entry/exit(). (audit_syscall_entry/exit are null if !AUDITSYSCALL, though)I can try: ppc s390
x86_64ppc64 i686 s390x
These arches above all pass compile and basic tests with the following patches applied:
audit: correct a type mismatch in audit_syscall_exit() pending (already upstream)
audit: Modify a set of system calls in audit class definitions (already upstream)
[PATCH v3] audit: Add generic compat syscall support
[PATCH v2] audit: Enable arm64 support
[PATCH v2] arm64: Add regs_return_value() in syscall.h
[PATCH v2] arm64: Add audit support
[PATCH v2] arm64: audit: Add 32-bit (compat) syscall support
[PATCH v2] arm64: audit: Add makefile rule to create unistd_32.h for compat syscalls [PATCH v2] arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 6 lines
Quoted 4 lines
So I'm afraid that the change might break someone's assumption.
Thanks,
-Takahiro AKASHI- RGB
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH v2 1/6] audit: Enable arm64 support
Richard,
Quoted 47 lines · Richard Guy Briggs
Quoted 32 lines · Richard Guy Briggs
Quoted 31 lines · AKASHI Takahiro
[To audit maintainers]
Quoted 18 lines · Catalin Marinas
Quoted 17 lines · AKASHI Takahiro
include/uapi/linux/audit.h +2
-0@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)init/Kconfig +0
-0@@ -284,7 +284,7 @@ config AUDITQuoted 7 lines
init/Kconfig config AUDIT · line 287
Quoted 4 lines
init/Kconfig +1
-1config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64)The usual comment for such changes: could you please clean this up and just use something like "depends on
HAVE_ARCH_AUDITSYSCALL"?Do you agree to this change?
Quoted 7 lines
Quoted 5 lines
If so, I can create a patch, but have some concerns:
1) I can't verify it on other architectures than (arm &) arm64.
2) Some architectures (microblaze, mips, openrisc) are not listed here, but theirptrace.chave a call to audit_syscall_entry/exit(). (audit_syscall_entry/exit are null if !AUDITSYSCALL, though)I can try: ppc s390
x86_64ppc64 i686 s390xThese arches above all pass compile and basic tests with the following patches applied:
audit: correct a type mismatch in
audit_syscall_exit()pending (already upstream)audit: Modify a set of system calls in audit class definitions (already upstream)
Quoted 8 lines
[PATCH v3] audit: Add generic compat syscall support
[PATCH v2] audit: Enable arm64 support
[PATCH v2] arm64: Addregs_return_value()insyscall.h
[PATCH v2] arm64: Add audit support
[PATCH v2] arm64: audit: Add 32-bit (compat) syscall support
[PATCH v2] arm64: audit: Add makefile rule to createunistd_32.hfor compat syscalls [PATCH v2] arm64: audit: Add audit hook in ptrace/syscall_trace
I think that you missed Catalin's suggestion.
Please use the patch I will post after this message and try it again, please?
Thanks,
-Takahiro AKASHI
Quoted 15 lines
Quoted 6 lines
Quoted 4 lines
So I'm afraid that the change might break someone's assumption.
Thanks,
-Takahiro AKASHI- RGB
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH v2 1/6] audit: Enable arm64 support
Quoted 1 line · AKASHI Takahiro
Richard,
Takahiro,
Quoted 50 lines · Richard Guy Briggs
Quoted 49 lines · Richard Guy Briggs
Quoted 32 lines · AKASHI Takahiro
Quoted 31 lines
[To audit maintainers]
Quoted 18 lines · Catalin Marinas
Quoted 17 lines · AKASHI Takahiro
include/uapi/linux/audit.h +2
-0@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)init/Kconfig +0
-0@@ -284,7 +284,7 @@ config AUDITQuoted 7 lines
init/Kconfig config AUDIT · line 287
Quoted 4 lines
init/Kconfig +1
-1config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64)The usual comment for such changes: could you please clean this up and just use something like "depends on
HAVE_ARCH_AUDITSYSCALL"?Do you agree to this change?
Quoted 7 lines
Quoted 5 lines
If so, I can create a patch, but have some concerns:
1) I can't verify it on other architectures than (arm &) arm64.
2) Some architectures (microblaze, mips, openrisc) are not listed here, but theirptrace.chave a call to audit_syscall_entry/exit(). (audit_syscall_entry/exit are null if !AUDITSYSCALL, though)I can try: ppc s390
x86_64ppc64 i686 s390xThese arches above all pass compile and basic tests with the following patches applied:
audit: correct a type mismatch in
audit_syscall_exit()pending (already upstream)audit: Modify a set of system calls in audit class definitions (already upstream)
[PATCH v3] audit: Add generic compat syscall support
Quoted 8 lines
Quoted 6 lines
[PATCH v2] audit: Enable arm64 support
[PATCH v2] arm64: Addregs_return_value()insyscall.h
[PATCH v2] arm64: Add audit support
[PATCH v2] arm64: audit: Add 32-bit (compat) syscall support
[PATCH v2] arm64: audit: Add makefile rule to createunistd_32.hfor compat syscalls [PATCH v2] arm64: audit: Add audit hook in ptrace/syscall_traceI think that you missed Catalin's suggestion.
I didn't miss his suggestions. I think they are a good way to go, but I wanted to make a test at referrable point in time to validate the work to that point and to avoid introducing errors by mis-interpreting ideas that were not yet fully-formed patches.
Quoted 1 line
Please use the patch I will post after this message and try it again, please?
I was certainly intending to do so.
Quoted 18 lines
Thanks,
-Takahiro AKASHIQuoted 15 lines
Quoted 6 lines
Quoted 4 lines
So I'm afraid that the change might break someone's assumption.
Thanks,
-Takahiro AKASHI- RGB
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH v2 1/6] audit: Enable arm64 support
Quoted 4 lines · Richard Guy Briggs
Quoted 1 line · AKASHI Takahiro
Richard,
Takahiro,
Takahiro,
Quoted 59 lines
Quoted 50 lines · Richard Guy Briggs
Quoted 49 lines · Richard Guy Briggs
Quoted 32 lines · AKASHI Takahiro
Quoted 31 lines
[To audit maintainers]
Quoted 18 lines · Catalin Marinas
Quoted 17 lines · AKASHI Takahiro
include/uapi/linux/audit.h +2
-0@@ -327,6 +327,8 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_AARCH64EB (EM_AARCH64|__AUDIT_ARCH_64BIT)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)init/Kconfig +0
-0@@ -284,7 +284,7 @@ config AUDITQuoted 7 lines
init/Kconfig config AUDIT · line 287
Quoted 4 lines
init/Kconfig +1
-1config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ARM64)The usual comment for such changes: could you please clean this up and just use something like "depends on
HAVE_ARCH_AUDITSYSCALL"?Do you agree to this change?
Quoted 7 lines
Quoted 5 lines
If so, I can create a patch, but have some concerns:
1) I can't verify it on other architectures than (arm &) arm64.
2) Some architectures (microblaze, mips, openrisc) are not listed here, but theirptrace.chave a call to audit_syscall_entry/exit(). (audit_syscall_entry/exit are null if !AUDITSYSCALL, though)I can try: ppc s390
x86_64ppc64 i686 s390xThese arches above all pass compile and basic tests with the following patches applied:
audit: correct a type mismatch in
audit_syscall_exit()pending (already upstream)audit: Modify a set of system calls in audit class definitions (already upstream)
[PATCH v3] audit: Add generic compat syscall support
Quoted 8 lines
Quoted 6 lines
[PATCH v2] audit: Enable arm64 support
[PATCH v2] arm64: Addregs_return_value()insyscall.h
[PATCH v2] arm64: Add audit support
[PATCH v2] arm64: audit: Add 32-bit (compat) syscall support
[PATCH v2] arm64: audit: Add makefile rule to createunistd_32.hfor compat syscalls [PATCH v2] arm64: audit: Add audit hook in ptrace/syscall_traceI think that you missed Catalin's suggestion.
Quoted 8 lines
I didn't miss his suggestions. I think they are a good way to go, but I wanted to make a test at referrable point in time to validate the work to that point and to avoid introducing errors by mis-interpreting ideas that were not yet fully-formed patches.
Quoted 1 line
Please use the patch I will post after this message and try it again, please?
I was certainly intending to do so.
I have tested the new sets from Catalin and you and everything passes ok.
Quoted 5 lines
Quoted 5 lines
Thanks,
-Takahiro AKASHIQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
So I'm afraid that the change might break someone's assumption.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Thanks,
-Takahiro AKASHI- RGB
- RGB
- RGB
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
PATCH 1/1 audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
In reply to Richard Guy BriggsCurrently AUDITSYSCALL has a long list of architecture depencency:
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT))
The purpose of this patch is to replace it with HAVE_ARCH_AUDITSYSCALL for simplicity.
--- arch/arm/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/sh/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/um/Kconfig.common | 1 + arch/x86/Kconfig | 1 + init/Kconfig | 5 ++++- 10 files changed, 13 insertions(+), 1 deletion(-)
arch/arm/Kconfig +1 -0
@@ -23,6 +23,7 @@ config ARM select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT)
arch/ia64/Kconfig +1 -0
@@ -43,6 +43,7 @@ config IA64 select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA select ARCH_USE_CMPXCHG_LOCKREF + select HAVE_ARCH_AUDITSYSCALL default y help The Itanium Processor Family is Intel's 64-bit successor to
arch/parisc/Kconfig +1 -0
@@ -28,6 +28,7 @@ config PARISC select CLONE_BACKWARDS select TTY # Needed for pdc_cons.c select HAVE_DEBUG_STACKOVERFLOW + select HAVE_ARCH_AUDITSYSCALL help The PA-RISC microprocessor is designed by Hewlett-Packard and used
arch/powerpc/Kconfig +1 -0
@@ -139,6 +139,7 @@ config PPC select OLD_SIGACTION if PPC32 select HAVE_DEBUG_STACKOVERFLOW select HAVE_IRQ_EXIT_ON_IRQ_STACK + select HAVE_ARCH_AUDITSYSCALL config GENERIC_CSUM def_bool CPU_LITTLE_ENDIAN
arch/s390/Kconfig +1 -0
@@ -103,6 +103,7 @@ config S390 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select HAVE_ALIGNED_STRUCT_PAGE if SLUB + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_TRACEHOOK
arch/sh/Kconfig +1 -0
@@ -42,6 +42,7 @@ config SUPERH select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND select OLD_SIGACTION + select HAVE_ARCH_AUDITSYSCALL help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast
arch/sparc/Kconfig +1 -0
@@ -76,6 +76,7 @@ config SPARC64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select HAVE_C_RECORDMCOUNT select NO_BOOTMEM + select HAVE_ARCH_AUDITSYSCALL config ARCH_DEFCONFIG string
arch/um/Kconfig.common +1 -0
@@ -1,6 +1,7 @@ config UML bool default y + select HAVE_ARCH_AUDITSYSCALL select HAVE_UID16 select GENERIC_IRQ_SHOW select GENERIC_CPU_DEVICES
arch/x86/Kconfig +1 -0
@@ -124,6 +124,7 @@ config X86 select RTC_LIB select HAVE_DEBUG_STACKOVERFLOW select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 + select HAVE_ARCH_AUDITSYSCALL config INSTRUCTION_DECODER def_bool y
init/Kconfig +4 -1
@@ -282,9 +282,12 @@ config AUDIT logging of avc messages output). Does not do system-call auditing without CONFIG_AUDITSYSCALL. +config HAVE_ARCH_AUDITSYSCALL + bool + config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT)) + depends on AUDIT && HAVE_ARCH_AUDITSYSCALL default y if SECURITY_SELINUX help Enable low-overhead system-call auditing infrastructure that
Signature · 1 line
1.7.9.5
v2 cover audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
Currently AUDITSYSCALL has a long list of architecture depencency:
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML ||
SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA)The purpose of this patch is to replace it with HAVE_ARCH_AUDITSYSCALL for simplicity.
Changes v1 -> v2:
* rebased to 3.14-rcX, and so added a change on ALPHA
AKASHI Takahiro (1):
audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
arch/alpha/Kconfig | 1 + arch/arm/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/sh/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/um/Kconfig.common | 1 + arch/x86/Kconfig | 1 + init/Kconfig | 5 ++++- 11 files changed, 14 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/1 audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
Currently AUDITSYSCALL has a long list of architecture depencency:
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA)
The purpose of this patch is to replace it with HAVE_ARCH_AUDITSYSCALL for simplicity.
--- arch/alpha/Kconfig | 1 + arch/arm/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/sh/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/um/Kconfig.common | 1 + arch/x86/Kconfig | 1 + init/Kconfig | 5 ++++- 11 files changed, 14 insertions(+), 1 deletion(-)
arch/alpha/Kconfig +1 -0
@@ -22,6 +22,7 @@ config ALPHA select GENERIC_SMP_IDLE_THREAD select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER + select HAVE_ARCH_AUDITSYSCALL select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA select ODD_RT_SIGACTION
arch/arm/Kconfig +1 -0
@@ -24,6 +24,7 @@ config ARM select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT)
arch/ia64/Kconfig +1 -0
@@ -44,6 +44,7 @@ config IA64 select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA select ARCH_USE_CMPXCHG_LOCKREF + select HAVE_ARCH_AUDITSYSCALL default y help The Itanium Processor Family is Intel's 64-bit successor to
arch/parisc/Kconfig +1 -0
@@ -28,6 +28,7 @@ config PARISC select CLONE_BACKWARDS select TTY # Needed for pdc_cons.c select HAVE_DEBUG_STACKOVERFLOW + select HAVE_ARCH_AUDITSYSCALL help The PA-RISC microprocessor is designed by Hewlett-Packard and used
arch/powerpc/Kconfig +1 -0
@@ -141,6 +141,7 @@ config PPC select HAVE_DEBUG_STACKOVERFLOW select HAVE_IRQ_EXIT_ON_IRQ_STACK select ARCH_USE_CMPXCHG_LOCKREF if PPC64 + select HAVE_ARCH_AUDITSYSCALL config GENERIC_CSUM def_bool CPU_LITTLE_ENDIAN
arch/s390/Kconfig +1 -0
@@ -103,6 +103,7 @@ config S390 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select HAVE_ALIGNED_STRUCT_PAGE if SLUB + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_TRACEHOOK
arch/sh/Kconfig +1 -0
@@ -42,6 +42,7 @@ config SUPERH select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND select OLD_SIGACTION + select HAVE_ARCH_AUDITSYSCALL help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcast
arch/sparc/Kconfig +1 -0
@@ -77,6 +77,7 @@ config SPARC64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select HAVE_C_RECORDMCOUNT select NO_BOOTMEM + select HAVE_ARCH_AUDITSYSCALL config ARCH_DEFCONFIG string
arch/um/Kconfig.common +1 -0
@@ -1,6 +1,7 @@ config UML bool default y + select HAVE_ARCH_AUDITSYSCALL select HAVE_UID16 select GENERIC_IRQ_SHOW select GENERIC_CPU_DEVICES
arch/x86/Kconfig +1 -0
@@ -127,6 +127,7 @@ config X86 select HAVE_DEBUG_STACKOVERFLOW select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 select HAVE_CC_STACKPROTECTOR + select HAVE_ARCH_AUDITSYSCALL config INSTRUCTION_DECODER def_bool y
init/Kconfig +4 -1
@@ -282,9 +282,12 @@ config AUDIT logging of avc messages output). Does not do system-call auditing without CONFIG_AUDITSYSCALL. +config HAVE_ARCH_AUDITSYSCALL + bool + config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA) + depends on AUDIT && HAVE_ARCH_AUDITSYSCALL default y if SECURITY_SELINUX help Enable low-overhead system-call auditing infrastructure that
Signature · 1 line
1.7.9.5
Re: [PATCH v2 1/1] audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
Quoted 5 lines · AKASHI Takahiro
Currently AUDITSYSCALL has a long list of architecture depencency:
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA)The purpose of this patch is to replace it with
HAVE_ARCH_AUDITSYSCALLfor simplicity.
Looks sensible to me:
Will
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2 1/1] audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
In reply to AKASHI TakahiroQuoted 7 lines · AKASHI Takahiro
Currently AUDITSYSCALL has a long list of architecture depencency:
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA)The purpose of this patch is to replace it with
HAVE_ARCH_AUDITSYSCALLfor simplicity.Signed-off-by AKASHI Takahiro <[email protected]>
Quoted 155 lines
--- arch/alpha/Kconfig | 1 + arch/arm/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/sh/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/um/Kconfig.common | 1 + arch/x86/Kconfig | 1 + init/Kconfig | 5 ++++- 11 files changed, 14 insertions(+), 1 deletion(-)arch/alpha/Kconfig +1
-0@@ -22,6 +22,7 @@ config ALPHA select GENERIC_SMP_IDLE_THREAD select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER + select HAVE_ARCH_AUDITSYSCALL select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA select ODD_RT_SIGACTIONarch/arm/Kconfig +1
-0@@ -24,6 +24,7 @@ config ARM select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT)arch/ia64/Kconfig +1
-0@@ -44,6 +44,7 @@ config IA64 select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA select ARCH_USE_CMPXCHG_LOCKREF + select HAVE_ARCH_AUDITSYSCALL default y help The Itanium Processor Family is Intel's 64-bit successor toarch/parisc/Kconfig +1
-0@@ -28,6 +28,7 @@ config PARISC select CLONE_BACKWARDS select TTY # Needed for pdc_cons.c select HAVE_DEBUG_STACKOVERFLOW + select HAVE_ARCH_AUDITSYSCALL help The PA-RISC microprocessor is designed by Hewlett-Packard and usedarch/powerpc/Kconfig +1
-0@@ -141,6 +141,7 @@ config PPC select HAVE_DEBUG_STACKOVERFLOW select HAVE_IRQ_EXIT_ON_IRQ_STACK select ARCH_USE_CMPXCHG_LOCKREF if PPC64 + select HAVE_ARCH_AUDITSYSCALL config GENERIC_CSUM def_bool CPU_LITTLE_ENDIANarch/s390/Kconfig +1
-0@@ -103,6 +103,7 @@ config S390 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select HAVE_ALIGNED_STRUCT_PAGE if SLUB + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_TRACEHOOKarch/sh/Kconfig +1
-0@@ -42,6 +42,7 @@ config SUPERH select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND select OLD_SIGACTION + select HAVE_ARCH_AUDITSYSCALL help The SuperH is a RISC processor targeted for use in embedded systems and consumer electronics; it was also used in the Sega Dreamcastarch/sparc/Kconfig +1
-0@@ -77,6 +77,7 @@ config SPARC64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select HAVE_C_RECORDMCOUNT select NO_BOOTMEM + select HAVE_ARCH_AUDITSYSCALL config ARCH_DEFCONFIG stringarch/um/Kconfig.common +1
-0@@ -1,6 +1,7 @@ config UML bool default y + select HAVE_ARCH_AUDITSYSCALL select HAVE_UID16 select GENERIC_IRQ_SHOW select GENERIC_CPU_DEVICESarch/x86/Kconfig +1
-0@@ -127,6 +127,7 @@ config X86 select HAVE_DEBUG_STACKOVERFLOW select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 select HAVE_CC_STACKPROTECTOR + select HAVE_ARCH_AUDITSYSCALL config INSTRUCTION_DECODER def_bool yinit/Kconfig +4
-1@@ -282,9 +282,12 @@ config AUDIT logging of avc messages output). Does not do system-call auditing without CONFIG_AUDITSYSCALL. +config HAVE_ARCH_AUDITSYSCALL + bool + config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA) + depends on AUDIT && HAVE_ARCH_AUDITSYSCALL default y if SECURITY_SELINUX help Enable low-overhead system-call auditing infrastructure thatSignature · 1 line
1.7.9.5
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH v2 1/1] audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
In reply to AKASHI TakahiroQuoted 26 lines · AKASHI Takahiro
Currently AUDITSYSCALL has a long list of architecture depencency:
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA)The purpose of this patch is to replace it with
HAVE_ARCH_AUDITSYSCALLfor simplicity.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/alpha/Kconfig | 1 + arch/arm/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/sh/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/um/Kconfig.common | 1 + arch/x86/Kconfig | 1 + init/Kconfig | 5 ++++- 11 files changed, 14 insertions(+), 1 deletion(-)arch/alpha/Kconfig +0
-0
arch/alpha/Kconfig config ALPHA · line 28
Quoted 7 lines
arch/alpha/Kconfig +1
-0@@ -22,6 +22,7 @@ config ALPHA select GENERIC_SMP_IDLE_THREAD select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER + select HAVE_ARCH_AUDITSYSCALL select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA select ODD_RT_SIGACTION
Thanks.
Re: [PATCH v2 1/1] audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
In reply to AKASHI TakahiroQuoted 13 lines · AKASHI Takahiro
Currently AUDITSYSCALL has a long list of architecture depencency:
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA)The purpose of this patch is to replace it with
HAVE_ARCH_AUDITSYSCALLfor simplicity.Signed-off-by AKASHI Takahiro <[email protected]>arch/powerpc/Kconfig +0
-0
arch/powerpc/Kconfig config PPC · line 147
Quoted 7 lines
arch/powerpc/Kconfig +1
-0@@ -141,6 +141,7 @@ config PPC select HAVE_DEBUG_STACKOVERFLOW select HAVE_IRQ_EXIT_ON_IRQ_STACK select ARCH_USE_CMPXCHG_LOCKREF if PPC64 + select HAVE_ARCH_AUDITSYSCALL config GENERIC_CSUM def_bool CPU_LITTLE_ENDIAN
Looks good for powerpc.
cheers
PATCH v2 2/6 arm64: Add regs_return_value() in syscall.h
In reply to AKASHI TakahiroThis macro is used mainly for audit to record system call's results, but may also be used in test_kprobes.c.
--- arch/arm64/include/asm/ptrace.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/include/asm/ptrace.h +5 -0
@@ -134,6 +134,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ ((regs)->sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
Signature · 1 line
1.7.9.5
PATCH v2 3/6 arm64: Add audit support
In reply to AKASHI TakahiroOn AArch64, audit can be enabled with CONFIG_AUDIT_GENERIC. Most of audit features are implemented in generic way. This patch adds a small piece of architecture dependent code. syscall_get_arch(), which is used in seccomp, should just return AUDIT_ARCH_*.
--- arch/arm64/include/asm/syscall.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/include/asm/syscall.h +12 -0
@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <linux/audit.h> #include <linux/err.h> +#include <linux/sched.h> static inline int syscall_get_nr(struct task_struct *task,
@@ -104,4 +106,14 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +static inline int syscall_get_arch (struct task_struct *task, +struct pt_regs *regs) +{ +#ifdef __AARCH64EB__ +return AUDIT_ARCH_AARCH64EB ; +#else +return AUDIT_ARCH_AARCH64 ; +#endif +} +#endif /* __ASM_SYSCALL_H */
Signature · 1 line
1.7.9.5
PATCH v2 4/6 arm64: audit: Add 32-bit (compat) syscall support
In reply to AKASHI TakahiroGeneric audit code also support compat system calls now. This patch adds a small piece of architecture dependent code.
--- arch/arm64/include/asm/audit.h | 20 ++++++++++++++++++++ arch/arm64/include/asm/syscall.h | 10 ++++++++++ 2 files changed, 30 insertions(+) create mode 100644 arch/arm64/include/asm/audit.h
arch/arm64/include/asm/audit.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* arch/arm64/include/asm/audit.h +* +* Copyright (C) 2013 Linaro Limited +* Author: AKASHI Takahiro <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __ASM_AUDIT_H +#define __ASM_AUDIT_H + +#include <linux/audit.h> + +#define audit_is_compat (arch) \ + ((arch == AUDIT_ARCH_ARM) || (arch == AUDIT_ARCH_ARMEB)) + +#endif /* __ASM_AUDIT_H */
arch/arm64/include/asm/syscall.h +10 -0
@@ -19,6 +19,7 @@#include <linux/audit.h> #include <linux/err.h> #include <linux/sched.h> +#include <asm/compat.h> static inline int syscall_get_nr(struct task_struct *task,
@@ -109,6 +110,15 @@ static inline void syscall_set_arguments(struct task_struct *task,static inline int syscall_get_arch (struct task_struct *task,struct pt_regs *regs) { +#ifdef CONFIG_COMPAT + if (is_compat_thread(task_thread_info(task))) +#ifdef __AARCH64EB__ +return AUDIT_ARCH_ARMEB ;/* only BE on BE */ +#else +return AUDIT_ARCH_ARM ; +#endif +#endif +#ifdef __AARCH64EB__return AUDIT_ARCH_AARCH64EB ;#else
Signature · 1 line
1.7.9.5
Re: [PATCH v2 4/6] arm64: audit: Add 32-bit (compat) syscall support
Hi Akashi,
Quoted 2 lines · AKASHI Takahiro
Generic audit code also support compat system calls now. This patch adds a small piece of architecture dependent code.
[...]
arch/arm64/include/asm/syscall.h static inline void syscall_set_arguments(struct task_struct *task, · line 114
Quoted 7 lines
static inline int syscall_get_nr(struct
task_struct*task,arch/arm64/include/asm/syscall.h +2
-0@@ -109,6 +110,15 @@ static inline void syscall_set_arguments(struct task_struct *task,static inline int syscall_get_arch (struct task_struct *task,struct pt_regs *regs) { +#ifdef CONFIG_COMPAT +if (is_compat_thread (task_thread_info (task)))
You can call is_compat_thread even when !CONFIG_COMPAT, so you don't need that #ifdef.
arch/arm64/include/asm/syscall.h static inline void syscall_set_arguments(struct task_struct *task, · line 116
Quoted 2 lines
arch/arm64/include/asm/syscall.h +2
-0+#ifdef __AARCH64EB__ +return AUDIT_ARCH_ARMEB ;/* only BE on BE */
Well, actually, we only support userspace to be the same endianness as the kernel, so you that comment is slightly misleading. You could probably avoid these repeated ifdefs by defining things like ARM64_AUDIT_ARCH and ARM64_COMPAT_AUDIT_ARCH once depending on endianness.
Will
Re: [PATCH v2 4/6] arm64: audit: Add 32-bit (compat) syscall support
Quoted 8 lines · Will Deacon
Hi Akashi,
Quoted 2 lines · AKASHI Takahiro
Generic audit code also support compat system calls now. This patch adds a small piece of architecture dependent code.
[...]
Quoted 10 lines
arch/arm64/include/asm/syscall.h static inline void syscall_set_arguments(struct task_struct *task, · line 114
Quoted 7 lines
static inline int syscall_get_nr(struct
task_struct*task,arch/arm64/include/asm/syscall.h +2
-0@@ -109,6 +110,15 @@ static inline void syscall_set_arguments(struct task_struct *task,static inline int syscall_get_arch (struct task_struct *task,struct pt_regs *regs) { +#ifdef CONFIG_COMPAT +if (is_compat_thread (task_thread_info (task)))You can call
is_compat_threadeven when !CONFIG_COMPAT, so you don't need that #ifdef.
Right. I will remove it.
Quoted 7 lines
arch/arm64/include/asm/syscall.h static inline void syscall_set_arguments(struct task_struct *task, · line 116
Quoted 2 lines
arch/arm64/include/asm/syscall.h +2
-0+#ifdef __AARCH64EB__ +return AUDIT_ARCH_ARMEB ;/* only BE on BE */ Well, actually, we only support userspace to be the same endianness as the kernel, so you that comment is slightly misleading. You could probably avoid these repeated ifdefs by defining things like
ARM64_AUDIT_ARCHandARM64_COMPAT_AUDIT_ARCHonce depending on endianness.
As in the discussions about "audit(userspace)", if we don't have to care about endianness, I will remove this #ifdef instead.
Thanks,
-Takahiro AKASHI
Quoted 2 lines
Will
PATCH v2 5/6 arm64: audit: Add makefile rule to create unistd_32.h for compat syscalls
In reply to AKASHI Takahirogeneric compat sycall audit (lib/compat_audit.c) requires unistd_32.h for __NR_xyx compat syscall numbers. This is a different file from unistd32.h on arm64 and so it must be generated from unistd32.h.
--- arch/arm64/Makefile | 4 ++++ arch/arm64/kernel/syscalls/Makefile | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 arch/arm64/kernel/syscalls/Makefile
arch/arm64/Makefile +4 -0
@@ -72,6 +72,10 @@ PHONY += vdso_install vdso_install: $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ +# Compat syscall header generation +archheaders: + $(Q)$(MAKE) $(build)=arch/arm64/kernel/syscalls $@ + # We use MRPROPER_FILES and CLEAN_FILES now archclean: $(Q)$(MAKE) $(clean)=$(boot)
arch/arm64/kernel/syscalls/Makefile new file +20 -0
@@ -0,0 +1,20 @@ +out := $(obj)/../../include/generated/asm + +# Create output directory if not already present +_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') + +syshdr-$(CONFIG_COMPAT) += unistd_32.h + +targets += $(syshdr-y) + +quiet_cmd_syshdr = SYSHDR $@ + cmd_syshdr = cat $< | sed -r \ + -e 's/compat_//' \ + -e 's/_wrapper//' \ + -e 's/^__SYSCALL\((.*),[ ]*sys_([^)].*)\).*/\#define __NR_\2 \1/p;d' \ + | grep -v __NR_ni_syscall > $@ + +archheaders: $(addprefix $(out)/,$(syshdr-y)) + +$(out)/unistd_32.h: $(src)/../../include/asm/unistd32.h + $(call if_changed,syshdr)
Signature · 1 line
1.7.9.5
Catalin Marinas
maintainerRe: [PATCH v2 5/6] arm64: audit: Add makefile rule to create unistd_32.h for compat syscalls
Quoted 16 lines · AKASHI Takahiro
generic compat sycall audit (
lib/compat_audit.c) requiresunistd_32.hfor__NR_xyxcompat syscall numbers. This is a different file fromunistd32.hon arm64 and so it must be generated fromunistd32.h.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/Makefile | 4 ++++ arch/arm64/kernel/syscalls/Makefile | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 arch/arm64/kernel/syscalls/Makefilearch/arm64/Makefile +0
-0
arch/arm64/Makefile PHONY += vdso_install · line 77
Quoted 6 lines
arch/arm64/Makefile +3
-0@@ -72,6 +72,10 @@ PHONY += vdso_install vdso_install: $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ +# Compat syscall header generation +archheaders: + $(Q)$(MAKE) $(build)=arch/arm64/kernel/syscalls $@
See my other post to the lib/compat_audit.c file. I think that's too complex for what you need.
Signature · 1 line
Catalin
Re: [PATCH v2 5/6] arm64: audit: Add makefile rule to create unistd_32.h for compat syscalls
Catalin,
Quoted 20 lines · Catalin Marinas
Quoted 19 lines · AKASHI Takahiro
generic compat sycall audit (
lib/compat_audit.c) requiresunistd_32.hfor__NR_xyxcompat syscall numbers. This is a different file fromunistd32.hon arm64 and so it must be generated fromunistd32.h.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/Makefile | 4 ++++ arch/arm64/kernel/syscalls/Makefile | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+)create mode 100644
arch/arm64/kernel/syscalls/Makefilearch/arm64/Makefile +0
-0@@ -72,6 +72,10 @@ PHONY += vdso_install vdso_install: $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
Quoted 6 lines
arch/arm64/Makefile PHONY += vdso_install · line 77
Quoted 3 lines
arch/arm64/Makefile +3
-0+# Compat syscall header generation +archheaders: + $(Q)$(MAKE) $(build)=arch/arm64/kernel/syscalls $@See my other post to the
lib/compat_audit.cfile. I think that's too complex for what you need.
Generation script is getting more complexed than I assumed at first because some of system call names are a bit inconsistent with native 32-bit system calls, for example, fchown16 vs. fchown, fchown vs. fchown32.
Now my tentative sed script looks like:
+quiet_cmd_syshdr = SYSHDR $@
+ cmd_syshdr = cat $< | sed -r \ + -e 's/compat_//' \ + -e 's/_wrapper//' \ + -e 's/(sys_[fl]?chown)(\))/\132\)/' \ + -e 's/(sys_[gs]et)(|e|fs|re|res)(uid\))/\1\2uid32\)/' \ + -e 's/(sys_[gs]et)(|e|fs|re|res)(gid\))/\1\2gid32\)/' \ + -e 's/(sys_[gs]etgroups)(\))/\132\)/' \ + -e 's/(sys_new)(.*)/sys_\2/' \ + -e 's/sys_mmap_pgoff/sys_mmap2/' \ + -e 's/(sys_[_a-z]*)16(.*)/\1\2/' \ + -e 's/^__SYSCALL\((.*),[ ]*sys_([^)].*)\).*/\#define __NR_\2 \1/p;d' \ + | grep -v __NR_ni_syscall > $@
So, yeah, I agree with you now.
-Takahiro AKASHI
PATCH v2 6/6 arm64: audit: Add audit hook in ptrace/syscall_trace
In reply to AKASHI TakahiroThis patch adds auditing functions on entry to or exit from every system call invocation.
--- arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 12 ++++++++++++ 3 files changed, 16 insertions(+)
arch/arm64/include/asm/thread_info.h +1 -0
@@ -101,6 +101,7 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
arch/arm64/kernel/entry.S +3 -0
@@ -631,6 +631,9 @@ el0_svc_naked: // compat entry point get_thread_info tsk ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? +#ifdef CONFIG_AUDITSYSCALL + tbnz x16, #TIF_SYSCALL_AUDIT, __sys_trace // auditing syscalls? +#endif adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
arch/arm64/kernel/ptrace.c +12 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1064,6 +1066,16 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; +#ifdef CONFIG_AUDITSYSCALL +if (dir) +audit_syscall_exit (regs); +else +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]); +#endif /* CONFIG_AUDITSYSCALL */ +if (!test_thread_flag (TIF_SYSCALL_TRACE ))return regs->syscallno;
Signature · 1 line
1.7.9.5
Catalin Marinas
maintainerRe: [PATCH v2 6/6] arm64: audit: Add audit hook in ptrace/syscall_trace
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1077
Quoted 13 lines · AKASHI Takahiro
arch/arm64/kernel/ptrace.c +9
-0@@ -1064,6 +1066,16 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; +#ifdef CONFIG_AUDITSYSCALL +if (dir) +audit_syscall_exit (regs); +else +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]); +#endif /* CONFIG_AUDITSYSCALL */
It should work without the #ifdef as audit_syscall_exit/entry are dummy static inline functions when !CONFIG_AUDITSYSCALL.
Signature · 1 line
Catalin
Quoted 46 lines · AKASHI Takahiro
This patchset adds system call audit support on arm64.
Both 32-bit (AUIDT_ARCH_ARM[EB]) and 64-bit tasks (AUDIT_ARCH_AARCH64[EB]) are supported, but presuming 32-LE on 64-LE or 32-BE on 64-BE.There are some prerequisites for this patch to work correctly:
* "generic compat system call audit support" patch
* "correct a type mismatch inaudit_syscall_exit()" patch (already accepted and queued in 3.14)
* "Modify a set of system calls in audit class" patch
* userspace audit tool (v2.3.2 + my patch for arm64)All those were already or will be soon posted separately. Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace# auditctl -a exit,always -S openat -F path=/etc/inittab # auditctl -a exit,always -F dir=/tmp -F perm=rw # auditctl -a task,always # autrace /bin/ls by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header,unistd_32.h, is automatically generated fromunistd32.h.
* Refer toregs->orig_x0instead ofregs->x0as the first argument of system call inaudit_syscall_entry()[6/6]
* Include "Addregs_return_value()insyscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".AKASHI Takahiro (6):
audit: Enable arm64 support
arm64: Addregs_return_value()insyscall.h
arm64: Add audit support
arm64: audit: Add 32-bit (compat) syscall support
arm64: audit: Add makefile rule to createunistd_32.hfor compat
syscalls
arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 16 lines
arch/arm64/Makefile | 4 ++++ arch/arm64/include/asm/audit.h | 20 ++++++++++++++++++++ arch/arm64/include/asm/ptrace.h | 5 +++++ arch/arm64/include/asm/syscall.h | 22 ++++++++++++++++++++++ arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 12 ++++++++++++ arch/arm64/kernel/syscalls/Makefile | 20 ++++++++++++++++++++ include/uapi/linux/audit.h | 2 ++ init/Kconfig | 2 +- 10 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/audit.h create mode 100644 arch/arm64/kernel/syscalls/MakefileSignature · 1 line
1.7.9.5
Set:
Quoted 1 line
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
v3 cover arm64: Add audit support
In reply to AKASHI TakahiroThis patchset adds system call audit support on arm64. Both 32-bit (AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically __AUDIT_ARCH_64BIT bit in AUDIT_ARCH_*).
There are some prerequisites for this patch to work correctly:
* "generic compat system call audit support" patch
* "correct a type mismatch in audit_syscall_exit()" patch (already accepted and queued in 3.14)
* "Modify a set of system calls in audit class" patch (already accepted and queued in 3.14)
* "__NR_* definitions for compat syscalls" patch from Catalin
* userspace audit tool (v2.3.2 + my patch for arm64)
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace
# auditctl -a exit,always -S openat -F path=/etc/inittab
# auditctl -a exit,always -F dir=/tmp -F perm=rw
# auditctl -a task,always
# autrace /bin/ls
by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.
Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header, unistd_32.h, is automatically generated from unistd32.h.
* Refer to regs->orig_x0 instead of regs->x0 as the first argument of system call in audit_syscall_entry() [6/6]
* Include "Add regs_return_value() in syscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".
Changes v2 -> v3:
* Remove asm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Remove kernel/syscalls/Makefile which was used to create unistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patch
AKASHI Takahiro (3):
arm64: Add regs_return_value() in syscall.h
arm64: Add audit support
arm64: audit: Add audit hook in ptrace/syscall_trace
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/ptrace.h | 5 +++++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 10 ++++++++++ include/uapi/linux/audit.h | 1 + 7 files changed, 36 insertions(+)
Signature · 1 line
1.7.9.5
PATCH v3 1/3 arm64: Add regs_return_value() in syscall.h
This macro, regs_return_value, is used mainly for audit to record system call's results, but may also be used in test_kprobes.c.
--- arch/arm64/include/asm/ptrace.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/include/asm/ptrace.h +5 -0
@@ -134,6 +134,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ ((regs)->sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
Signature · 1 line
1.7.9.5
Re: [PATCH v3 1/3] arm64: Add regs_return_value() in syscall.h
Quoted 4 lines · AKASHI Takahiro
This macro,
regs_return_value, is used mainly for audit to record system call's results, but may also be used intest_kprobes.c.Signed-off-by AKASHI Takahiro <[email protected]>
Will
PATCH v3 2/3 arm64: Add audit support
In reply to AKASHI TakahiroOn AArch64, audit is supported through generic lib/audit.c and compat_audit.c, and so this patch adds arch specific definitions required.
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -19,6 +19,7 @@ config ARM64 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_TRACEHOOK select HAVE_DEBUG_BUGVERBOSE select HAVE_DEBUG_KMEMLEAK
arch/arm64/include/asm/syscall.h +15 -0
@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <linux/audit.h> #include <linux/err.h> +#include <asm/compat.h> static inline int syscall_get_nr(struct task_struct *task,
@@ -104,4 +106,17 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 (struct task_struct *task, +struct pt_regs *regs) +{ +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */
include/uapi/linux/audit.h +1 -0
@@ -327,6 +327,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
Signature · 1 line
1.7.9.5
Quoted 9 lines · AKASHI Takahiro
On AArch64, audit is supported through generic
lib/audit.candcompat_audit.c, and so this patch adds arch specific definitions required.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)
Will
PATCH v3 3/3 arm64: audit: Add audit hook in ptrace/syscall_trace
In reply to AKASHI TakahiroThis patch adds auditing functions on entry to or exit from every system call invocation.
--- arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 10 ++++++++++ 3 files changed, 14 insertions(+)
arch/arm64/include/asm/thread_info.h +1 -0
@@ -101,6 +101,7 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
arch/arm64/kernel/entry.S +3 -0
@@ -630,6 +630,9 @@ el0_svc_naked: // compat entry point get_thread_info tsk ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? +#ifdef CONFIG_AUDITSYSCALL + tbnz x16, #TIF_SYSCALL_AUDIT, __sys_trace // auditing syscalls? +#endif adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
arch/arm64/kernel/ptrace.c +10 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1064,6 +1066,14 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; +if (dir) +audit_syscall_exit (regs); +else +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]); +if (!test_thread_flag (TIF_SYSCALL_TRACE ))return regs->syscallno;
Signature · 1 line
1.7.9.5
Re: [PATCH v3 3/3] arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 27 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 10 ++++++++++ 3 files changed, 14 insertions(+)arch/arm64/include/asm/thread_info.h +1
-0@@ -101,6 +101,7 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19arch/arm64/kernel/entry.S +0
-0
arch/arm64/kernel/entry.S el0_svc_naked: // compat entry point · line 635
Quoted 6 lines
arch/arm64/kernel/entry.S +3
-0@@ -630,6 +630,9 @@ el0_svc_naked: // compat entry point get_thread_info tsk ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? +#ifdef CONFIG_AUDITSYSCALL + tbnz x16, #TIF_SYSCALL_AUDIT, __sys_trace // auditing syscalls? +#endif
Could we avoid the back-to-back tbnz instructions with a single mask? It's not obvious that it will end up any better, but it would be good to know.
Quoted 25 lines
arch/arm64/kernel/entry.S +0
-0adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sysarch/arm64/kernel/ptrace.c +2
-0@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h> @@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h> @@ -1064,6 +1066,14 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1076
Quoted 10 lines
arch/arm64/kernel/ptrace.c +8
-0unsigned long saved_reg; +if (dir) +audit_syscall_exit (regs); +else +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]); +
Do we really want to perform the audit checks before the tracehook calls? Remember that the latter can rewrite all of the registers.
Will
Re: [PATCH v3 3/3] arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 29 lines · Will Deacon
Quoted 28 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/ptrace.c | 10 ++++++++++ 3 files changed, 14 insertions(+)arch/arm64/include/asm/thread_info.h +1
-0@@ -101,6 +101,7 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19arch/arm64/kernel/entry.S +0
-0@@ -630,6 +630,9 @@ el0_svc_naked: // compat entry point get_thread_info tsk
Quoted 8 lines
arch/arm64/kernel/entry.S el0_svc_naked: // compat entry point · line 635
Quoted 5 lines
arch/arm64/kernel/entry.S +3
-0ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? +#ifdef CONFIG_AUDITSYSCALL + tbnz x16, #TIF_SYSCALL_AUDIT, __sys_trace // auditing syscalls? +#endifCould we avoid the back-to-back tbnz instructions with a single mask? It's not obvious that it will end up any better, but it would be good to know.
When first implementing ftrace support, TIF_SYSCALL_TRACEPOINT is defined as 10 and 'tst' instruction doesn't allow the following code:
tst x16, #(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_TRACEPOINT)
That is why I've used "back-to-back" tbnz since then, but now that I'm going to submit ftrace, audit and later seccomp, I will replace it with:
#define TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE|TRACEPOINT|AUDIT|SECCOMP)
tst x16, #TIF_SYSCALL_WORK
b.ne __syscall_trace
Quoted 27 lines
Quoted 27 lines
arch/arm64/kernel/entry.S +0
-0adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sysarch/arm64/kernel/ptrace.c +2
-0@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h> @@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h> @@ -1064,6 +1066,14 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg;
Quoted 11 lines
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1076
Quoted 8 lines
arch/arm64/kernel/ptrace.c +8
-0+if (dir) +audit_syscall_exit (regs); +else +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]); +Do we really want to perform the audit checks before the tracehook calls? Remember that the latter can rewrite all of the registers.
OK. I will change the code to make calls in the following order:
On entry,
*secure_computing
*tracehook_report_syscall(ENTER)
*trace_sys_enter
*audit_syscall_entry
On exit,
*audit_syscall_exit
*trace_sys_exit
*tracehook_report_syscall(EXIT)
The order here is the exact same as on x86, but such change might decrease the readability in syscall_trace().
Thanks,
-Takahiro AKASHI
Quoted 2 lines
Will
PATCH 1/1 arm64: make a single hook to syscall_trace() for all syscall features
Currently syscall_trace() is called only for ptrace.
With additional TIF_xx flags introduced, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
Those features will be implemented later, but it's safe to include them now because they can not be turned on anyway.
--- arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- arch/arm64/kernel/ptrace.c | 11 +++++------ 3 files changed, 21 insertions(+), 8 deletions(-)
arch/arm64/include/asm/thread_info.h +13 -0
@@ -91,6 +91,9 @@ static inline struct thread_info *current_thread_info(void)/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace +* TIF_SYSCALL_AUDIT - syscall auditing +* TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_NOTIFY_RESUME - callback before returning to user
@@ -101,6 +104,9 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 +#define TIF_SYSCALL_TRACEPOINT 10 +#define TIF_SECCOMP 11#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
@@ -112,10 +118,17 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME) +#define _TIF_WORK_SYSCALL (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) +#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */
arch/arm64/kernel/entry.S +3 -2
@@ -631,8 +631,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_WORK_SYSCALL + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
arch/arm64/kernel/ptrace.c +5 -6
@@ -1062,9 +1062,6 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno; -if (is_compat_task ()) {/* AArch32 uses ip (r12) for scratch */ saved_reg = regs->regs[12 ];
@@ -1078,10 +1075,12 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) regs->regs[7 ] = dir; } -if (dir) +if (dir) {tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; + }else { +if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ; + }if (is_compat_task ()) regs->regs[12 ] = saved_reg;
Signature · 1 line
1.7.9.5
Re: [PATCH] arm64: make a single hook to syscall_trace() for all syscall features
Quoted 7 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags introduced, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
Those features will be implemented later, but it's safe to include them now because they can not be turned on anyway.Signed-off-by AKASHI Takahiro <[email protected]>
Quoted 101 lines
--- arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- arch/arm64/kernel/ptrace.c | 11 +++++------ 3 files changed, 21 insertions(+), 8 deletions(-)arch/arm64/include/asm/thread_info.h +13
-0@@ -91,6 +91,9 @@ static inline struct thread_info *current_thread_info(void)/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace +* TIF_SYSCALL_AUDIT - syscall auditing +* TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_NOTIFY_RESUME - callback before returning to user @@ -101,6 +104,9 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 +#define TIF_SYSCALL_TRACEPOINT 10 +#define TIF_SECCOMP 11#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19@@ -112,10 +118,17 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME) +#define _TIF_WORK_SYSCALL (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) +#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */ arch/arm64/kernel/entry.S +3
-2@@ -631,8 +631,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_WORK_SYSCALL + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sysarch/arm64/kernel/ptrace.c +5
-6@@ -1062,9 +1062,6 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno; -if (is_compat_task ()) {/* AArch32 uses ip (r12) for scratch */ saved_reg = regs->regs[12 ];@@ -1078,10 +1075,12 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) regs->regs[7 ] = dir; } -if (dir) +if (dir) {tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; + }else { +if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ; + }if (is_compat_task ()) regs->regs[12 ] = saved_reg;Signature · 6 lines
1.7.9.5 -- Linux-audit mailing list Linux-audit at redhat.com https://www.redhat.com/mailman/listinfo/linux-audit
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH] arm64: make a single hook to syscall_trace() for all syscall features
In reply to AKASHI TakahiroQuoted 17 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags introduced, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
Those features will be implemented later, but it's safe to include them now because they can not be turned on anyway.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- arch/arm64/kernel/ptrace.c | 11 +++++------ 3 files changed, 21 insertions(+), 8 deletions(-)arch/arm64/include/asm/thread_info.h +0
-0
[...]
arch/arm64/include/asm/thread_info.h static inline struct thread_info *current_thread_info(void) · line 131
Quoted 2 lines
arch/arm64/include/asm/thread_info.h +2
-0+#define _TIF_WORK_SYSCALL (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
This is called _TIF_SYSCALL_WORK on arch/arm/, any reason not to follow the naming convention here?
Quoted 23 lines
#endif /*
__KERNEL__*/
#endif /*__ASM_THREAD_INFO_H*/arch/arm64/kernel/entry.S +3
-2@@ -631,8 +631,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_WORK_SYSCALL + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sysarch/arm64/kernel/ptrace.c +0
-0
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1066
Quoted 5 lines
arch/arm64/kernel/ptrace.c +0
-2@@ -1062,9 +1062,6 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno;
This doesn't look right for things like audit (where we don't want to report the syscall if only _TIF_SYSCALL_AUDIT is set, for example).
Quoted 6 lines
arch/arm64/kernel/ptrace.c +0
-0if (is_compat_task ()) {/* AArch32 uses ip (r12) for scratch */ saved_reg = regs->regs[12 ];@@ -1078,10 +1075,12 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) regs->regs[7 ] = dir; }
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1083
Quoted 10 lines
arch/arm64/kernel/ptrace.c +5
-3-if (dir) +if (dir) {tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; + }else { +if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ; + }
This hunk doesn't do anything.
Will
Re: [PATCH] arm64: make a single hook to syscall_trace() for all syscall features
Hi,
Quoted 21 lines · Will Deacon
Quoted 17 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags introduced, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
Those features will be implemented later, but it's safe to include them now because they can not be turned on anyway.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- arch/arm64/kernel/ptrace.c | 11 +++++------ 3 files changed, 21 insertions(+), 8 deletions(-)arch/arm64/include/asm/thread_info.h +0
-0[...]
Quoted 5 lines
arch/arm64/include/asm/thread_info.h static inline struct thread_info *current_thread_info(void) · line 131
Quoted 2 lines
arch/arm64/include/asm/thread_info.h +2
-0+#define _TIF_WORK_SYSCALL (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)This is called
_TIF_SYSCALL_WORKonarch/arm/, any reason not to follow the naming convention here?
This is called _TIF_WORK_SYSCALL on arch/x86 :-)
That is the only reason, and so I don't have any objection to following arm if you prefer it.
Quoted 26 lines
Quoted 26 lines
#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */arch/arm64/kernel/entry.S +3
-2@@ -631,8 +631,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_WORK_SYSCALL + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sysarch/arm64/kernel/ptrace.c +0
-0@@ -1062,9 +1062,6 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg;
Quoted 5 lines
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1066
Quoted 2 lines
arch/arm64/kernel/ptrace.c +0
-2-if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno;This doesn't look right for things like audit (where we don't want to report the syscall if only
_TIF_SYSCALL_AUDITis set, for example).
Yeah, it is my screwup.
I will add the guards against TIF_SYSCALL_TRACE (for ptrace), TIF_SYSCALL_TRACEPOINT (for ftrace) and TIF_SYSCALL_AUDIT (for audit).
secure_computing() is protected in itself.
Quoted 7 lines
Quoted 7 lines
arch/arm64/kernel/ptrace.c +0
-0if (is_compat_task ()) {/* AArch32 uses ip (r12) for scratch */ saved_reg = regs->regs[12 ];@@ -1078,10 +1075,12 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) regs->regs[7 ] = dir; }
Quoted 11 lines
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1083
Quoted 9 lines
arch/arm64/kernel/ptrace.c +5
-3-if (dir) +if (dir) {tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; + }else { +if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ; + }This hunk doesn't do anything.
Well, this is just a change for future patches, but I will remove it anyway due to the guards mentioned above.
-Takahiro AKASHI
Quoted 2 lines
Will
v2 cover arm64: make a single hook to syscall_trace() for all syscall features
In reply to AKASHI TakahiroThis patch makes it easy to add syscall related hooks, including ftrace, audit and seccomp, in syscall_trace() later.
Those features will be implemented in separate patchsets, but it's safe to check for all TIF_* now because they can not be turned on anyway.
Changes v1 -> v2:
* added a guard against TIF_SYSCALL_TRACE at tracehook_report_syscall_*()
* renamed _TIF_WORK_SYSCALL to _TIF_SYSCALL_WORK
AKASHI Takahiro (1):
arm64: make a single hook to syscall_trace() for all syscall features
arch/arm64/include/asm/thread_info.h | 13 ++++++++++ arch/arm64/kernel/entry.S | 5 ++-- arch/arm64/kernel/ptrace.c | 45 +++++++++++++++++----------------- 3 files changed, 38 insertions(+), 25 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/1 arm64: make a single hook to syscall_trace() for all syscall features
Currently syscall_trace() is called only for ptrace.
With additional TIF_xx flags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
--- arch/arm64/include/asm/thread_info.h | 13 ++++++++++ arch/arm64/kernel/entry.S | 5 ++-- arch/arm64/kernel/ptrace.c | 45 +++++++++++++++++----------------- 3 files changed, 38 insertions(+), 25 deletions(-)
arch/arm64/include/asm/thread_info.h +13 -0
@@ -91,6 +91,9 @@ static inline struct thread_info *current_thread_info(void)/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace +* TIF_SYSCALL_AUDIT - syscall auditing +* TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_NOTIFY_RESUME - callback before returning to user
@@ -101,6 +104,9 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 +#define TIF_SYSCALL_TRACEPOINT 10 +#define TIF_SECCOMP 11#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
@@ -112,10 +118,17 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) +#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */
arch/arm64/kernel/entry.S +3 -2
@@ -630,8 +630,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_SYSCALL_WORK + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
arch/arm64/kernel/ptrace.c +22 -23
53 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v2 1/1] arm64: make a single hook to syscall_trace() for all syscall features
Quoted 60 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/include/asm/thread_info.h | 13 ++++++++++ arch/arm64/kernel/entry.S | 5 ++-- arch/arm64/kernel/ptrace.c | 45 +++++++++++++++++----------------- 3 files changed, 38 insertions(+), 25 deletions(-)arch/arm64/include/asm/thread_info.h +13
-0@@ -91,6 +91,9 @@ static inline struct thread_info *current_thread_info(void)/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace +* TIF_SYSCALL_AUDIT - syscall auditing +* TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_NOTIFY_RESUME - callback before returning to user @@ -101,6 +104,9 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 +#define TIF_SYSCALL_TRACEPOINT 10 +#define TIF_SECCOMP 11#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19@@ -112,10 +118,17 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) +#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */ arch/arm64/kernel/entry.S +0
-0@@ -630,8 +630,9 @@ el0_svc_naked: // compat entry point enable_irq
arch/arm64/kernel/entry.S el0_svc_naked: // compat entry point · line 638
Quoted 10 lines
arch/arm64/kernel/entry.S +3
-2get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_SYSCALL_WORK + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
All looks fine up to here.
Quoted 45 lines
arch/arm64/kernel/ptrace.c +17
-19@@ -1062,31 +1062,30 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno; - -if (is_compat_task ()) { -/* AArch32 uses ip (r12) for scratch */ - saved_reg = regs->regs[12 ]; - regs->regs[12 ] = dir; - }else { -/* -* Save X7. X7 is used to denote syscall entry/exit: -* X7 = 0 -> entry, = 1 -> exit -*/ - saved_reg = regs->regs[7 ]; - regs->regs[7 ] = dir; - } +if (test_thread_flag (TIF_SYSCALL_TRACE )) { +if (is_compat_task ()) { +/* AArch32 uses ip (r12) for scratch */ + saved_reg = regs->regs[12 ]; + regs->regs[12 ] = dir; + }else { +/* +* Save X7. X7 is used to denote syscall entry/exit: +* X7 = 0 -> entry, = 1 -> exit +*/ + saved_reg = regs->regs[7 ]; + regs->regs[7 ] = dir; + } -if (dir) -tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; +if (dir) +tracehook_report_syscall_exit (regs,0 ); +else if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ;
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1088
Quoted 10 lines
arch/arm64/kernel/ptrace.c +5
-4-if (is_compat_task ()) - regs->regs[12 ] = saved_reg; -else - regs->regs[7 ] = saved_reg; +if (is_compat_task ()) + regs->regs[12 ] = saved_reg; +else + regs->regs[7 ] = saved_reg; + }
Aren't these changes (to ptrace.c) just a giant NOP?
Will
Re: [PATCH v2 1/1] arm64: make a single hook to syscall_trace() for all syscall features
Quoted 12 lines · Will Deacon
Quoted 11 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/include/asm/thread_info.h | 13 ++++++++++ arch/arm64/kernel/entry.S | 5 ++-- arch/arm64/kernel/ptrace.c | 45 +++++++++++++++++----------------- 3 files changed, 38 insertions(+), 25 deletions(-)
[...]
Quoted 46 lines
Quoted 46 lines
arch/arm64/kernel/ptrace.c +17
-19@@ -1062,31 +1062,30 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno; - -if (is_compat_task ()) { -/* AArch32 uses ip (r12) for scratch */ - saved_reg = regs->regs[12 ]; - regs->regs[12 ] = dir; - }else { -/* -* Save X7. X7 is used to denote syscall entry/exit: -* X7 = 0 -> entry, = 1 -> exit -*/ - saved_reg = regs->regs[7 ]; - regs->regs[7 ] = dir; - } +if (test_thread_flag (TIF_SYSCALL_TRACE )) { +if (is_compat_task ()) { +/* AArch32 uses ip (r12) for scratch */ + saved_reg = regs->regs[12 ]; + regs->regs[12 ] = dir; + }else { +/* +* Save X7. X7 is used to denote syscall entry/exit: +* X7 = 0 -> entry, = 1 -> exit +*/ + saved_reg = regs->regs[7 ]; + regs->regs[7 ] = dir; + } -if (dir) -tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; +if (dir) +tracehook_report_syscall_exit (regs,0 ); +else if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ;
Quoted 11 lines
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1088
Quoted 9 lines
arch/arm64/kernel/ptrace.c +5
-4-if (is_compat_task ()) - regs->regs[12 ] = saved_reg; -else - regs->regs[7 ] = saved_reg; +if (is_compat_task ()) + regs->regs[12 ] = saved_reg; +else + regs->regs[7 ] = saved_reg; + }Aren't these changes (to
ptrace.c) just a giant NOP?
Umm, the purpose of this big "if" is to run the code only if TIF_SYSCALL_TRACE is set, and to make it easy to add additional hooks, audit and ftrace, around tracehook_report_*() later on.
-Takahiro AKASHI
Quoted 2 lines
Will
Re: [PATCH v2 1/1] arm64: make a single hook to syscall_trace() for all syscall features
Quoted 74 lines · AKASHI Takahiro
Quoted 12 lines · Will Deacon
Quoted 11 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/include/asm/thread_info.h | 13 ++++++++++ arch/arm64/kernel/entry.S | 5 ++-- arch/arm64/kernel/ptrace.c | 45 +++++++++++++++++----------------- 3 files changed, 38 insertions(+), 25 deletions(-)[...]
Quoted 46 lines
Quoted 46 lines
arch/arm64/kernel/ptrace.c +17
-19@@ -1062,31 +1062,30 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno; - -if (is_compat_task ()) { -/* AArch32 uses ip (r12) for scratch */ - saved_reg = regs->regs[12 ]; - regs->regs[12 ] = dir; - }else { -/* -* Save X7. X7 is used to denote syscall entry/exit: -* X7 = 0 -> entry, = 1 -> exit -*/ - saved_reg = regs->regs[7 ]; - regs->regs[7 ] = dir; - } +if (test_thread_flag (TIF_SYSCALL_TRACE )) { +if (is_compat_task ()) { +/* AArch32 uses ip (r12) for scratch */ + saved_reg = regs->regs[12 ]; + regs->regs[12 ] = dir; + }else { +/* +* Save X7. X7 is used to denote syscall entry/exit: +* X7 = 0 -> entry, = 1 -> exit +*/ + saved_reg = regs->regs[7 ]; + regs->regs[7 ] = dir; + } -if (dir) -tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; +if (dir) +tracehook_report_syscall_exit (regs,0 ); +else if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ;Quoted 11 lines
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1088
Quoted 9 lines
arch/arm64/kernel/ptrace.c +5
-4-if (is_compat_task ()) - regs->regs[12 ] = saved_reg; -else - regs->regs[7 ] = saved_reg; +if (is_compat_task ()) + regs->regs[12 ] = saved_reg; +else + regs->regs[7 ] = saved_reg; + }Aren't these changes (to
ptrace.c) just a giant NOP?
Quoted 3 lines
Umm, the purpose of this big "if" is to run the code only if
TIF_SYSCALL_TRACEis set, and to make it easy to add additional hooks, audit and ftrace, around tracehook_report_*() later on.
The existing code already checks TIF_SYSCALL_TRACE. I'd rather you added this new code when it's actually nedded (e.g. when adding audit on top).
Will
Re: [PATCH v2 1/1] arm64: make a single hook to syscall_trace() for all syscall features
Quoted 75 lines · Will Deacon
Quoted 74 lines · AKASHI Takahiro
Quoted 12 lines · Will Deacon
Quoted 11 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/include/asm/thread_info.h | 13 ++++++++++ arch/arm64/kernel/entry.S | 5 ++-- arch/arm64/kernel/ptrace.c | 45 +++++++++++++++++----------------- 3 files changed, 38 insertions(+), 25 deletions(-)[...]
Quoted 57 lines
Quoted 45 lines
arch/arm64/kernel/ptrace.c +17
-19@@ -1062,31 +1062,30 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno; - -if (is_compat_task ()) { -/* AArch32 uses ip (r12) for scratch */ - saved_reg = regs->regs[12 ]; - regs->regs[12 ] = dir; - }else { -/* -* Save X7. X7 is used to denote syscall entry/exit: -* X7 = 0 -> entry, = 1 -> exit -*/ - saved_reg = regs->regs[7 ]; - regs->regs[7 ] = dir; - } +if (test_thread_flag (TIF_SYSCALL_TRACE )) { +if (is_compat_task ()) { +/* AArch32 uses ip (r12) for scratch */ + saved_reg = regs->regs[12 ]; + regs->regs[12 ] = dir; + }else { +/* +* Save X7. X7 is used to denote syscall entry/exit: +* X7 = 0 -> entry, = 1 -> exit +*/ + saved_reg = regs->regs[7 ]; + regs->regs[7 ] = dir; + } -if (dir) -tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; +if (dir) +tracehook_report_syscall_exit (regs,0 ); +else if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ;arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1088
Quoted 10 lines
arch/arm64/kernel/ptrace.c +5
-4-if (is_compat_task ()) - regs->regs[12 ] = saved_reg; -else - regs->regs[7 ] = saved_reg; +if (is_compat_task ()) + regs->regs[12 ] = saved_reg; +else + regs->regs[7 ] = saved_reg; + }Aren't these changes (to
ptrace.c) just a giant NOP?
Quoted 6 lines
Quoted 3 lines
Umm, the purpose of this big "if" is to run the code only if
TIF_SYSCALL_TRACEis set, and to make it easy to add additional hooks, audit and ftrace, around tracehook_report_*() later on.The existing code already checks
TIF_SYSCALL_TRACE. I'd rather you added this new code when it's actually nedded (e.g. when adding audit on top).
* This patch is required only if you really merge my audit and/or ftrace patch.
* Putting these changes in audit patch would impose an extra (unnecessary) dependency on ftrace patch.
* Putting them both in audit and ftrace patch would cause a conflict when applying both patches.
Even so, since I don't bother you on this minor issue, I will follow your comment and make changes on:
* arm64: make a single hook to syscall_trace() for all syscall features
* arm64: Add audit support
* arm64: Add ftrace support
-Takahiro AKASHI
Quoted 2 lines
Will
v3 cover arm64: prerequisites for audit and ftrace
In reply to AKASHI TakahiroThis patchset contains some patches commonly used by audit and ftrace.
Patch [1/2] defines system call related TIF_* flags to add syscall_trace() hooks, including ftrace, audit and seccomp, later.
Those features will be implemented in separate patchsets, but it's safe to check for all TIF_* now because they can not be turned on anyway.
Patch [2/2] adds a function which returns a return value of system call.
Changes v1 -> v2:
* added a guard against TIF_SYSCALL_TRACE at tracehook_report_syscall_*()
* renamed _TIF_WORK_SYSCALL to _TIF_SYSCALL_WORK
Changes v2 -> v3:
* reverted a change in syscall_trace() in v1 [1/2]
* added "arm64: Add regs_return_value() in syscall.h" patch which was previously included in audit patch [2/2]
AKASHI Takahiro (2):
arm64: make a single hook to syscall_trace() for all syscall features
arm64: Add regs_return_value() in syscall.h
arch/arm64/include/asm/ptrace.h | 5 +++++ arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- 3 files changed, 21 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v3 1/2 arm64: make a single hook to syscall_trace() for all syscall features
Currently syscall_trace() is called only for ptrace.
With additional TIF_xx flags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
--- arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-)
arch/arm64/include/asm/thread_info.h +13 -0
@@ -91,6 +91,9 @@ static inline struct thread_info *current_thread_info(void)/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace +* TIF_SYSCALL_AUDIT - syscall auditing +* TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_NOTIFY_RESUME - callback before returning to user
@@ -101,6 +104,9 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 +#define TIF_SYSCALL_TRACEPOINT 10 +#define TIF_SECCOMP 11#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
@@ -112,10 +118,17 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) +#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */
arch/arm64/kernel/entry.S +3 -2
@@ -630,8 +630,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_SYSCALL_WORK + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
Signature · 1 line
1.7.9.5
Re: [PATCH v3 1/2] arm64: make a single hook to syscall_trace() for all syscall features
Quoted 6 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.Signed-off-by AKASHI Takahiro <[email protected]>
Will
PATCH v3 2/2 arm64: Add regs_return_value() in syscall.h
In reply to AKASHI TakahiroThis macro, regs_return_value, is used mainly for audit to record system call's results, but may also be used in test_kprobes.c.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/include/asm/ptrace.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/include/asm/ptrace.h +5 -0
@@ -134,6 +134,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ ((regs)->sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
Signature · 1 line
1.7.9.5
v4 cover arm64: prerequisites for audit and ftrace
In reply to AKASHI TakahiroThis patchset contains some patches commonly applied for audit and ftrace.
Patch [1/3] defines syscall trace related TIF_* flags in order to add hooks, including ftrace, audit and seccomp, later on. Those features will be implemented in separate patchsets, but it's safe to check for all TIF_* now because they can not be turned on anyway.
Patch [2/3] doesn't change a behavior but make it easy and manageable to confirm we invoke those hooks in correct order by splitting syscall_trace().
Patch [3/3] adds a commonly used function, which returns a return value of system call.
Changes v3 -> v4:
* added "arm64: split syscall_trace() into separate functions for enter/ exit", which is just a preparation for adding syscall trace hooks later.
Changes v2 -> v3:
* reverted a change in syscall_trace() in v1 [1/2]
* added "arm64: Add regs_return_value() in syscall.h" patch which was previously included in audit patch [2/2]
Changes v1 -> v2:
* added a guard against TIF_SYSCALL_TRACE at tracehook_report_syscall_*()
* renamed _TIF_WORK_SYSCALL to _TIF_SYSCALL_WORK
AKASHI Takahiro (3):
arm64: make a single hook to syscall_trace() for all syscall features
arm64: split syscall_trace() into separate functions for enter/exit
arm64: Add regs_return_value() in syscall.h
arch/arm64/include/asm/ptrace.h | 5 ++++ arch/arm64/include/asm/thread_info.h | 13 +++++++++ arch/arm64/kernel/entry.S | 15 +++++------ arch/arm64/kernel/ptrace.c | 48 ++++++++++++++++++++++++++-------- 4 files changed, 62 insertions(+), 19 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v4 1/3 arm64: make a single hook to syscall_trace() for all syscall features
Currently syscall_trace() is called only for ptrace.
With additional TIF_xx flags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
--- arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-)
arch/arm64/include/asm/thread_info.h +13 -0
@@ -91,6 +91,9 @@ static inline struct thread_info *current_thread_info(void)/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace +* TIF_SYSCALL_AUDIT - syscall auditing +* TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_NOTIFY_RESUME - callback before returning to user
@@ -101,6 +104,9 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 +#define TIF_SYSCALL_TRACEPOINT 10 +#define TIF_SECCOMP 11#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
@@ -112,10 +118,17 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) +#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */
arch/arm64/kernel/entry.S +3 -2
@@ -631,8 +631,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_SYSCALL_WORK + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
Signature · 1 line
1.7.9.5
Re: [PATCH v4 1/3] arm64: make a single hook to syscall_trace() for all syscall features
Quoted 7 lines · AKASHI Takahiro
Currently
syscall_trace()is called only for ptrace.
With additionalTIF_xxflags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.Signed-off-by AKASHI Takahiro <[email protected]>---
Will
PATCH v4 2/3 arm64: split syscall_trace() into separate functions for enter/exit
In reply to AKASHI TakahiroAs done in arm, this change makes it easy to confirm we invoke syscall related hooks, including syscall tracepoint, audit and seccomp which would be implemented later, in correct order. That is, undoing operations in the opposite order on exit that they were done on entry.
--- arch/arm64/kernel/entry.S | 10 ++++----- arch/arm64/kernel/ptrace.c | 48 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 17 deletions(-)
arch/arm64/kernel/entry.S +4 -6
@@ -649,9 +649,8 @@ ENDPROC(el0_svc) * switches, and waiting for our parent to respond. */ __sys_trace: - mov x1, sp - mov w0, #0 // trace entry - bl syscall_trace + mov x0, sp + bl syscall_trace_enter adr lr, __sys_trace_return // return address uxtw scno, w0 // syscall number (possibly new) mov x1, sp // pointer to regs
@@ -666,9 +665,8 @@ __sys_trace: __sys_trace_return: str x0, [sp] // save returned x0 - mov x1, sp - mov w0, #1 // trace exit - bl syscall_trace + mov x0, sp + bl syscall_trace_exit b ret_to_user /*
arch/arm64/kernel/ptrace.c +37 -11
69 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v4 2/3] arm64: split syscall_trace() into separate functions for enter/exit
Quoted 10 lines · AKASHI Takahiro
As done in arm, this change makes it easy to confirm we invoke syscall related hooks, including syscall tracepoint, audit and seccomp which would be implemented later, in correct order. That is, undoing operations in the opposite order on exit that they were done on entry.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/kernel/entry.S | 10 ++++----- arch/arm64/kernel/ptrace.c | 48 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 17 deletions(-)
[...]
Quoted 11 lines
arch/arm64/kernel/ptrace.c +1
-1@@ -1058,29 +1058,27 @@ long arch_ptrace(struct task_struct *child, long request,return ptrace_request (child, request, addr, data); } -asmlinkage int syscall_trace(int dir, struct pt_regs *regs) +asmlinkage int syscall_trace_enter(struct pt_regs *regs) {
arch/arm64/kernel/ptrace.c long arch_ptrace(struct task_struct *child, long request, · line 1072
Quoted 10 lines
arch/arm64/kernel/ptrace.c +5
-0unsigned long saved_reg;if (!test_thread_flag (TIF_SYSCALL_TRACE ))return regs->syscallno; +/* +* A scrach register (ip(r12) on AArch32, x7 on AArch64) is +* used to denote syscall entry/exit: +* 0 -> entry +*/
You could add an enum, like we have on ARM (ptrace_syscall_dir) for the two directions.
arch/arm64/kernel/ptrace.c long arch_ptrace(struct task_struct *child, long request, · line 1078
Quoted 13 lines
arch/arm64/kernel/ptrace.c +2
-7if (is_compat_task ()) { -/* AArch32 uses ip (r12) for scratch */ saved_reg = regs->regs[12 ]; - regs->regs[12 ] = dir; + regs->regs[12 ] =0 ; }else { -/* -* Save X7. X7 is used to denote syscall entry/exit: -* X7 = 0 -> entry, = 1 -> exit -*/ saved_reg = regs->regs[7 ]; - regs->regs[7 ] = dir; + regs->regs[7 ] =0 ;
This code could also be refactored so we calculated the register number once, then avoid the if (is_compact_task()) check all over the place.
Similarly on the exit path.
Will
Re: [PATCH v4 2/3] arm64: split syscall_trace() into separate functions for enter/exit
Quoted 56 lines · Will Deacon
Quoted 10 lines · AKASHI Takahiro
As done in arm, this change makes it easy to confirm we invoke syscall related hooks, including syscall tracepoint, audit and seccomp which would be implemented later, in correct order. That is, undoing operations in the opposite order on exit that they were done on entry.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/kernel/entry.S | 10 ++++----- arch/arm64/kernel/ptrace.c | 48 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 17 deletions(-)[...]
Quoted 11 lines
arch/arm64/kernel/ptrace.c +1
-1@@ -1058,29 +1058,27 @@ long arch_ptrace(struct task_struct *child, long request,return ptrace_request (child, request, addr, data); } -asmlinkage int syscall_trace(int dir, struct pt_regs *regs) +asmlinkage int syscall_trace_enter(struct pt_regs *regs) {arch/arm64/kernel/ptrace.c long arch_ptrace(struct task_struct *child, long request, · line 1072
Quoted 10 lines
arch/arm64/kernel/ptrace.c +5
-0unsigned long saved_reg;if (!test_thread_flag (TIF_SYSCALL_TRACE ))return regs->syscallno; +/* +* A scrach register (ip(r12) on AArch32, x7 on AArch64) is +* used to denote syscall entry/exit: +* 0 -> entry +*/ You could add an enum, like we have on ARM (
ptrace_syscall_dir) for the two directions.arch/arm64/kernel/ptrace.c long arch_ptrace(struct task_struct *child, long request, · line 1078
Quoted 13 lines
arch/arm64/kernel/ptrace.c +2
-7if (is_compat_task ()) { -/* AArch32 uses ip (r12) for scratch */ saved_reg = regs->regs[12 ]; - regs->regs[12 ] = dir; + regs->regs[12 ] =0 ; }else { -/* -* Save X7. X7 is used to denote syscall entry/exit: -* X7 = 0 -> entry, = 1 -> exit -*/ saved_reg = regs->regs[7 ]; - regs->regs[7 ] = dir; + regs->regs[7 ] =0 ;This code could also be refactored so we calculated the register number once, then avoid the if (
is_compact_task()) check all over the place.
Quoted 1 line
Similarly on the exit path.
OK, I will implement tracehook_report_syscall() as in arm.
-Takahiro AKASHI
Quoted 2 lines
Will
PATCH v4 3/3 arm64: Add regs_return_value() in syscall.h
In reply to AKASHI TakahiroThis macro, regs_return_value, is used mainly for audit to record system call's results, but may also be used in test_kprobes.c.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/include/asm/ptrace.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/include/asm/ptrace.h +5 -0
@@ -134,6 +134,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ ((regs)->sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
Signature · 1 line
1.7.9.5
v5 cover arm64: prerequisites for audit and ftrace
In reply to AKASHI TakahiroThis patchset contains some patches commonly applied for audit and ftrace.
Patch [1/4] defines syscall trace related TIF_* flags in order to add hooks, including ftrace, audit and seccomp, later on. Those features will be implemented in separate patchsets, but it's safe to check for all TIF_* now because they can not be turned on anyway.
Patch [2/4] doesn't change a behavior but make it easy and manageable to confirm we invoke those hooks in correct order by splitting syscall_trace().
Patch [3/4] adds a commonly used function, which returns a return value of system call.
Patch [4/4] removes is_compat_task from asm/compat.h to avoid conflicted definitions.
Changes v4 -> v5:
* added the following patch from my seccomp patch since it is required for audit and ftrace in case of !COMPAT, too. [4/4]
"arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h"
Changes v3 -> v4:
* added "arm64: split syscall_trace() into separate functions for enter/ exit", which is just a preparation for adding syscall trace hooks later.
Changes v2 -> v3:
* reverted a change in syscall_trace() in v1 [1/2]
* added "arm64: Add regs_return_value() in syscall.h" patch which was previously included in audit patch [2/2]
Changes v1 -> v2:
* added a guard against TIF_SYSCALL_TRACE at tracehook_report_syscall_*()
* renamed _TIF_WORK_SYSCALL to _TIF_SYSCALL_WORK
AKASHI Takahiro (4):
arm64: make a single hook to syscall_trace() for all syscall features
arm64: split syscall_trace() into separate functions for enter/exit
arm64: Add regs_return_value() in syscall.h
arm64: is_compat_task is defined both in asm/compat.h and
linux/compat.h
arch/arm64/include/asm/compat.h | 5 ---- arch/arm64/include/asm/ptrace.h | 5 ++++ arch/arm64/include/asm/thread_info.h | 13 +++++++++ arch/arm64/kernel/entry.S | 15 +++++------ arch/arm64/kernel/hw_breakpoint.c | 2 +- arch/arm64/kernel/process.c | 1 + arch/arm64/kernel/ptrace.c | 51 +++++++++++++++++++++--------------- arch/arm64/kernel/signal.c | 2 +- 8 files changed, 58 insertions(+), 36 deletions(-)
Signature · 1 line
1.8.3.2
PATCH v5 1/4 arm64: make a single hook to syscall_trace() for all syscall features
Currently syscall_trace() is called only for ptrace.
With additional TIF_xx flags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
--- arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-)
arch/arm64/include/asm/thread_info.h +13 -0
@@ -91,6 +91,9 @@ static inline struct thread_info *current_thread_info(void)/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace +* TIF_SYSCALL_AUDIT - syscall auditing +* TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_NOTIFY_RESUME - callback before returning to user
@@ -101,6 +104,9 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 +#define TIF_SYSCALL_TRACEPOINT 10 +#define TIF_SECCOMP 11#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
@@ -112,10 +118,17 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) +#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */
arch/arm64/kernel/entry.S +3 -2
@@ -631,8 +631,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_SYSCALL_WORK + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
Signature · 1 line
1.8.3.2
PATCH v5 2/4 arm64: split syscall_trace() into separate functions for enter/exit
In reply to AKASHI TakahiroAs done in arm, this change makes it easy to confirm we invoke syscall related hooks, including syscall tracepoint, audit and seccomp which would be implemented later, in correct order. That is, undoing operations in the opposite order on exit that they were done on entry.
--- arch/arm64/kernel/entry.S | 10 ++++------ arch/arm64/kernel/ptrace.c | 50 +++++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 27 deletions(-)
arch/arm64/kernel/entry.S +4 -6
@@ -649,9 +649,8 @@ ENDPROC(el0_svc) * switches, and waiting for our parent to respond. */ __sys_trace: - mov x1, sp - mov w0, #0 // trace entry - bl syscall_trace + mov x0, sp + bl syscall_trace_enter adr lr, __sys_trace_return // return address uxtw scno, w0 // syscall number (possibly new) mov x1, sp // pointer to regs
@@ -666,9 +665,8 @@ __sys_trace: __sys_trace_return: str x0, [sp] // save returned x0 - mov x1, sp - mov w0, #1 // trace exit - bl syscall_trace + mov x0, sp + bl syscall_trace_exit b ret_to_user /*
arch/arm64/kernel/ptrace.c +29 -21
64 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH v5 2/4] arm64: split syscall_trace() into separate functions for enter/exit
Quoted 6 lines · AKASHI Takahiro
As done in arm, this change makes it easy to confirm we invoke syscall related hooks, including syscall tracepoint, audit and seccomp which would be implemented later, in correct order. That is, undoing operations in the opposite order on exit that they were done on entry.
Signed-off-by AKASHI Takahiro <[email protected]>
Minor variable mis-spelling of "scratch" noted below, but other than that:
Quoted 41 lines
--- arch/arm64/kernel/entry.S | 10 ++++------ arch/arm64/kernel/ptrace.c | 50 +++++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 27 deletions(-)arch/arm64/kernel/entry.S +4
-6@@ -649,9 +649,8 @@ ENDPROC(el0_svc) * switches, and waiting for our parent to respond. */ __sys_trace: - mov x1, sp - mov w0, #0 // trace entry - bl syscall_trace + mov x0, sp + bl syscall_trace_enter adr lr, __sys_trace_return // return address uxtw scno, w0 // syscall number (possibly new) mov x1, sp // pointer to regs@@ -666,9 +665,8 @@ __sys_trace: __sys_trace_return: str x0, [sp] // save returned x0 - mov x1, sp - mov w0, #1 // trace exit - bl syscall_trace + mov x0, sp + bl syscall_trace_exit b ret_to_user /*arch/arm64/kernel/ptrace.c +0
-0@@ -1058,35 +1058,43 @@ long arch_ptrace(struct task_struct *child, long request,return ptrace_request (child, request, addr, data); }
arch/arm64/kernel/ptrace.c long arch_ptrace(struct task_struct *child, long request, · line 1069
Quoted 10 lines
arch/arm64/kernel/ptrace.c +8
-1-asmlinkage int syscall_trace(int dir, struct pt_regs *regs) +enum ptrace_syscall_dir { +PTRACE_SYSCALL_ENTER =0 , +PTRACE_SYSCALL_EXIT , +}; + +static void tracehook_report_syscall (struct pt_regs *regs, +enum ptrace_syscall_dir dir) { +int scrach;
"scratch"
Quoted 53 lines
arch/arm64/kernel/ptrace.c +21
-20unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno; - -if (is_compat_task ()) { -/* AArch32 uses ip (r12) for scratch */ - saved_reg = regs->regs[12 ]; - regs->regs[12 ] = dir; - }else { -/* -* Save X7. X7 is used to denote syscall entry/exit: -* X7 = 0 -> entry, = 1 -> exit -*/ - saved_reg = regs->regs[7 ]; - regs->regs[7 ] = dir; - } +/* +* A scrach register (ip(r12) on AArch32, x7 on AArch64) is +* used to denote syscall entry/exit: +*/ + scrach = (is_compat_task () ?12 :7 ); + saved_reg = regs->regs[scrach]; + regs->regs[scrach] = dir; -if (dir) +if (dir ==PTRACE_SYSCALL_EXIT )tracehook_report_syscall_exit (regs,0 );else if (tracehook_report_syscall_entry (regs)) regs->syscallno = ~0UL ; -if (is_compat_task ()) - regs->regs[12 ] = saved_reg; -else - regs->regs[7 ] = saved_reg; + regs->regs[scrach] = saved_reg; +} + +asmlinkage int syscall_trace_enter(struct pt_regs *regs) +{ +if (test_thread_flag (TIF_SYSCALL_TRACE )) +tracehook_report_syscall (regs,PTRACE_SYSCALL_ENTER );return regs->syscallno; } + +asmlinkage void syscall_trace_exit(struct pt_regs *regs) +{ +if (test_thread_flag (TIF_SYSCALL_TRACE )) +tracehook_report_syscall (regs,PTRACE_SYSCALL_EXIT ); +}Signature · 1 line
1.8.3.2
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH v5 2/4] arm64: split syscall_trace() into separate functions for enter/exit
In reply to AKASHI TakahiroHi Akashi,
Quoted 6 lines · AKASHI Takahiro
As done in arm, this change makes it easy to confirm we invoke syscall related hooks, including syscall tracepoint, audit and seccomp which would be implemented later, in correct order. That is, undoing operations in the opposite order on exit that they were done on entry.
Signed-off-by AKASHI Takahiro <[email protected]>
[...]
arch/arm64/kernel/ptrace.c long arch_ptrace(struct task_struct *child, long request, · line 1069
Quoted 4 lines
arch/arm64/kernel/ptrace.c +3
-0+static void tracehook_report_syscall (struct pt_regs *regs, +enum ptrace_syscall_dir dir) { +int scrach;
s/scrach/scratch/
Although, I'd rather have a variable with a more meaningful name. How about regno?
With that,
Cheers,
Will
Re: [PATCH v5 2/4] arm64: split syscall_trace() into separate functions for enter/exit
Quoted 10 lines · Will Deacon
Hi Akashi,
Quoted 6 lines · AKASHI Takahiro
As done in arm, this change makes it easy to confirm we invoke syscall related hooks, including syscall tracepoint, audit and seccomp which would be implemented later, in correct order. That is, undoing operations in the opposite order on exit that they were done on entry.
Signed-off-by AKASHI Takahiro <[email protected]>
Quoted 8 lines
[...]
arch/arm64/kernel/ptrace.c long arch_ptrace(struct task_struct *child, long request, · line 1069
Quoted 4 lines
arch/arm64/kernel/ptrace.c +3
-0+static void tracehook_report_syscall (struct pt_regs *regs, +enum ptrace_syscall_dir dir) { +int scrach;s/scrach/scratch/
I will fix it.
Quoted 2 lines
Although, I'd rather have a variable with a more meaningful name. How about regno?
OK, I will use regno in the next revision, which I will submit soon.
Quoted 3 lines
With that,
Acked-by Will Deacon <[email protected]>
Thank you so much,
-Takahiro AKASHI
Quoted 4 lines
Cheers,
Will
PATCH v5 3/4 arm64: Add regs_return_value() in syscall.h
In reply to AKASHI TakahiroThis macro, regs_return_value, is used mainly for audit to record system call's results, but may also be used in test_kprobes.c.
--- arch/arm64/include/asm/ptrace.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/include/asm/ptrace.h +5 -0
@@ -134,6 +134,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ ((regs)->sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
Signature · 1 line
1.8.3.2
PATCH v5 4/4 arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h
In reply to AKASHI TakahiroSome kernel files may include both linux/compat.h and asm/compat.h directly or indirectly. Since both header files contain is_compat_task() under !CONFIG_COMPAT, compiling them with !CONFIG_COMPAT will eventually fail. Such files include kernel/auditsc.c, kernel/seccomp.c and init/do_mountfs.c (do_mountfs.c may read asm/compat.h via asm/ftrace.h once ftrace is implemented).
So this patch proactively
1) removes is_compat_task() under !CONFIG_COMPAT from asm/compat.h
2) replaces asm/compat.h to linux/compat.h in kernel/*.c, but asm/compat.h is still necessary in ptrace.c and process.c because they use is_compat_thread().
--- arch/arm64/include/asm/compat.h | 5 ----- arch/arm64/kernel/hw_breakpoint.c | 2 +- arch/arm64/kernel/process.c | 1 + arch/arm64/kernel/ptrace.c | 1 + arch/arm64/kernel/signal.c | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-)
arch/arm64/include/asm/compat.h +0 -5
@@ -305,11 +305,6 @@ static inline int is_compat_thread(struct thread_info *thread)#else /* !CONFIG_COMPAT */ -static inline int is_compat_task (void ) -{ -return 0 ; -} -static inline int is_compat_thread (struct thread_info *thread) {return 0 ;
arch/arm64/kernel/hw_breakpoint.c +1 -1
@@ -20,6 +20,7 @@#define pr_fmt (fmt) "hw-breakpoint: " fmt +#include <linux/compat.h> #include <linux/cpu_pm.h> #include <linux/errno.h> #include <linux/hw_breakpoint.h>
@@ -27,7 +28,6 @@#include <linux/ptrace.h> #include <linux/smp.h> -#include <asm/compat.h> #include <asm/current.h> #include <asm/debug-monitors.h> #include <asm/hw_breakpoint.h>
arch/arm64/kernel/process.c +1 -0
@@ -20,6 +20,7 @@#include <stdarg.h> +#include <linux/compat.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/kernel.h>
arch/arm64/kernel/ptrace.c +1 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/compat.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
arch/arm64/kernel/signal.c +1 -1
@@ -17,6 +17,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/compat.h> #include <linux/errno.h> #include <linux/signal.h> #include <linux/personality.h>
@@ -25,7 +26,6 @@#include <linux/tracehook.h> #include <linux/ratelimit.h> -#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/elf.h> #include <asm/cacheflush.h>
Signature · 1 line
1.8.3.2
Re: [PATCH v5 4/4] arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h
Quoted 7 lines · AKASHI Takahiro
Some kernel files may include both
linux/compat.handasm/compat.hdirectly or indirectly. Since both header files containis_compat_task()under !CONFIG_COMPAT, compiling them with !CONFIG_COMPAT will eventually fail. Such files includekernel/auditsc.c,kernel/seccomp.candinit/do_mountfs.c(do_mountfs.cmay readasm/compat.hviaasm/ftrace.honce ftrace is implemented).
Quoted 7 lines
So this patch proactively
1) removesis_compat_task()under !CONFIG_COMPAT fromasm/compat.h
2) replacesasm/compat.htolinux/compat.hinkernel/*.c, butasm/compat.his still necessary inptrace.candprocess.cbecause they useis_compat_thread().Signed-off-by AKASHI Takahiro <[email protected]>
Quoted 91 lines
--- arch/arm64/include/asm/compat.h | 5 ----- arch/arm64/kernel/hw_breakpoint.c | 2 +- arch/arm64/kernel/process.c | 1 + arch/arm64/kernel/ptrace.c | 1 + arch/arm64/kernel/signal.c | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-)arch/arm64/include/asm/compat.h +0
-5@@ -305,11 +305,6 @@ static inline int is_compat_thread(struct thread_info *thread)#else /* !CONFIG_COMPAT */ -static inline int is_compat_task (void ) -{ -return 0 ; -} -static inline int is_compat_thread (struct thread_info *thread) {return 0 ;arch/arm64/kernel/hw_breakpoint.c +1
-1@@ -20,6 +20,7 @@#define pr_fmt (fmt) "hw-breakpoint: " fmt +#include <linux/compat.h> #include <linux/cpu_pm.h> #include <linux/errno.h> #include <linux/hw_breakpoint.h> @@ -27,7 +28,6 @@#include <linux/ptrace.h> #include <linux/smp.h> -#include <asm/compat.h> #include <asm/current.h> #include <asm/debug-monitors.h> #include <asm/hw_breakpoint.h> arch/arm64/kernel/process.c +1
-0@@ -20,6 +20,7 @@#include <stdarg.h> +#include <linux/compat.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/kernel.h> arch/arm64/kernel/ptrace.c +1
-0@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/compat.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h> arch/arm64/kernel/signal.c +1
-1@@ -17,6 +17,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/compat.h> #include <linux/errno.h> #include <linux/signal.h> #include <linux/personality.h> @@ -25,7 +26,6 @@#include <linux/tracehook.h> #include <linux/ratelimit.h> -#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/elf.h> #include <asm/cacheflush.h> Signature · 1 line
1.8.3.2
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH v5 4/4] arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h
In reply to AKASHI TakahiroQuoted 7 lines · AKASHI Takahiro
Some kernel files may include both
linux/compat.handasm/compat.hdirectly or indirectly. Since both header files containis_compat_task()under !CONFIG_COMPAT, compiling them with !CONFIG_COMPAT will eventually fail. Such files includekernel/auditsc.c,kernel/seccomp.candinit/do_mountfs.c(do_mountfs.cmay readasm/compat.hviaasm/ftrace.honce ftrace is implemented).
Quoted 7 lines
So this patch proactively
1) removesis_compat_task()under !CONFIG_COMPAT fromasm/compat.h
2) replacesasm/compat.htolinux/compat.hinkernel/*.c, butasm/compat.his still necessary inptrace.candprocess.cbecause they useis_compat_thread().Signed-off-by AKASHI Takahiro <[email protected]>
Will
v6 cover arm64: prerequisites for audit and ftrace
In reply to AKASHI Takahiro(This patchset was already acked by the maintainer along with a minor typo fix. See below.)
This patchset contains some patches commonly applied for audit and ftrace.
Patch [1/4] defines syscall trace related TIF_* flags in order to add hooks, including ftrace, audit and seccomp, later on. Those features will be implemented in separate patchsets, but it's safe to check for all TIF_* now because they can not be turned on anyway.
Patch [2/4] doesn't change a behavior but make it easy and manageable to confirm we invoke those hooks in correct order by splitting syscall_trace().
Patch [3/4] adds a commonly used function, which returns a return value of system call.
Patch [4/4] removes is_compat_task from asm/compat.h to avoid conflicted definitions.
Changes v5 -> v6:
* renamed a temporary variable's name to more meaningful one [2/4]
Changes v4 -> v5:
* added the following patch from my seccomp patch since it is required for audit and ftrace in case of !COMPAT, too. [4/4]
"arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h"
Changes v3 -> v4:
* added "arm64: split syscall_trace() into separate functions for enter/ exit", which is just a preparation for adding syscall trace hooks later.
Changes v2 -> v3:
* reverted a change in syscall_trace() in v1 [1/2]
* added "arm64: Add regs_return_value() in syscall.h" patch which was previously included in audit patch [2/2]
Changes v1 -> v2:
* added a guard against TIF_SYSCALL_TRACE at tracehook_report_syscall_*()
* renamed _TIF_WORK_SYSCALL to _TIF_SYSCALL_WORK
AKASHI Takahiro (4):
arm64: make a single hook to syscall_trace() for all syscall features
arm64: split syscall_trace() into separate functions for enter/exit
arm64: Add regs_return_value() in syscall.h
arm64: is_compat_task is defined both in asm/compat.h and
linux/compat.h
arch/arm64/include/asm/compat.h | 5 ---- arch/arm64/include/asm/ptrace.h | 5 ++++ arch/arm64/include/asm/thread_info.h | 13 +++++++++ arch/arm64/kernel/entry.S | 15 +++++----- arch/arm64/kernel/hw_breakpoint.c | 2 +- arch/arm64/kernel/process.c | 1 + arch/arm64/kernel/ptrace.c | 51 ++++++++++++++++++++-------------- arch/arm64/kernel/signal.c | 2 +- 8 files changed, 58 insertions(+), 36 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v6 1/4 arm64: make a single hook to syscall_trace() for all syscall features
Currently syscall_trace() is called only for ptrace.
With additional TIF_xx flags defined, it is now called in all the cases of audit, ftrace and seccomp in addition to ptrace.
--- arch/arm64/include/asm/thread_info.h | 13 +++++++++++++ arch/arm64/kernel/entry.S | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-)
arch/arm64/include/asm/thread_info.h +13 -0
@@ -91,6 +91,9 @@ static inline struct thread_info *current_thread_info(void)/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace +* TIF_SYSCALL_AUDIT - syscall auditing +* TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_NOTIFY_RESUME - callback before returning to user
@@ -101,6 +104,9 @@ static inline struct thread_info *current_thread_info(void)#define TIF_NEED_RESCHED 1#define TIF_NOTIFY_RESUME 2/* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_AUDIT 9 +#define TIF_SYSCALL_TRACEPOINT 10 +#define TIF_SECCOMP 11#define TIF_POLLING_NRFLAG 16#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_FREEZE 19
@@ -112,10 +118,17 @@ static inline struct thread_info *current_thread_info(void)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME) +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP) +#endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */
arch/arm64/kernel/entry.S +3 -2
@@ -631,8 +631,9 @@ el0_svc_naked: // compat entry point enable_irq get_thread_info tsk - ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing - tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks + tst x16, #_TIF_SYSCALL_WORK + b.ne __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys
Signature · 1 line
1.7.9.5
PATCH v6 2/4 arm64: split syscall_trace() into separate functions for enter/exit
In reply to AKASHI TakahiroAs done in arm, this change makes it easy to confirm we invoke syscall related hooks, including syscall tracepoint, audit and seccomp which would be implemented later, in correct order. That is, undoing operations in the opposite order on exit that they were done on entry.
--- arch/arm64/kernel/entry.S | 10 ++++----- arch/arm64/kernel/ptrace.c | 50 +++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 27 deletions(-)
arch/arm64/kernel/entry.S +4 -6
@@ -649,9 +649,8 @@ ENDPROC(el0_svc) * switches, and waiting for our parent to respond. */ __sys_trace: - mov x1, sp - mov w0, #0 // trace entry - bl syscall_trace + mov x0, sp + bl syscall_trace_enter adr lr, __sys_trace_return // return address uxtw scno, w0 // syscall number (possibly new) mov x1, sp // pointer to regs
@@ -666,9 +665,8 @@ __sys_trace: __sys_trace_return: str x0, [sp] // save returned x0 - mov x1, sp - mov w0, #1 // trace exit - bl syscall_trace + mov x0, sp + bl syscall_trace_exit b ret_to_user /*
arch/arm64/kernel/ptrace.c +29 -21
64 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v6 3/4 arm64: Add regs_return_value() in syscall.h
In reply to AKASHI TakahiroThis macro, regs_return_value, is used mainly for audit to record system call's results, but may also be used in test_kprobes.c.
--- arch/arm64/include/asm/ptrace.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/include/asm/ptrace.h +5 -0
@@ -135,6 +135,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ (!compat_user_mode(regs)) ? ((regs)->sp) : ((regs)->compat_sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
Signature · 1 line
1.7.9.5
PATCH v6 4/4 arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h
In reply to AKASHI TakahiroSome kernel files may include both linux/compat.h and asm/compat.h directly or indirectly. Since both header files contain is_compat_task() under !CONFIG_COMPAT, compiling them with !CONFIG_COMPAT will eventually fail. Such files include kernel/auditsc.c, kernel/seccomp.c and init/do_mountfs.c (do_mountfs.c may read asm/compat.h via asm/ftrace.h once ftrace is implemented).
So this patch proactively
1) removes is_compat_task() under !CONFIG_COMPAT from asm/compat.h
2) replaces asm/compat.h to linux/compat.h in kernel/*.c, but asm/compat.h is still necessary in ptrace.c and process.c because they use is_compat_thread().
--- arch/arm64/include/asm/compat.h | 5 ----- arch/arm64/kernel/hw_breakpoint.c | 2 +- arch/arm64/kernel/process.c | 1 + arch/arm64/kernel/ptrace.c | 1 + arch/arm64/kernel/signal.c | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-)
arch/arm64/include/asm/compat.h +0 -5
@@ -305,11 +305,6 @@ static inline int is_compat_thread(struct thread_info *thread)#else /* !CONFIG_COMPAT */ -static inline int is_compat_task (void ) -{ -return 0 ; -} -static inline int is_compat_thread (struct thread_info *thread) {return 0 ;
arch/arm64/kernel/hw_breakpoint.c +1 -1
@@ -20,6 +20,7 @@#define pr_fmt (fmt) "hw-breakpoint: " fmt +#include <linux/compat.h> #include <linux/cpu_pm.h> #include <linux/errno.h> #include <linux/hw_breakpoint.h>
@@ -27,7 +28,6 @@#include <linux/ptrace.h> #include <linux/smp.h> -#include <asm/compat.h> #include <asm/current.h> #include <asm/debug-monitors.h> #include <asm/hw_breakpoint.h>
arch/arm64/kernel/process.c +1 -0
@@ -20,6 +20,7 @@#include <stdarg.h> +#include <linux/compat.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/kernel.h>
arch/arm64/kernel/ptrace.c +1 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/compat.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
arch/arm64/kernel/signal.c +1 -1
@@ -17,6 +17,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/compat.h> #include <linux/errno.h> #include <linux/signal.h> #include <linux/personality.h>
@@ -25,7 +26,6 @@#include <linux/tracehook.h> #include <linux/ratelimit.h> -#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/elf.h> #include <asm/cacheflush.h>
Signature · 1 line
1.7.9.5
Catalin Marinas
maintainerRe: [PATCH v6 0/4] arm64: prerequisites for audit and ftrace
In reply to AKASHI TakahiroQuoted 6 lines · AKASHI Takahiro
AKASHI Takahiro (4):
arm64: make a single hook tosyscall_trace()for all syscall features
arm64: splitsyscall_trace()into separate functions for enter/exit
arm64: Addregs_return_value()insyscall.h
arm64:is_compat_taskis defined both inasm/compat.hand
linux/compat.h
Patches picked by Will and applied to the arm64 for-next/core branch (should appear in -next at some point).
Thanks.
Signature · 1 line
Catalin
v4 cover arm64: Add audit support
In reply to AKASHI TakahiroThis patchset adds system call audit support on arm64. Both 32-bit (AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically __AUDIT_ARCH_64BIT bit in AUDIT_ARCH_*).
There are some prerequisites for this patch to work correctly:
* "generic compat system call audit support" patch
* "correct a type mismatch in audit_syscall_exit()" patch (already accepted and queued in 3.14)
* "Modify a set of system calls in audit class" patch (already accepted and queued in 3.14)
* "__NR_* definitions for compat syscalls" patch from Catalin
* "make a single hook to syscall_trace() for all syscall features" patch
* userspace audit tool (v2.3.2 + my patch for arm64)
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace
# auditctl -a exit,always -S openat -F path=/etc/inittab
# auditctl -a exit,always -F dir=/tmp -F perm=rw
# auditctl -a task,always
# autrace /bin/ls
by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.
Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header, unistd_32.h, is automatically generated from unistd32.h.
* Refer to regs->orig_x0 instead of regs->x0 as the first argument of system call in audit_syscall_entry() [6/6]
* Include "Add regs_return_value() in syscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".
Changes v2 -> v3:
* Remove asm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Remove kernel/syscalls/Makefile which was used to create unistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patch
Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook to syscall_trace() for all syscall features"
AKASHI Takahiro (3):
arm64: Add regs_return_value() in syscall.h
arm64: Add audit support
arm64: audit: Add audit hook in ptrace/syscall_trace
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/ptrace.h | 5 +++++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/kernel/ptrace.c | 7 +++++++ include/uapi/linux/audit.h | 1 + 5 files changed, 29 insertions(+)
Signature · 1 line
1.7.9.5
PATCH v4 1/3 arm64: Add regs_return_value() in syscall.h
This macro, regs_return_value, is used mainly for audit to record system call's results, but may also be used in test_kprobes.c.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/include/asm/ptrace.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/include/asm/ptrace.h +5 -0
@@ -134,6 +134,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ ((regs)->sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
Signature · 1 line
1.7.9.5
PATCH v4 2/3 arm64: Add audit support
In reply to AKASHI TakahiroOn AArch64, audit is supported through generic lib/audit.c and compat_audit.c, and so this patch adds arch specific definitions required.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -25,6 +25,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_TRACEHOOK select HAVE_DEBUG_BUGVERBOSE
arch/arm64/include/asm/syscall.h +15 -0
@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <linux/audit.h> #include <linux/err.h> +#include <asm/compat.h> static inline int syscall_get_nr(struct task_struct *task,
@@ -104,4 +106,17 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 (struct task_struct *task, +struct pt_regs *regs) +{ +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */
include/uapi/linux/audit.h +1 -0
@@ -333,6 +333,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
Signature · 1 line
1.7.9.5
PATCH v4 3/3 arm64: audit: Add audit hook in ptrace/syscall_trace
In reply to AKASHI TakahiroThis patch adds auditing functions on entry to or exit from every system call invocation.
--- arch/arm64/kernel/ptrace.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/kernel/ptrace.c +7 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1076,10 +1078,15 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) }if (dir) { +audit_syscall_exit (regs);tracehook_report_syscall_exit (regs,0 ); }else {if (tracehook_report_syscall_entry (regs)) regs->syscallno = ~0UL ; +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]); }if (is_compat_task ())
Signature · 1 line
1.7.9.5
Re: [PATCH v4 3/3] arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 31 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/kernel/ptrace.c | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm64/kernel/ptrace.c +2
-0@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h> @@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h> @@ -1076,10 +1078,15 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) }
arch/arm64/kernel/ptrace.c asmlinkage int syscall_trace(int dir, struct pt_regs *regs) · line 1089
Quoted 10 lines
arch/arm64/kernel/ptrace.c +5
-0if (dir) { +audit_syscall_exit (regs);tracehook_report_syscall_exit (regs,0 ); }else {if (tracehook_report_syscall_entry (regs)) regs->syscallno = ~0UL ; +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]);
Again, I don't think we should just lump tracehook and audit together like this without checking the flags (see my reply to the previous patch series).
Will
Quoted 57 lines · AKASHI Takahiro
This patchset adds system call audit support on arm64. Both 32-bit (
AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically__AUDIT_ARCH_64BITbit in AUDIT_ARCH_*).There are some prerequisites for this patch to work correctly:
* "generic compat system call audit support" patch
* "correct a type mismatch inaudit_syscall_exit()" patch (already accepted and queued in 3.14)
* "Modify a set of system calls in audit class" patch (already accepted and queued in 3.14)
* "__NR_* definitions for compat syscalls" patch from Catalin
* "make a single hook tosyscall_trace()for all syscall features" patch
* userspace audit tool (v2.3.2 + my patch for arm64)Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace# auditctl -a exit,always -S openat -F path=/etc/inittab # auditctl -a exit,always -F dir=/tmp -F perm=rw # auditctl -a task,always # autrace /bin/ls by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header,unistd_32.h, is automatically generated fromunistd32.h.
* Refer toregs->orig_x0instead ofregs->x0as the first argument of system call inaudit_syscall_entry()[6/6]
* Include "Addregs_return_value()insyscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".Changes v2 -> v3:
* Removeasm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Removekernel/syscalls/Makefilewhich was used to createunistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patchChanges v3 -> v4:
* Modified to sync with the patch, "make a single hook tosyscall_trace()for all syscall features"AKASHI Takahiro (3):
arm64: Addregs_return_value()insyscall.h
arm64: Add audit support
arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 6 lines
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/ptrace.h | 5 +++++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/kernel/ptrace.c | 7 +++++++ include/uapi/linux/audit.h | 1 + 5 files changed, 29 insertions(+)
Compile and regression tested on: ppc s390 x86_64 ppc64 i686 s390x.
Quoted 7 lines
Signature · 6 lines
1.7.9.5 -- Linux-audit mailing list Linux-audit at redhat.com https://www.redhat.com/mailman/listinfo/linux-audit
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
v5 cover arm64: Add audit support
In reply to AKASHI TakahiroThis patchset adds system call audit support on arm64. Both 32-bit (AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically __AUDIT_ARCH_64BIT bit in AUDIT_ARCH_*).
There are some prerequisites for this patch to work correctly:
* "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
* "generic compat system call audit support" patch
* "__NR_* definitions for compat syscalls" patch from Catalin
* "make a single hook to syscall_trace() for all syscall features" patch
* userspace audit tool (v2.3.2 + my patch for arm64)
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace
# auditctl -a exit,always -S openat -F path=/etc/inittab
# auditctl -a exit,always -F dir=/tmp -F perm=rw
# auditctl -a task,always
# autrace /bin/ls
by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.
Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header, unistd_32.h, is automatically generated from unistd32.h.
* Refer to regs->orig_x0 instead of regs->x0 as the first argument of system call in audit_syscall_entry() [6/6]
* Include "Add regs_return_value() in syscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".
Changes v2 -> v3:
* Remove asm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Remove kernel/syscalls/Makefile which was used to create unistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patch
Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook to syscall_trace() for all syscall features"
* aligned with "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
Changes v4 -> v5:
* rebased to 3.14-rcX
* added a guard against TIF_SYSCALL_AUDIT [3/3]
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v2 [3/3]
AKASHI Takahiro (3):
arm64: Add regs_return_value() in syscall.h
arm64: Add audit support
arm64: audit: Add audit hook in ptrace/syscall_trace
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/ptrace.h | 5 +++++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/kernel/ptrace.c | 11 +++++++++++ include/uapi/linux/audit.h | 1 + 5 files changed, 33 insertions(+)
Signature · 1 line
1.7.9.5
PATCH v5 1/3 arm64: Add regs_return_value() in syscall.h
This macro, regs_return_value, is used mainly for audit to record system call's results, but may also be used in test_kprobes.c.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/include/asm/ptrace.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/include/asm/ptrace.h +5 -0
@@ -134,6 +134,11 @@ struct pt_regs {#define user_stack_pointer (regs) \ ((regs)->sp) +static inline unsigned long regs_return_value (struct pt_regs *regs) +{ +return regs->regs[0 ]; +} +/* * Are the current registers suitable for user mode? (used to maintain * security in signal handlers)
Signature · 1 line
1.7.9.5
PATCH v5 2/3 arm64: Add audit support
In reply to AKASHI TakahiroOn AArch64, audit is supported through generic lib/audit.c and compat_audit.c, and so this patch adds arch specific definitions required.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -25,6 +25,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_TRACEHOOK select HAVE_DEBUG_BUGVERBOSE
arch/arm64/include/asm/syscall.h +15 -0
@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <linux/audit.h> #include <linux/err.h> +#include <asm/compat.h> static inline int syscall_get_nr(struct task_struct *task,
@@ -104,4 +106,17 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 (struct task_struct *task, +struct pt_regs *regs) +{ +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */
include/uapi/linux/audit.h +1 -0
@@ -333,6 +333,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
Signature · 1 line
1.7.9.5
PATCH v5 3/3 arm64: audit: Add audit hook in ptrace/syscall_trace
In reply to AKASHI TakahiroThis patch adds auditing functions on entry to or exit from every system call invocation.
--- arch/arm64/kernel/ptrace.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm64/kernel/ptrace.c +11 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1062,6 +1064,9 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; +if (dir &&test_thread_flag (TIF_SYSCALL_AUDIT )) +audit_syscall_exit (regs); +if (test_thread_flag (TIF_SYSCALL_TRACE )) {if (is_compat_task ()) {/* AArch32 uses ip (r12) for scratch */
@@ -1087,5 +1092,11 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) regs->regs[7 ] = saved_reg; } +if (!dir &&test_thread_flag (TIF_SYSCALL_AUDIT )) +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]); +return regs->syscallno; }
Signature · 1 line
1.7.9.5
v6 cover arm64: Add audit support
In reply to AKASHI TakahiroThis patchset adds system call audit support on arm64. Both 32-bit (AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically __AUDIT_ARCH_64BIT bit in AUDIT_ARCH_*).
There are some prerequisites for this patch to work correctly:
* "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
* "generic compat system call audit support" patch
* "__NR_* definitions for compat syscalls" patch from Catalin
* "make a single hook to syscall_trace() for all syscall features" patch
* "arm64: Add regs_return_value() in syscall.h" patch
* userspace audit tool (v2.3.2 + my patch for arm64)
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace
# auditctl -a exit,always -S openat -F path=/etc/inittab
# auditctl -a exit,always -F dir=/tmp -F perm=rw
# auditctl -a task,always
# autrace /bin/ls
by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.
Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header, unistd_32.h, is automatically generated from unistd32.h.
* Refer to regs->orig_x0 instead of regs->x0 as the first argument of system call in audit_syscall_entry() [6/6]
* Include "Add regs_return_value() in syscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".
Changes v2 -> v3:
* Remove asm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Remove kernel/syscalls/Makefile which was used to create unistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patch
Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook to syscall_trace() for all syscall features"
* aligned with "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
Changes v4 -> v5:
* rebased to 3.14-rcX
* added a guard against TIF_SYSCALL_AUDIT [3/3]
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v2 [3/3]
Changes v5 -> v6:
* removed and put "arm64: Add regs_return_value() in syscall.h" patch into a separate set
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v3 [1/2]
AKASHI Takahiro (2):
arm64: Add audit support
arm64: audit: Add audit hook in ptrace/syscall_trace
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++ arch/arm64/kernel/ptrace.c | 54 ++++++++++++++++++++++---------------- include/uapi/linux/audit.h | 1 + 4 files changed, 49 insertions(+), 22 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v6 1/2 arm64: Add audit support
On AArch64, audit is supported through generic lib/audit.c and compat_audit.c, and so this patch adds arch specific definitions required.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -25,6 +25,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_TRACEHOOK select HAVE_DEBUG_BUGVERBOSE
arch/arm64/include/asm/syscall.h +15 -0
@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <linux/audit.h> #include <linux/err.h> +#include <asm/compat.h> static inline int syscall_get_nr(struct task_struct *task,
@@ -104,4 +106,17 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 (struct task_struct *task, +struct pt_regs *regs) +{ +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */
include/uapi/linux/audit.h +1 -0
@@ -333,6 +333,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
Signature · 1 line
1.7.9.5
Quoted 29 lines · AKASHI Takahiro
On AArch64, audit is supported through generic
lib/audit.candcompat_audit.c, and so this patch adds arch specific definitions required.Acked-by Will Deacon <[email protected]>
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)arch/arm64/Kconfig +1
-0@@ -25,6 +25,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_TRACEHOOK select HAVE_DEBUG_BUGVERBOSEarch/arm64/include/asm/syscall.h +0
-0
arch/arm64/include/asm/syscall.h line 19
Quoted 4 lines
arch/arm64/include/asm/syscall.h +1
-0@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <linux/audit.h>
This could be changed to <uapi/linux/audit.h> to pick up the AUDIT_ARCH_* definitions needed and not any of the audit kernel funcitons.
Quoted 38 lines
arch/arm64/include/asm/syscall.h +14
-0#include <linux/err.h> +#include <asm/compat.h> static inline int syscall_get_nr(struct task_struct *task,@@ -104,4 +106,17 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 (struct task_struct *task, +struct pt_regs *regs) +{ +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */ include/uapi/linux/audit.h +1
-0@@ -333,6 +333,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)Signature · 1 line
1.7.9.5
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Quoted 33 lines · Richard Guy Briggs
Quoted 32 lines · AKASHI Takahiro
On AArch64, audit is supported through generic
lib/audit.candcompat_audit.c, and so this patch adds arch specific definitions required.Acked-by Will Deacon <[email protected]>
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)arch/arm64/Kconfig +1
-0@@ -25,6 +25,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_TRACEHOOK select HAVE_DEBUG_BUGVERBOSEarch/arm64/include/asm/syscall.h +0
-0@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H
Quoted 5 lines
arch/arm64/include/asm/syscall.h line 19
Quoted 1 line
arch/arm64/include/asm/syscall.h +1
-0+#include <linux/audit.h> This could be changed to <
uapi/linux/audit.h> to pick up the AUDIT_ARCH_* definitions needed and not any of the audit kernel funcitons.
I will fix it in the next version.
Thank you,
-Takahiro AKASHI
Quoted 47 lines
Quoted 36 lines
arch/arm64/include/asm/syscall.h +14
-0#include <linux/err.h> +#include <asm/compat.h> static inline int syscall_get_nr(struct task_struct *task,@@ -104,4 +106,17 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 (struct task_struct *task, +struct pt_regs *regs) +{ +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */ include/uapi/linux/audit.h +1
-1@@ -333,6 +333,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM) --Quoted 2 lines
1.7.9.5
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
PATCH v6 2/2 arm64: audit: Add audit hook in ptrace/syscall_trace
In reply to AKASHI TakahiroThis patch adds auditing functions on entry to or exit from every system call invocation.
--- arch/arm64/kernel/ptrace.c | 54 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-)
arch/arm64/kernel/ptrace.c +32 -22
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1062,31 +1064,39 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) {unsigned long saved_reg; -if (!test_thread_flag (TIF_SYSCALL_TRACE )) -return regs->syscallno; +if (dir &&test_thread_flag (TIF_SYSCALL_AUDIT )) +audit_syscall_exit (regs); + +if (test_thread_flag (TIF_SYSCALL_TRACE )) { +if (is_compat_task ()) { +/* AArch32 uses ip (r12) for scratch */ + saved_reg = regs->regs[12 ]; + regs->regs[12 ] = dir; + }else { +/* +* Save X7. X7 is used to denote syscall entry/exit: +* X7 = 0 -> entry, = 1 -> exit +*/ + saved_reg = regs->regs[7 ]; + regs->regs[7 ] = dir; + } -if (is_compat_task ()) { -/* AArch32 uses ip (r12) for scratch */ - saved_reg = regs->regs[12 ]; - regs->regs[12 ] = dir; - }else { -/* -* Save X7. X7 is used to denote syscall entry/exit: -* X7 = 0 -> entry, = 1 -> exit -*/ - saved_reg = regs->regs[7 ]; - regs->regs[7 ] = dir; - } +if (dir) +tracehook_report_syscall_exit (regs,0 ); +else if (tracehook_report_syscall_entry (regs)) + regs->syscallno = ~0UL ; -if (dir) -tracehook_report_syscall_exit (regs,0 ); -else if (tracehook_report_syscall_entry (regs)) - regs->syscallno = ~0UL ; +if (is_compat_task ()) + regs->regs[12 ] = saved_reg; +else + regs->regs[7 ] = saved_reg; + } -if (is_compat_task ()) - regs->regs[12 ] = saved_reg; -else - regs->regs[7 ] = saved_reg; +if (!dir &&test_thread_flag (TIF_SYSCALL_AUDIT )) +audit_syscall_entry (syscall_get_arch (current, regs), + (int )regs->syscallno, + regs->orig_x0, regs->regs[1 ], + regs->regs[2 ], regs->regs[3 ]);return regs->syscallno; }
Signature · 1 line
1.7.9.5
Re: [PATCH v6 2/2] arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 8 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/kernel/ptrace.c | 54 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-)
I think you need to do something like I did for arch/arm/, where we have separate trace functions for entry/exit to make sure that we invoke the various helpers in the correct order (for example, you want to invoke all the debug stuff *first* on entry, but *last* on exit).
Will
Re: [PATCH v6 2/2] arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 10 lines · Will Deacon
Quoted 8 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/kernel/ptrace.c | 54 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-)
Quoted 4 lines
I think you need to do something like I did for
arch/arm/, where we have separate trace functions for entry/exit to make sure that we invoke the various helpers in the correct order (for example, you want to invoke all the debug stuff *first* on entry, but *last* on exit).
I'd have to agree. I've just had my head deep in audit_syscall_entry() and syscall_get_arch to clean them up. Since current is only ever fed to syscall_get_arch() and regs is never used by syscall_get_arch(), I'm looking at dropping both from the syscall_get_arch() args list, but leave syscall_get_arch() as you have it for now.
Quoted 1 line
Will
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
Re: [PATCH v6 2/2] arm64: audit: Add audit hook in ptrace/syscall_trace
In reply to Will DeaconQuoted 10 lines · Will Deacon
Quoted 8 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/kernel/ptrace.c | 54 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-)
Quoted 7 lines
I think you need to do something like I did for
arch/arm/, where we have separate trace functions for entry/exit to make sure that we invoke the various helpers in the correct order (for example, you want to invoke all the debug stuff *first* on entry, but *last* on exit).Will
If you mean syscall_trace_enter()/exit(), I will follow your suggestion for readability.
-Takahiro AKASHI
Re: [PATCH v6 2/2] arm64: audit: Add audit hook in ptrace/syscall_trace
Quoted 16 lines · AKASHI Takahiro
Quoted 15 lines · Will Deacon
Quoted 8 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>--- arch/arm64/kernel/ptrace.c | 54 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-)I think you need to do something like I did for
arch/arm/, where we have separate trace functions for entry/exit to make sure that we invoke the various helpers in the correct order (for example, you want to invoke all the debug stuff *first* on entry, but *last* on exit).
Quoted 4 lines
Quoted 1 line
Will
If you mean syscall_trace_enter()/exit(), I will follow your suggestion for readability.
It isn't so much a question of readability, but rather correctness, undoing operations in the opposite order on exit that they were done on entry.
Quoted 1 line
-Takahiro AKASHI
- RGB
--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
v7 cover arm64: Add audit support
In reply to AKASHI Takahiro(Please apply this patch after my ftrace patch to resolve some conflict on arm64/kernel/ptrace.c, functionally it doesn't depend on ftrace though)
This patchset adds system call audit support on arm64. Both 32-bit (AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically __AUDIT_ARCH_64BIT bit in AUDIT_ARCH_*).
There are some prerequisites for this patch to work correctly:
* "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
* "audit: generic compat system call audit support" patch
* "arm64: __NR_* definitions for compat syscalls" patch from Catalin
* "arm64: make a single hook to syscall_trace() for all syscall features" patch
* "arm64: split syscall_trace() into separate functions for enter/exit" patch
* "arm64: Add regs_return_value() in syscall.h" patch
* userspace audit tool (v2.3.2 + my patch for arm64)
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace
# auditctl -a exit,always -S openat -F path=/etc/inittab
# auditctl -a exit,always -F dir=/tmp -F perm=rw
# auditctl -a task,always
# autrace /bin/ls
by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.
Changes v6 -> v7:
* changed an include file in syscall.h from <linux/audit.h> to <uapi/linux/audit.h> [1/2]
* aligned with the patch, "arm64: split syscall_trace() into separate functions for enter/exit" [2/2]
Changes v5 -> v6:
* removed and put "arm64: Add regs_return_value() in syscall.h" patch into a separate set
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v3 [1/2]
Changes v4 -> v5:
* rebased to 3.14-rcX
* added a guard against TIF_SYSCALL_AUDIT [3/3]
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v2 [3/3]
Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook to syscall_trace() for all syscall features"
* aligned with "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
Changes v2 -> v3:
* Remove asm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Remove kernel/syscalls/Makefile which was used to create unistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patch
Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header, unistd_32.h, is automatically generated from unistd32.h.
* Refer to regs->orig_x0 instead of regs->x0 as the first argument of system call in audit_syscall_entry() [6/6]
* Include "Add regs_return_value() in syscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".
AKASHI Takahiro (2):
arm64: Add audit support
arm64: audit: Add audit hook in syscall_trace_enter/exit()
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/kernel/ptrace.c | 7 +++++++ include/uapi/linux/audit.h | 1 + 4 files changed, 24 insertions(+)
Signature · 1 line
1.7.9.5
PATCH v7 1/2 arm64: Add audit support
On AArch64, audit is supported through generic lib/audit.c and compat_audit.c, and so this patch adds arch specific definitions required.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -25,6 +25,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_TRACEHOOK select HAVE_C_RECORDMCOUNT
arch/arm64/include/asm/syscall.h +15 -0
@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <uapi/linux/audit.h> #include <linux/err.h> +#include <asm/compat.h> extern const void *sys_call_table[];
@@ -105,4 +107,17 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 (struct task_struct *task, +struct pt_regs *regs) +{ +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */
include/uapi/linux/audit.h +1 -0
@@ -333,6 +333,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
Signature · 1 line
1.7.9.5
PATCH v7 2/2 arm64: audit: Add audit hook in syscall_trace_enter/exit()
In reply to AKASHI TakahiroThis patch adds auditing functions on entry to or exit from every system call invocation.
--- arch/arm64/kernel/ptrace.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/kernel/ptrace.c +7 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -38,6 +39,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1091,6 +1093,9 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)if (test_thread_flag (TIF_SYSCALL_TRACEPOINT ))trace_sys_enter (regs, regs->syscallno); +audit_syscall_entry (syscall_get_arch (current, regs), regs->syscallno, + regs->orig_x0, regs->regs[1 ], regs->regs[2 ], regs->regs[3 ]); +return regs->syscallno; }
@@ -1098,6 +1103,8 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs) {unsigned long saved_reg; +audit_syscall_exit (regs); +if (test_thread_flag (TIF_SYSCALL_TRACEPOINT ))trace_sys_exit (regs,regs_return_value (regs));
Signature · 1 line
1.7.9.5
Re: [PATCH v7 2/2] arm64: audit: Add audit hook in syscall_trace_enter/exit()
Quoted 5 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>
Will
cover arm64: Add audit support
In reply to AKASHI Takahiro(Please apply this patch after my ftrace patch to resolve some conflict on arm64/kernel/ptrace.c, functionally it doesn't depend on ftrace though)
This patchset adds system call audit support on arm64. Both 32-bit (AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically __AUDIT_ARCH_64BIT bit in AUDIT_ARCH_*).
There are some prerequisites for this patch to work correctly:
* "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
* "audit: generic compat system call audit support" patch
* "arm64: __NR_* definitions for compat syscalls" patch from Catalin
* "arm64: make a single hook to syscall_trace() for all syscall features" patch
* "arm64: split syscall_trace() into separate functions for enter/exit" patch
* "arm64: Add regs_return_value() in syscall.h" patch
* "arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h" patch
* userspace audit tool (v2.3.2 + my patch for arm64)
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace
# auditctl -a exit,always -S openat -F path=/etc/inittab
# auditctl -a exit,always -F dir=/tmp -F perm=rw
# auditctl -a task,always
# autrace /bin/ls
by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.
Changes v7 -> v8:
* aligned with the change in "audit: generic compat system call audit support" v5 [1/2]
* aligned with the change in "arm64: split syscall_trace() into separate functions for enter/exit" v5 [2/2]
Changes v6 -> v7:
* changed an include file in syscall.h from <linux/audit.h> to <uapi/linux/audit.h> [1/2]
* aligned with the patch, "arm64: split syscall_trace() into separate functions for enter/exit" [2/2]
Changes v5 -> v6:
* removed and put "arm64: Add regs_return_value() in syscall.h" patch into a separate set
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v3 [1/2]
Changes v4 -> v5:
* rebased to 3.14-rcX
* added a guard against TIF_SYSCALL_AUDIT [3/3]
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v2 [3/3]
Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook to syscall_trace() for all syscall features"
* aligned with "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
Changes v2 -> v3:
* Remove asm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Remove kernel/syscalls/Makefile which was used to create unistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patch
Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header, unistd_32.h, is automatically generated from unistd32.h.
* Refer to regs->orig_x0 instead of regs->x0 as the first argument of system call in audit_syscall_entry() [6/6]
* Include "Add regs_return_value() in syscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".
AKASHI Takahiro (2):
arm64: Add audit support
arm64: audit: Add audit hook in syscall_trace_enter/exit()
arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/kernel/ptrace.c | 7 +++++++ include/uapi/linux/audit.h | 1 + 4 files changed, 25 insertions(+)
Signature · 1 line
1.8.3.2
PATCH v6 1/2 arm64: Add audit support
On AArch64, audit is supported through generic lib/audit.c and compat_audit.c, and so this patch adds arch specific definitions required.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 18 insertions(+)
arch/arm64/Kconfig +2 -0
@@ -9,6 +9,7 @@ config ARM64 select ARM_AMBA select ARM_ARCH_TIMER select ARM_GIC + select AUDIT_ARCH_COMPAT_GENERIC select BUILDTIME_EXTABLE_SORT select CLONE_BACKWARDS select COMMON_CLK
@@ -25,6 +26,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_TRACEHOOK select HAVE_C_RECORDMCOUNT
arch/arm64/include/asm/syscall.h +15 -0
@@ -16,7 +16,9 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <uapi/linux/audit.h> #include <linux/err.h> +#include <asm/compat.h> extern const void *sys_call_table[];
@@ -105,4 +107,17 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 (struct task_struct *task, +struct pt_regs *regs) +{ +if (is_compat_thread (task_thread_info (task))) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */
include/uapi/linux/audit.h +1 -0
@@ -333,6 +333,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
Signature · 1 line
1.8.3.2
PATCH v6 2/2 arm64: audit: Add audit hook in syscall_trace_enter/exit()
In reply to AKASHI TakahiroThis patch adds auditing functions on entry to or exit from every system call invocation.
--- arch/arm64/kernel/ptrace.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/kernel/ptrace.c +7 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/compat.h> #include <linux/kernel.h> #include <linux/sched.h>
@@ -39,6 +40,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1097,11 +1099,16 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)if (test_thread_flag (TIF_SYSCALL_TRACEPOINT ))trace_sys_enter (regs, regs->syscallno); +audit_syscall_entry (syscall_get_arch (current, regs), regs->syscallno, + regs->orig_x0, regs->regs[1 ], regs->regs[2 ], regs->regs[3 ]); +return regs->syscallno; } asmlinkage void syscall_trace_exit(struct pt_regs *regs) { +audit_syscall_exit (regs); +if (test_thread_flag (TIF_SYSCALL_TRACEPOINT ))trace_sys_exit (regs,regs_return_value (regs));
Signature · 1 line
1.8.3.2
Re: [PATCH_v8 2/2] arm64: audit: Add audit hook in syscall_trace_enter/exit()
Quoted 5 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>
I think I already acked this patch.
Will
Re: [PATCH_v8 2/2] arm64: audit: Add audit hook in syscall_trace_enter/exit()
Quoted 8 lines · Will Deacon
Quoted 5 lines · AKASHI Takahiro
This patch adds auditing functions on entry to or exit from every system call invocation.
Signed-off-by AKASHI Takahiro <[email protected]>I think I already acked this patch.
Oh, yeah? Thanks.
-Takahiro AKASHI
Quoted 2 lines
Will
Quoted 9 lines · AKASHI Takahiro
(Please apply this patch after my ftrace patch to resolve some conflict on
arm64/kernel/ptrace.c, functionally it doesn't depend on ftrace though)This patchset adds system call audit support on arm64. Both 32-bit (
AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically__AUDIT_ARCH_64BITbit in AUDIT_ARCH_*).
Quoted 11 lines
There are some prerequisites for this patch to work correctly:
* "audit: AddCONFIG_HAVE_ARCH_AUDITSYSCALL" patch
* "audit: generic compat system call audit support" patch
* "arm64: __NR_* definitions for compat syscalls" patch from Catalin
* "arm64: make a single hook tosyscall_trace()for all syscall features" patch
* "arm64: splitsyscall_trace()into separate functions for enter/exit" patch
* "arm64: Addregs_return_value()insyscall.h" patch
* "arm64:is_compat_taskis defined both inasm/compat.handlinux/compat.h" patch
* userspace audit tool (v2.3.2 + my patch for arm64)
and the 2/2 patch won't apply to arch/arm64/kernel/ptrace.c
without the patch from [PATCH v7 7/7] arm64: ftrace: Add system call tracepoint; My question: do you need all 7 patches from arm64: Add ftrace support as well for this audit patch to work, or just this 7/7 patch ?
Quoted 70 lines
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace# auditctl -a exit,always -S openat -F path=/etc/inittab # auditctl -a exit,always -F dir=/tmp -F perm=rw # auditctl -a task,always # autrace /bin/ls by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.Changes v7 -> v8:
* aligned with the change in "audit: generic compat system call audit support" v5 [1/2]
* aligned with the change in "arm64: splitsyscall_trace()into separate functions for enter/exit" v5 [2/2]Changes v6 -> v7:
* changed an include file insyscall.hfrom <linux/audit.h> to <uapi/linux/audit.h> [1/2]
* aligned with the patch, "arm64: splitsyscall_trace()into separate functions for enter/exit" [2/2]Changes v5 -> v6:
* removed and put "arm64: Addregs_return_value()insyscall.h" patch into a separate set
* aligned with the change in "arm64: make a single hook tosyscall_trace()for all syscall features" v3 [1/2]Changes v4 -> v5:
* rebased to 3.14-rcX
* added a guard againstTIF_SYSCALL_AUDIT[3/3]
* aligned with the change in "arm64: make a single hook tosyscall_trace()for all syscall features" v2 [3/3]Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook tosyscall_trace()for all syscall features"
* aligned with "audit: AddCONFIG_HAVE_ARCH_AUDITSYSCALL" patchChanges v2 -> v3:
* Removeasm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Removekernel/syscalls/Makefilewhich was used to createunistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patchChanges v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header,unistd_32.h, is automatically generated fromunistd32.h.
* Refer toregs->orig_x0instead ofregs->x0as the first argument of system call inaudit_syscall_entry()[6/6]
* Include "Addregs_return_value()insyscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".AKASHI Takahiro (2):
arm64: Add audit support
arm64: audit: Add audit hook in syscall_trace_enter/exit()arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/kernel/ptrace.c | 7 +++++++ include/uapi/linux/audit.h | 1 + 4 files changed, 25 insertions(+)
Hi Don,
Sorry for not responding to you soon:
Quoted 21 lines · Don Dutile
Quoted 9 lines · AKASHI Takahiro
(Please apply this patch after my ftrace patch to resolve some conflict on
arm64/kernel/ptrace.c, functionally it doesn't depend on ftrace though)This patchset adds system call audit support on arm64. Both 32-bit (
AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically__AUDIT_ARCH_64BITbit in AUDIT_ARCH_*).Quoted 11 lines
There are some prerequisites for this patch to work correctly:
* "audit: AddCONFIG_HAVE_ARCH_AUDITSYSCALL" patch
* "audit: generic compat system call audit support" patch
* "arm64: __NR_* definitions for compat syscalls" patch from Catalin
* "arm64: make a single hook tosyscall_trace()for all syscall features" patch
* "arm64: splitsyscall_trace()into separate functions for enter/exit" patch
* "arm64: Addregs_return_value()insyscall.h" patch
* "arm64:is_compat_taskis defined both inasm/compat.handlinux/compat.h" patch
* userspace audit tool (v2.3.2 + my patch for arm64)
Quoted 4 lines
and the 2/2 patch won't apply to
arch/arm64/kernel/ptrace.c
without the patch from [PATCH v7 7/7] arm64: ftrace: Add system call tracepoint; My question: do you need all 7 patches from arm64: Add ftrace support as well for this audit patch to work, or just this 7/7 patch ?
Functionally, my audit patch should work without ftrace patchset, but as described in ftrace's [0/7] and audit's [0/2], audit's [2/2] assumes that ftrace patchset, especially [7/7], has been applied in order to avoid any conflict when making changes on the same line of ptrace.c.
Thanks,
-Takahiro AKASHI
Quoted 72 lines
Quoted 71 lines
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace# auditctl -a exit,always -S openat -F path=/etc/inittab # auditctl -a exit,always -F dir=/tmp -F perm=rw # auditctl -a task,always # autrace /bin/ls by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.Changes v7 -> v8:
* aligned with the change in "audit: generic compat system call audit support" v5 [1/2]
* aligned with the change in "arm64: splitsyscall_trace()into separate functions for enter/exit" v5 [2/2]Changes v6 -> v7:
* changed an include file insyscall.hfrom <linux/audit.h> to <uapi/linux/audit.h> [1/2]
* aligned with the patch, "arm64: splitsyscall_trace()into separate functions for enter/exit" [2/2]Changes v5 -> v6:
* removed and put "arm64: Addregs_return_value()insyscall.h" patch into a separate set
* aligned with the change in "arm64: make a single hook tosyscall_trace()for all syscall features" v3 [1/2]Changes v4 -> v5:
* rebased to 3.14-rcX
* added a guard againstTIF_SYSCALL_AUDIT[3/3]
* aligned with the change in "arm64: make a single hook tosyscall_trace()for all syscall features" v2 [3/3]Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook tosyscall_trace()for all syscall features"
* aligned with "audit: AddCONFIG_HAVE_ARCH_AUDITSYSCALL" patchChanges v2 -> v3:
* Removeasm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Removekernel/syscalls/Makefilewhich was used to createunistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patchChanges v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header,unistd_32.h, is automatically generated fromunistd32.h.
* Refer toregs->orig_x0instead ofregs->x0as the first argument of system call inaudit_syscall_entry()[6/6]
* Include "Addregs_return_value()insyscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".AKASHI Takahiro (2):
arm64: Add audit support
arm64: audit: Add audit hook in syscall_trace_enter/exit()arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/kernel/ptrace.c | 7 +++++++ include/uapi/linux/audit.h | 1 + 4 files changed, 25 insertions(+)
Quoted 4 lines · AKASHI Takahiro
Hi Don,
Sorry for not responding to you soon:
been there, done that! .. no problem..
Quoted 27 lines · Don Dutile
Quoted 21 lines · AKASHI Takahiro
Quoted 9 lines
(Please apply this patch after my ftrace patch to resolve some conflict on
arm64/kernel/ptrace.c, functionally it doesn't depend on ftrace though)This patchset adds system call audit support on arm64. Both 32-bit (
AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically__AUDIT_ARCH_64BITbit in AUDIT_ARCH_*).Quoted 11 lines
There are some prerequisites for this patch to work correctly:
* "audit: AddCONFIG_HAVE_ARCH_AUDITSYSCALL" patch
* "audit: generic compat system call audit support" patch
* "arm64: __NR_* definitions for compat syscalls" patch from Catalin
* "arm64: make a single hook tosyscall_trace()for all syscall features" patch
* "arm64: splitsyscall_trace()into separate functions for enter/exit" patch
* "arm64: Addregs_return_value()insyscall.h" patch
* "arm64:is_compat_taskis defined both inasm/compat.handlinux/compat.h" patch
* userspace audit tool (v2.3.2 + my patch for arm64)Quoted 4 lines
and the 2/2 patch won't apply to
arch/arm64/kernel/ptrace.c
without the patch from [PATCH v7 7/7] arm64: ftrace: Add system call tracepoint; My question: do you need all 7 patches from arm64: Add ftrace support as well for this audit patch to work, or just this 7/7 patch ?
Quoted 8 lines
Functionally, my audit patch should work without ftrace patchset, but as described in ftrace's [0/7] and audit's [0/2], audit's [2/2] assumes that ftrace patchset, especially [7/7], has been applied in order to avoid any conflict when making changes on the same line of
ptrace.c.Thanks,
-Takahiro AKASHI
just a nit for others to see/know if they were having the same fun of backporting these patches to work on an existing kernel w/o ftrace patch set.
Quoted 77 lines
Quoted 65 lines
Quoted 65 lines
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace# auditctl -a exit,always -S openat -F path=/etc/inittab # auditctl -a exit,always -F dir=/tmp -F perm=rw # auditctl -a task,always # autrace /bin/ls by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.Changes v7 -> v8:
* aligned with the change in "audit: generic compat system call audit support" v5 [1/2]
* aligned with the change in "arm64: splitsyscall_trace()into separate functions for enter/exit" v5 [2/2]Changes v6 -> v7:
* changed an include file insyscall.hfrom <linux/audit.h> to <uapi/linux/audit.h> [1/2]
* aligned with the patch, "arm64: splitsyscall_trace()into separate functions for enter/exit" [2/2]Changes v5 -> v6:
* removed and put "arm64: Addregs_return_value()insyscall.h" patch into a separate set
* aligned with the change in "arm64: make a single hook tosyscall_trace()for all syscall features" v3 [1/2]Changes v4 -> v5:
* rebased to 3.14-rcX
* added a guard againstTIF_SYSCALL_AUDIT[3/3]
* aligned with the change in "arm64: make a single hook tosyscall_trace()for all syscall features" v2 [3/3]Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook tosyscall_trace()for all syscall features"
* aligned with "audit: AddCONFIG_HAVE_ARCH_AUDITSYSCALL" patchChanges v2 -> v3:
* Removeasm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Removekernel/syscalls/Makefilewhich was used to createunistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patchChanges v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header,unistd_32.h, is automatically generated fromunistd32.h.
* Refer toregs->orig_x0instead ofregs->x0as the first argument of system call inaudit_syscall_entry()[6/6]
* Include "Addregs_return_value()insyscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".AKASHI Takahiro (2):
arm64: Add audit support
arm64: audit: Add audit hook in syscall_trace_enter/exit()Quoted 7 lines
Quoted 6 lines
arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/syscall.h | 15 +++++++++++++++ arch/arm64/kernel/ptrace.c | 7 +++++++ include/uapi/linux/audit.h | 1 + 4 files changed, 25 insertions(+)--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
v9 cover arm64: Add audit support
In reply to AKASHI Takahiro(This patchset was already acked by the maintainer, but now re-submitted since it needs to be modified due to rebase to 3.15. See below)
(Please apply this patch after my ftrace patch to resolve some conflict on arm64/kernel/ptrace.c, functionally it doesn't depend on ftrace though)
This patchset adds system call audit support on arm64. Both 32-bit (AUDIT_ARCH_ARM) and 64-bit tasks (AUDIT_ARCH_AARCH64) are supported. Since arm64 has the exact same set of system calls on LE and BE, we don't care about endianness (or more specifically __AUDIT_ARCH_64BIT bit in AUDIT_ARCH_*).
There are some prerequisites for this patch to work correctly:
* "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
* "audit: generic compat system call audit support" patch
* "arm64: __NR_* definitions for compat syscalls" patch from Catalin
* "arm64: make a single hook to syscall_trace() for all syscall features" patch
* "arm64: split syscall_trace() into separate functions for enter/exit" patch
* "arm64: Add regs_return_value() in syscall.h" patch
* "arm64: is_compat_task is defined both in asm/compat.h and linux/compat.h" patch
* userspace audit tool (v2.3.6)
Please review them as well for better understandings.
This code was tested on both 32-bit and 64-bit LE userland in the following two ways:
1) basic operations with auditctl/autrace
# auditctl -a exit,always -S openat -F path=/etc/inittab
# auditctl -a exit,always -F dir=/tmp -F perm=rw
# auditctl -a task,always
# autrace /bin/ls
by comparing output from autrace with one from strace2) audit-test-code (+ my workarounds for arm/arm64)
by running "audit-tool", "filter" and "syscalls" test categories.
Changes v8 -> v9:
* rebased on 3.15-rc, especially due to the change of syscall_get_arch() interface [1,2/2]
Changes v7 -> v8:
* aligned with the change in "audit: generic compat system call audit support" v5 [1/2]
* aligned with the change in "arm64: split syscall_trace() into separate functions for enter/exit" v5 [2/2]
Changes v6 -> v7:
* changed an include file in syscall.h from <linux/audit.h> to <uapi/linux/audit.h> [1/2]
* aligned with the patch, "arm64: split syscall_trace() into separate functions for enter/exit" [2/2]
Changes v5 -> v6:
* removed and put "arm64: Add regs_return_value() in syscall.h" patch into a separate set
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v3 [1/2]
Changes v4 -> v5:
* rebased to 3.14-rcX
* added a guard against TIF_SYSCALL_AUDIT [3/3]
* aligned with the change in "arm64: make a single hook to syscall_trace() for all syscall features" v2 [3/3]
Changes v3 -> v4:
* Modified to sync with the patch, "make a single hook to syscall_trace() for all syscall features"
* aligned with "audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL" patch
Changes v2 -> v3:
* Remove asm/audit.h.
See "generic compat syscall audit support" patch v4
* Remove endianness dependency, ie. AUDIT_ARCH_ARMEB/AARCH64EB.
* Remove kernel/syscalls/Makefile which was used to create unistd32.h. See Catalin's "Add __NR_* definitions for compat syscalls" patch
Changes v1 -> v2:
* Modified to utilize "generic compat system call audit" [3/6, 4/6, 5/6] Please note that a required header, unistd_32.h, is automatically generated from unistd32.h.
* Refer to regs->orig_x0 instead of regs->x0 as the first argument of system call in audit_syscall_entry() [6/6]
* Include "Add regs_return_value() in syscall.h" patch [2/6], which was not intentionally included in v1 because it could be added by "kprobes support".
AKASHI Takahiro (2):
arm64: Add audit support
arm64: audit: Add audit hook in syscall_trace_enter/exit()
arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/syscall.h | 14 ++++++++++++++ arch/arm64/kernel/ptrace.c | 7 +++++++ include/uapi/linux/audit.h | 1 + 4 files changed, 24 insertions(+)
Signature · 1 line
1.7.9.5
PATCH v9 1/2 arm64: Add audit support
On AArch64, audit is supported through generic lib/audit.c and compat_audit.c, and so this patch adds arch specific definitions required.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/syscall.h | 14 ++++++++++++++ include/uapi/linux/audit.h | 1 + 3 files changed, 17 insertions(+)
arch/arm64/Kconfig +2 -0
@@ -9,6 +9,7 @@ config ARM64 select ARM_AMBA select ARM_ARCH_TIMER select ARM_GIC + select AUDIT_ARCH_COMPAT_GENERIC select BUILDTIME_EXTABLE_SORT select CLONE_BACKWARDS select COMMON_CLK
@@ -27,6 +28,7 @@ config ARM64 select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND + select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK
arch/arm64/include/asm/syscall.h +14 -0
@@ -16,6 +16,8 @@#ifndef __ASM_SYSCALL_H#define __ASM_SYSCALL_H +#include <uapi/linux/audit.h> +#include <linux/compat.h> #include <linux/err.h> extern const void *sys_call_table[];
@@ -105,4 +107,16 @@ static inline void syscall_set_arguments(struct task_struct *task, memcpy(®s->regs[i], args, n * sizeof(args[0])); } +/* +* 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 ) +{ +if (is_compat_task ()) +return AUDIT_ARCH_ARM ; + +return AUDIT_ARCH_AARCH64 ; +} +#endif /* __ASM_SYSCALL_H */
include/uapi/linux/audit.h +1 -0
@@ -334,6 +334,7 @@ enum {/* distinguish syscall tables */ #define __AUDIT_ARCH_64BIT 0x80000000#define __AUDIT_ARCH_LE 0x40000000 +#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)#define AUDIT_ARCH_ARMEB (EM_ARM)
Signature · 1 line
1.7.9.5
PATCH v9 2/2 arm64: audit: Add audit hook in syscall_trace_enter/exit()
In reply to AKASHI TakahiroThis patch adds auditing functions on entry to or exit from every system call invocation.
Acked-by Will Deacon <[email protected]>
--- arch/arm64/kernel/ptrace.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/kernel/ptrace.c +7 -0
@@ -19,6 +19,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/audit.h> #include <linux/compat.h> #include <linux/kernel.h> #include <linux/sched.h>
@@ -39,6 +40,7 @@#include <asm/compat.h> #include <asm/debug-monitors.h> #include <asm/pgtable.h> +#include <asm/syscall.h> #include <asm/traps.h> #include <asm/system_misc.h>
@@ -1097,11 +1099,16 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)if (test_thread_flag (TIF_SYSCALL_TRACEPOINT ))trace_sys_enter (regs, regs->syscallno); +audit_syscall_entry (syscall_get_arch (), regs->syscallno, + regs->orig_x0, regs->regs[1 ], regs->regs[2 ], regs->regs[3 ]); +return regs->syscallno; } asmlinkage void syscall_trace_exit(struct pt_regs *regs) { +audit_syscall_exit (regs); +if (test_thread_flag (TIF_SYSCALL_TRACEPOINT ))trace_sys_exit (regs,regs_return_value (regs));
Signature · 1 line
1.7.9.5