Skip to content

Commit b03a434

Browse files
committed
Merge tag 'seccomp-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull seccomp updates from Kees Cook: - Provide USER_NOTIFY flag for synchronous mode (Andrei Vagin, Peter Oskolkov). This touches the scheduler and perf but has been Acked by Peter Zijlstra. - Fix regression in syscall skipping and restart tracing on arm32. This touches arch/arm/ but has been Acked by Arnd Bergmann. * tag 'seccomp-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: seccomp: Add missing kerndoc notations ARM: ptrace: Restore syscall skipping for tracers ARM: ptrace: Restore syscall restart tracing selftests/seccomp: Handle arm32 corner cases better perf/benchmark: add a new benchmark for seccom_unotify selftest/seccomp: add a new test for the sync mode of seccomp_user_notify seccomp: add the synchronous mode for seccomp_unotify sched: add a few helpers to wake up tasks on the current cpu sched: add WF_CURRENT_CPU and externise ttwu seccomp: don't use semaphore and wait_queue together
2 parents 5b07aac + 4682286 commit b03a434

File tree

21 files changed

+384
-34
lines changed

21 files changed

+384
-34
lines changed

arch/arm/include/asm/syscall.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ static inline int syscall_get_nr(struct task_struct *task,
2525
if (IS_ENABLED(CONFIG_AEABI) && !IS_ENABLED(CONFIG_OABI_COMPAT))
2626
return task_thread_info(task)->abi_syscall;
2727

28+
if (task_thread_info(task)->abi_syscall == -1)
29+
return -1;
30+
2831
return task_thread_info(task)->abi_syscall & __NR_SYSCALL_MASK;
2932
}
3033

arch/arm/kernel/entry-common.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ slow_work_pending:
9090
cmp r0, #0
9191
beq no_work_pending
9292
movlt scno, #(__NR_restart_syscall - __NR_SYSCALL_BASE)
93+
str scno, [tsk, #TI_ABI_SYSCALL] @ make sure tracers see update
9394
ldmia sp, {r0 - r6} @ have to reload r0 - r6
9495
b local_restart @ ... and off we go
9596
ENDPROC(ret_fast_syscall)

arch/arm/kernel/ptrace.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,9 @@ long arch_ptrace(struct task_struct *child, long request,
783783
break;
784784

785785
case PTRACE_SET_SYSCALL:
786-
task_thread_info(child)->abi_syscall = data &
787-
__NR_SYSCALL_MASK;
786+
if (data != -1)
787+
data &= __NR_SYSCALL_MASK;
788+
task_thread_info(child)->abi_syscall = data;
788789
ret = 0;
789790
break;
790791

include/linux/completion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ extern bool try_wait_for_completion(struct completion *x);
116116
extern bool completion_done(struct completion *x);
117117

118118
extern void complete(struct completion *);
119+
extern void complete_on_current_cpu(struct completion *x);
119120
extern void complete_all(struct completion *);
120121

121122
#endif

include/linux/swait.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static inline bool swq_has_sleeper(struct swait_queue_head *wq)
146146

147147
extern void swake_up_one(struct swait_queue_head *q);
148148
extern void swake_up_all(struct swait_queue_head *q);
149-
extern void swake_up_locked(struct swait_queue_head *q);
149+
extern void swake_up_locked(struct swait_queue_head *q, int wake_flags);
150150

151151
extern void prepare_to_swait_exclusive(struct swait_queue_head *q, struct swait_queue *wait, int state);
152152
extern long prepare_to_swait_event(struct swait_queue_head *q, struct swait_queue *wait, int state);

include/linux/wait.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ __remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq
210210
}
211211

212212
int __wake_up(struct wait_queue_head *wq_head, unsigned int mode, int nr, void *key);
213+
void __wake_up_on_current_cpu(struct wait_queue_head *wq_head, unsigned int mode, void *key);
213214
void __wake_up_locked_key(struct wait_queue_head *wq_head, unsigned int mode, void *key);
214215
void __wake_up_locked_key_bookmark(struct wait_queue_head *wq_head,
215216
unsigned int mode, void *key, wait_queue_entry_t *bookmark);
@@ -237,6 +238,8 @@ void __wake_up_pollfree(struct wait_queue_head *wq_head);
237238
#define key_to_poll(m) ((__force __poll_t)(uintptr_t)(void *)(m))
238239
#define wake_up_poll(x, m) \
239240
__wake_up(x, TASK_NORMAL, 1, poll_to_key(m))
241+
#define wake_up_poll_on_current_cpu(x, m) \
242+
__wake_up_on_current_cpu(x, TASK_NORMAL, poll_to_key(m))
240243
#define wake_up_locked_poll(x, m) \
241244
__wake_up_locked_key((x), TASK_NORMAL, poll_to_key(m))
242245
#define wake_up_interruptible_poll(x, m) \

include/uapi/linux/seccomp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ struct seccomp_notif_resp {
115115
__u32 flags;
116116
};
117117

118+
#define SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP (1UL << 0)
119+
118120
/* valid flags for seccomp_notif_addfd */
119121
#define SECCOMP_ADDFD_FLAG_SETFD (1UL << 0) /* Specify remote fd */
120122
#define SECCOMP_ADDFD_FLAG_SEND (1UL << 1) /* Addfd and return it, atomically */
@@ -150,4 +152,6 @@ struct seccomp_notif_addfd {
150152
#define SECCOMP_IOCTL_NOTIF_ADDFD SECCOMP_IOW(3, \
151153
struct seccomp_notif_addfd)
152154

155+
#define SECCOMP_IOCTL_NOTIF_SET_FLAGS SECCOMP_IOW(4, __u64)
156+
153157
#endif /* _UAPI_LINUX_SECCOMP_H */

kernel/sched/completion.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@
1313
* Waiting for completion is a typically sync point, but not an exclusion point.
1414
*/
1515

16+
static void complete_with_flags(struct completion *x, int wake_flags)
17+
{
18+
unsigned long flags;
19+
20+
raw_spin_lock_irqsave(&x->wait.lock, flags);
21+
22+
if (x->done != UINT_MAX)
23+
x->done++;
24+
swake_up_locked(&x->wait, wake_flags);
25+
raw_spin_unlock_irqrestore(&x->wait.lock, flags);
26+
}
27+
28+
void complete_on_current_cpu(struct completion *x)
29+
{
30+
return complete_with_flags(x, WF_CURRENT_CPU);
31+
}
32+
1633
/**
1734
* complete: - signals a single thread waiting on this completion
1835
* @x: holds the state of this particular completion
@@ -27,14 +44,7 @@
2744
*/
2845
void complete(struct completion *x)
2946
{
30-
unsigned long flags;
31-
32-
raw_spin_lock_irqsave(&x->wait.lock, flags);
33-
34-
if (x->done != UINT_MAX)
35-
x->done++;
36-
swake_up_locked(&x->wait);
37-
raw_spin_unlock_irqrestore(&x->wait.lock, flags);
47+
complete_with_flags(x, 0);
3848
}
3949
EXPORT_SYMBOL(complete);
4050

kernel/sched/core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4193,8 +4193,7 @@ bool ttwu_state_match(struct task_struct *p, unsigned int state, int *success)
41934193
* Return: %true if @p->state changes (an actual wakeup was done),
41944194
* %false otherwise.
41954195
*/
4196-
static int
4197-
try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
4196+
int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
41984197
{
41994198
unsigned long flags;
42004199
int cpu, success = 0;
@@ -7030,7 +7029,7 @@ asmlinkage __visible void __sched preempt_schedule_irq(void)
70307029
int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flags,
70317030
void *key)
70327031
{
7033-
WARN_ON_ONCE(IS_ENABLED(CONFIG_SCHED_DEBUG) && wake_flags & ~WF_SYNC);
7032+
WARN_ON_ONCE(IS_ENABLED(CONFIG_SCHED_DEBUG) && wake_flags & ~(WF_SYNC|WF_CURRENT_CPU));
70347033
return try_to_wake_up(curr->private, mode, wake_flags);
70357034
}
70367035
EXPORT_SYMBOL(default_wake_function);

kernel/sched/fair.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7741,6 +7741,10 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
77417741
if (wake_flags & WF_TTWU) {
77427742
record_wakee(p);
77437743

7744+
if ((wake_flags & WF_CURRENT_CPU) &&
7745+
cpumask_test_cpu(cpu, p->cpus_ptr))
7746+
return cpu;
7747+
77447748
if (sched_energy_enabled()) {
77457749
new_cpu = find_energy_efficient_cpu(p, prev_cpu);
77467750
if (new_cpu >= 0)

0 commit comments

Comments
 (0)