From: Greg Kroah-Hartman Date: Mon, 22 Mar 2021 09:34:58 +0000 (+0100) Subject: 5.4-stable patches X-Git-Tag: v4.4.263~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e7a21d10da3828038d8bae6ffd924a08e925f637;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: kernel-fs-introduce-and-use-set_restart_fn-and-arch_set_restart_data.patch --- diff --git a/queue-5.4/kernel-fs-introduce-and-use-set_restart_fn-and-arch_set_restart_data.patch b/queue-5.4/kernel-fs-introduce-and-use-set_restart_fn-and-arch_set_restart_data.patch new file mode 100644 index 00000000000..21ac6764502 --- /dev/null +++ b/queue-5.4/kernel-fs-introduce-and-use-set_restart_fn-and-arch_set_restart_data.patch @@ -0,0 +1,147 @@ +From 5abbe51a526253b9f003e9a0a195638dc882d660 Mon Sep 17 00:00:00 2001 +From: Oleg Nesterov +Date: Mon, 1 Feb 2021 18:46:41 +0100 +Subject: kernel, fs: Introduce and use set_restart_fn() and arch_set_restart_data() + +From: Oleg Nesterov + +commit 5abbe51a526253b9f003e9a0a195638dc882d660 upstream. + +Preparation for fixing get_nr_restart_syscall() on X86 for COMPAT. + +Add a new helper which sets restart_block->fn and calls a dummy +arch_set_restart_data() helper. + +Fixes: 609c19a385c8 ("x86/ptrace: Stop setting TS_COMPAT in ptrace code") +Signed-off-by: Oleg Nesterov +Signed-off-by: Thomas Gleixner +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20210201174641.GA17871@redhat.com +Signed-off-by: Greg Kroah-Hartman +--- + fs/select.c | 10 ++++------ + include/linux/thread_info.h | 13 +++++++++++++ + kernel/futex.c | 3 +-- + kernel/time/alarmtimer.c | 2 +- + kernel/time/hrtimer.c | 2 +- + kernel/time/posix-cpu-timers.c | 2 +- + 6 files changed, 21 insertions(+), 11 deletions(-) + +--- a/fs/select.c ++++ b/fs/select.c +@@ -1037,10 +1037,9 @@ static long do_restart_poll(struct resta + + ret = do_sys_poll(ufds, nfds, to); + +- if (ret == -ERESTARTNOHAND) { +- restart_block->fn = do_restart_poll; +- ret = -ERESTART_RESTARTBLOCK; +- } ++ if (ret == -ERESTARTNOHAND) ++ ret = set_restart_fn(restart_block, do_restart_poll); ++ + return ret; + } + +@@ -1062,7 +1061,6 @@ SYSCALL_DEFINE3(poll, struct pollfd __us + struct restart_block *restart_block; + + restart_block = ¤t->restart_block; +- restart_block->fn = do_restart_poll; + restart_block->poll.ufds = ufds; + restart_block->poll.nfds = nfds; + +@@ -1073,7 +1071,7 @@ SYSCALL_DEFINE3(poll, struct pollfd __us + } else + restart_block->poll.has_timeout = 0; + +- ret = -ERESTART_RESTARTBLOCK; ++ ret = set_restart_fn(restart_block, do_restart_poll); + } + return ret; + } +--- a/include/linux/thread_info.h ++++ b/include/linux/thread_info.h +@@ -11,6 +11,7 @@ + #include + #include + #include ++#include + + #ifdef CONFIG_THREAD_INFO_IN_TASK + /* +@@ -39,6 +40,18 @@ enum { + + #ifdef __KERNEL__ + ++#ifndef arch_set_restart_data ++#define arch_set_restart_data(restart) do { } while (0) ++#endif ++ ++static inline long set_restart_fn(struct restart_block *restart, ++ long (*fn)(struct restart_block *)) ++{ ++ restart->fn = fn; ++ arch_set_restart_data(restart); ++ return -ERESTART_RESTARTBLOCK; ++} ++ + #ifndef THREAD_ALIGN + #define THREAD_ALIGN THREAD_SIZE + #endif +--- a/kernel/futex.c ++++ b/kernel/futex.c +@@ -2865,14 +2865,13 @@ retry: + goto out; + + restart = ¤t->restart_block; +- restart->fn = futex_wait_restart; + restart->futex.uaddr = uaddr; + restart->futex.val = val; + restart->futex.time = *abs_time; + restart->futex.bitset = bitset; + restart->futex.flags = flags | FLAGS_HAS_TIMEOUT; + +- ret = -ERESTART_RESTARTBLOCK; ++ ret = set_restart_fn(restart, futex_wait_restart); + + out: + if (to) { +--- a/kernel/time/alarmtimer.c ++++ b/kernel/time/alarmtimer.c +@@ -838,9 +838,9 @@ static int alarm_timer_nsleep(const cloc + if (flags == TIMER_ABSTIME) + return -ERESTARTNOHAND; + +- restart->fn = alarm_timer_nsleep_restart; + restart->nanosleep.clockid = type; + restart->nanosleep.expires = exp; ++ set_restart_fn(restart, alarm_timer_nsleep_restart); + return ret; + } + +--- a/kernel/time/hrtimer.c ++++ b/kernel/time/hrtimer.c +@@ -1953,9 +1953,9 @@ long hrtimer_nanosleep(const struct time + } + + restart = ¤t->restart_block; +- restart->fn = hrtimer_nanosleep_restart; + restart->nanosleep.clockid = t.timer.base->clockid; + restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); ++ set_restart_fn(restart, hrtimer_nanosleep_restart); + out: + destroy_hrtimer_on_stack(&t.timer); + return ret; +--- a/kernel/time/posix-cpu-timers.c ++++ b/kernel/time/posix-cpu-timers.c +@@ -1335,8 +1335,8 @@ static int posix_cpu_nsleep(const clocki + if (flags & TIMER_ABSTIME) + return -ERESTARTNOHAND; + +- restart_block->fn = posix_cpu_nsleep_restart; + restart_block->nanosleep.clockid = which_clock; ++ set_restart_fn(restart_block, posix_cpu_nsleep_restart); + } + return error; + } diff --git a/queue-5.4/series b/queue-5.4/series index cfe7d19e4ee..9177e4c53b3 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -49,5 +49,6 @@ counter-stm32-timer-cnt-fix-ceiling-write-max-value.patch pci-rpadlpar-fix-potential-drc_name-corruption-in-store-functions.patch perf-x86-intel-fix-a-crash-caused-by-zero-pebs-status.patch x86-ioapic-ignore-irq2-again.patch +kernel-fs-introduce-and-use-set_restart_fn-and-arch_set_restart_data.patch x86-move-ts_compat-back-to-asm-thread_info.h.patch x86-introduce-ts_compat_restart-to-fix-get_nr_restart_syscall.patch