Skip to content

Commit 5ab889f

Browse files
committed
Merge tag 'hardening-v6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardening updates from Kees Cook: - stackleak: Use str_enabled_disabled() helper (Thorsten Blum) - Document GCC INIT_STACK_ALL_PATTERN behavior (Geert Uytterhoeven) - Add task_prctl_unknown tracepoint (Marco Elver) * tag 'hardening-v6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: hardening: Document INIT_STACK_ALL_PATTERN behavior with GCC stackleak: Use str_enabled_disabled() helper in stack_erasing_sysctl() tracing: Remove pid in task_rename tracing output tracing: Add task_prctl_unknown tracepoint
2 parents ad2aec7 + a9a5e0b commit 5ab889f

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

include/trace/events/task.h

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,56 @@ TRACE_EVENT(task_rename,
3838
TP_ARGS(task, comm),
3939

4040
TP_STRUCT__entry(
41-
__field( pid_t, pid)
4241
__array( char, oldcomm, TASK_COMM_LEN)
4342
__array( char, newcomm, TASK_COMM_LEN)
4443
__field( short, oom_score_adj)
4544
),
4645

4746
TP_fast_assign(
48-
__entry->pid = task->pid;
4947
memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
5048
strscpy(entry->newcomm, comm, TASK_COMM_LEN);
5149
__entry->oom_score_adj = task->signal->oom_score_adj;
5250
),
5351

54-
TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%hd",
55-
__entry->pid, __entry->oldcomm,
56-
__entry->newcomm, __entry->oom_score_adj)
52+
TP_printk("oldcomm=%s newcomm=%s oom_score_adj=%hd",
53+
__entry->oldcomm, __entry->newcomm, __entry->oom_score_adj)
54+
);
55+
56+
/**
57+
* task_prctl_unknown - called on unknown prctl() option
58+
* @option: option passed
59+
* @arg2: arg2 passed
60+
* @arg3: arg3 passed
61+
* @arg4: arg4 passed
62+
* @arg5: arg5 passed
63+
*
64+
* Called on an unknown prctl() option.
65+
*/
66+
TRACE_EVENT(task_prctl_unknown,
67+
68+
TP_PROTO(int option, unsigned long arg2, unsigned long arg3,
69+
unsigned long arg4, unsigned long arg5),
70+
71+
TP_ARGS(option, arg2, arg3, arg4, arg5),
72+
73+
TP_STRUCT__entry(
74+
__field( int, option)
75+
__field( unsigned long, arg2)
76+
__field( unsigned long, arg3)
77+
__field( unsigned long, arg4)
78+
__field( unsigned long, arg5)
79+
),
80+
81+
TP_fast_assign(
82+
__entry->option = option;
83+
__entry->arg2 = arg2;
84+
__entry->arg3 = arg3;
85+
__entry->arg4 = arg4;
86+
__entry->arg5 = arg5;
87+
),
88+
89+
TP_printk("option=%d arg2=%ld arg3=%ld arg4=%ld arg5=%ld",
90+
__entry->option, __entry->arg2, __entry->arg3, __entry->arg4, __entry->arg5)
5791
);
5892

5993
#endif

kernel/stackleak.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
1717
#include <linux/jump_label.h>
18+
#include <linux/string_choices.h>
1819
#include <linux/sysctl.h>
1920
#include <linux/init.h>
2021

@@ -41,7 +42,7 @@ static int stack_erasing_sysctl(const struct ctl_table *table, int write,
4142
static_branch_enable(&stack_erasing_bypass);
4243

4344
pr_warn("stackleak: kernel stack erasing is %s\n",
44-
state ? "enabled" : "disabled");
45+
str_enabled_disabled(state));
4546
return ret;
4647
}
4748
static struct ctl_table stackleak_sysctls[] = {

kernel/sys.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
#include <asm/io.h>
7676
#include <asm/unistd.h>
7777

78+
#include <trace/events/task.h>
79+
7880
#include "uid16.h"
7981

8082
#ifndef SET_UNALIGN_CTL
@@ -2810,6 +2812,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
28102812
error = arch_lock_shadow_stack_status(me, arg2);
28112813
break;
28122814
default:
2815+
trace_task_prctl_unknown(option, arg2, arg3, arg4, arg5);
28132816
error = -EINVAL;
28142817
break;
28152818
}

security/Kconfig.hardening

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ choice
127127
repeating for all types and padding except float and double
128128
which use 0xFF repeating (-NaN). Clang on 32-bit uses 0xFF
129129
repeating for all types and padding.
130+
GCC uses 0xFE repeating for all types, and zero for padding.
130131

131132
config INIT_STACK_ALL_ZERO
132133
bool "zero-init everything (strongest and safest)"

0 commit comments

Comments
 (0)