Skip to content

Commit bcc9f96

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha
Pull alpha updates from Matt Turner: "A pair of changes for alpha. One fixes a networking regression, and the second adds audit syscall support which will help in supporting systemd" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha: alpha: fix broken network checksum alpha: Enable system-call auditing support.
2 parents b399c46 + 0ef38d7 commit bcc9f96

File tree

9 files changed

+88
-4
lines changed

9 files changed

+88
-4
lines changed

arch/alpha/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ config ALPHA
1717
select ARCH_WANT_IPC_PARSE_VERSION
1818
select ARCH_HAVE_NMI_SAFE_CMPXCHG
1919
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
20+
select AUDIT_ARCH
2021
select GENERIC_CLOCKEVENTS
2122
select GENERIC_SMP_IDLE_THREAD
2223
select GENERIC_STRNCPY_FROM_USER
@@ -77,6 +78,8 @@ config GENERIC_ISA_DMA
7778
source "init/Kconfig"
7879
source "kernel/Kconfig.freezer"
7980

81+
config AUDIT_ARCH
82+
bool
8083

8184
menu "System setup"
8285

arch/alpha/include/asm/ptrace.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@
1919

2020
#define force_successful_syscall_return() (current_pt_regs()->r0 = 0)
2121

22+
static inline unsigned long regs_return_value(struct pt_regs *regs)
23+
{
24+
return regs->r0;
25+
}
26+
2227
#endif

arch/alpha/include/asm/thread_info.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ register struct thread_info *__current_thread_info __asm__("$8");
7070
#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
7171
#define TIF_SIGPENDING 2 /* signal pending */
7272
#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
73+
#define TIF_SYSCALL_AUDIT 4 /* syscall audit active */
7374
#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */
7475
#define TIF_MEMDIE 13 /* is terminating due to OOM killer */
7576

7677
#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7778
#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
7879
#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
7980
#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
81+
#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8082

8183
/* Work to do on interrupt/exception return. */
8284
#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \

arch/alpha/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ obj-$(CONFIG_SRM_ENV) += srm_env.o
1717
obj-$(CONFIG_MODULES) += module.o
1818
obj-$(CONFIG_PERF_EVENTS) += perf_event.o
1919
obj-$(CONFIG_RTC_DRV_ALPHA) += rtc.o
20+
obj-$(CONFIG_AUDIT) += audit.o
2021

2122
ifdef CONFIG_ALPHA_GENERIC
2223

arch/alpha/kernel/audit.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <linux/init.h>
2+
#include <linux/types.h>
3+
#include <linux/audit.h>
4+
#include <asm/unistd.h>
5+
6+
static unsigned dir_class[] = {
7+
#include <asm-generic/audit_dir_write.h>
8+
~0U
9+
};
10+
11+
static unsigned read_class[] = {
12+
#include <asm-generic/audit_read.h>
13+
~0U
14+
};
15+
16+
static unsigned write_class[] = {
17+
#include <asm-generic/audit_write.h>
18+
~0U
19+
};
20+
21+
static unsigned chattr_class[] = {
22+
#include <asm-generic/audit_change_attr.h>
23+
~0U
24+
};
25+
26+
static unsigned signal_class[] = {
27+
#include <asm-generic/audit_signal.h>
28+
~0U
29+
};
30+
31+
int audit_classify_arch(int arch)
32+
{
33+
return 0;
34+
}
35+
36+
int audit_classify_syscall(int abi, unsigned syscall)
37+
{
38+
switch(syscall) {
39+
case __NR_open:
40+
return 2;
41+
case __NR_openat:
42+
return 3;
43+
case __NR_execve:
44+
return 5;
45+
default:
46+
return 0;
47+
}
48+
}
49+
50+
static int __init audit_classes_init(void)
51+
{
52+
audit_register_class(AUDIT_CLASS_WRITE, write_class);
53+
audit_register_class(AUDIT_CLASS_READ, read_class);
54+
audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
55+
audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
56+
audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
57+
return 0;
58+
}
59+
60+
__initcall(audit_classes_init);

arch/alpha/kernel/entry.S

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,11 @@ entSys:
465465
.cfi_rel_offset $16, SP_OFF+24
466466
.cfi_rel_offset $17, SP_OFF+32
467467
.cfi_rel_offset $18, SP_OFF+40
468-
blbs $3, strace
468+
#ifdef CONFIG_AUDITSYSCALL
469+
lda $6, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
470+
and $3, $6, $3
471+
#endif
472+
bne $3, strace
469473
beq $4, 1f
470474
ldq $27, 0($5)
471475
1: jsr $26, ($27), alpha_ni_syscall

arch/alpha/kernel/ptrace.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/security.h>
1515
#include <linux/signal.h>
1616
#include <linux/tracehook.h>
17+
#include <linux/audit.h>
1718

1819
#include <asm/uaccess.h>
1920
#include <asm/pgtable.h>
@@ -316,15 +317,18 @@ long arch_ptrace(struct task_struct *child, long request,
316317
asmlinkage unsigned long syscall_trace_enter(void)
317318
{
318319
unsigned long ret = 0;
320+
struct pt_regs *regs = current_pt_regs();
319321
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
320322
tracehook_report_syscall_entry(current_pt_regs()))
321323
ret = -1UL;
324+
audit_syscall_entry(AUDIT_ARCH_ALPHA, regs->r0, regs->r16, regs->r17, regs->r18, regs->r19);
322325
return ret ?: current_pt_regs()->r0;
323326
}
324327

325328
asmlinkage void
326329
syscall_trace_leave(void)
327330
{
331+
audit_syscall_exit(current_pt_regs());
328332
if (test_thread_flag(TIF_SYSCALL_TRACE))
329333
tracehook_report_syscall_exit(current_pt_regs(), 0);
330334
}

arch/alpha/lib/csum_partial_copy.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,11 @@ csum_partial_copy_from_user(const void __user *src, void *dst, int len,
378378
__wsum
379379
csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
380380
{
381-
return csum_partial_copy_from_user((__force const void __user *)src,
382-
dst, len, sum, NULL);
381+
__wsum checksum;
382+
mm_segment_t oldfs = get_fs();
383+
set_fs(KERNEL_DS);
384+
checksum = csum_partial_copy_from_user((__force const void __user *)src,
385+
dst, len, sum, NULL);
386+
set_fs(oldfs);
387+
return checksum;
383388
}

init/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ config AUDIT
284284

285285
config AUDITSYSCALL
286286
bool "Enable system-call auditing support"
287-
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT))
287+
depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA)
288288
default y if SECURITY_SELINUX
289289
help
290290
Enable low-overhead system-call auditing infrastructure that

0 commit comments

Comments
 (0)