linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT pull] locking/urgent for v5.10-rc2
@ 2020-11-01 13:56 Thomas Gleixner
  2020-11-01 13:56 ` [GIT pull] smp/urgent " Thomas Gleixner
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Thomas Gleixner @ 2020-11-01 13:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, x86

Linus,

please pull the latest locking/urgent branch from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-urgent-2020-11-01

up to:  1a39340865ce: lockdep: Fix nr_unused_locks accounting


A couple of locking fixes:

 - Fix incorrect failure injection handling on the fuxtex code

 - Prevent a preemption warning in lockdep when tracking local_irq_enable()
   and interrupts are already enabled

 - Remove more raw_cpu_read() usage from lockdep which causes state
   corruption on !X86 architectures.

 - Make the nr_unused_locks accounting in lockdep correct again.

Thanks,

	tglx

------------------>
Mateusz Nosek (1):
      futex: Fix incorrect should_fail_futex() handling

Peter Zijlstra (3):
      lockdep: Fix preemption WARN for spurious IRQ-enable
      locking/lockdep: Remove more raw_cpu_read() usage
      lockdep: Fix nr_unused_locks accounting


 kernel/futex.c           |  4 +++-
 kernel/locking/lockdep.c | 20 +++++++-------------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index a5876694a60e..39681bf8b06c 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1502,8 +1502,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_
 	 */
 	newval = FUTEX_WAITERS | task_pid_vnr(new_owner);
 
-	if (unlikely(should_fail_futex(true)))
+	if (unlikely(should_fail_futex(true))) {
 		ret = -EFAULT;
+		goto out_unlock;
+	}
 
 	ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval);
 	if (!ret && (curval != uval)) {
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 3e99dfef8408..b71ad8d9f1c9 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -84,7 +84,7 @@ static inline bool lockdep_enabled(void)
 	if (!debug_locks)
 		return false;
 
-	if (raw_cpu_read(lockdep_recursion))
+	if (this_cpu_read(lockdep_recursion))
 		return false;
 
 	if (current->lockdep_recursion)
@@ -4057,7 +4057,7 @@ void lockdep_hardirqs_on_prepare(unsigned long ip)
 	if (unlikely(in_nmi()))
 		return;
 
-	if (unlikely(__this_cpu_read(lockdep_recursion)))
+	if (unlikely(this_cpu_read(lockdep_recursion)))
 		return;
 
 	if (unlikely(lockdep_hardirqs_enabled())) {
@@ -4126,7 +4126,7 @@ void noinstr lockdep_hardirqs_on(unsigned long ip)
 		goto skip_checks;
 	}
 
-	if (unlikely(__this_cpu_read(lockdep_recursion)))
+	if (unlikely(this_cpu_read(lockdep_recursion)))
 		return;
 
 	if (lockdep_hardirqs_enabled()) {
@@ -4396,6 +4396,9 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
 	if (unlikely(hlock_class(this)->usage_mask & new_mask))
 		goto unlock;
 
+	if (!hlock_class(this)->usage_mask)
+		debug_atomic_dec(nr_unused_locks);
+
 	hlock_class(this)->usage_mask |= new_mask;
 
 	if (new_bit < LOCK_TRACE_STATES) {
@@ -4403,19 +4406,10 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
 			return 0;
 	}
 
-	switch (new_bit) {
-	case 0 ... LOCK_USED-1:
+	if (new_bit < LOCK_USED) {
 		ret = mark_lock_irq(curr, this, new_bit);
 		if (!ret)
 			return 0;
-		break;
-
-	case LOCK_USED:
-		debug_atomic_dec(nr_unused_locks);
-		break;
-
-	default:
-		break;
 	}
 
 unlock:


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [GIT pull] smp/urgent for v5.10-rc2
  2020-11-01 13:56 [GIT pull] locking/urgent for v5.10-rc2 Thomas Gleixner
@ 2020-11-01 13:56 ` Thomas Gleixner
  2020-11-01 19:27   ` pr-tracker-bot
  2020-11-01 13:56 ` [GIT pull] timers/urgent " Thomas Gleixner
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Thomas Gleixner @ 2020-11-01 13:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, x86

Linus,

please pull the latest smp/urgent branch from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git smp-urgent-2020-11-01

up to:  4230e2deaa48: stop_machine, rcu: Mark functions as notrace


A single fix for stop machine. Mark functions no trace to prevent a crash
caused by recursion when enabling or disabling a tracer on RISC-V (probably
all architectures which patch through stop machine).


Thanks,

	tglx

------------------>
Zong Li (1):
      stop_machine, rcu: Mark functions as notrace


 kernel/rcu/tree.c     | 2 +-
 kernel/stop_machine.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 06895ef85d69..2a52f42f64b6 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -409,7 +409,7 @@ bool rcu_eqs_special_set(int cpu)
  *
  * The caller must have disabled interrupts and must not be idle.
  */
-void rcu_momentary_dyntick_idle(void)
+notrace void rcu_momentary_dyntick_idle(void)
 {
 	int special;
 
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 865bb0228ab6..890b79cf0e7c 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -178,7 +178,7 @@ static void ack_state(struct multi_stop_data *msdata)
 		set_state(msdata, msdata->state + 1);
 }
 
-void __weak stop_machine_yield(const struct cpumask *cpumask)
+notrace void __weak stop_machine_yield(const struct cpumask *cpumask)
 {
 	cpu_relax();
 }


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [GIT pull] timers/urgent for v5.10-rc2
  2020-11-01 13:56 [GIT pull] locking/urgent for v5.10-rc2 Thomas Gleixner
  2020-11-01 13:56 ` [GIT pull] smp/urgent " Thomas Gleixner
@ 2020-11-01 13:56 ` Thomas Gleixner
  2020-11-01 19:27   ` pr-tracker-bot
  2020-11-01 13:56 ` [GIT pull] x86/urgent " Thomas Gleixner
  2020-11-01 19:27 ` [GIT pull] locking/urgent " pr-tracker-bot
  3 siblings, 1 reply; 8+ messages in thread
From: Thomas Gleixner @ 2020-11-01 13:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, x86

Linus,

please pull the latest timers/urgent branch from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-urgent-2020-11-01

up to:  cb47755725da: time: Prevent undefined behaviour in timespec64_to_ns()


A few fixes for timers/timekeeping:

  - Prevent undefined behaviour in the timespec64_to_ns() conversion which
    is used for converting user supplied time input to nanoseconds. It
    lacked overflow protection.

  - Mark sched_clock_read_begin/retry() to prevent recursion in the tracer

  - Remove unused debug functions in the hrtimer and timerlist code


Thanks,

	tglx

------------------>
Quanyang Wang (1):
      time/sched_clock: Mark sched_clock_read_begin/retry() as notrace

YueHaibing (2):
      hrtimer: Remove unused inline function debug_hrtimer_free()
      timers: Remove unused inline funtion debug_timer_free()

Zeng Tao (1):
      time: Prevent undefined behaviour in timespec64_to_ns()


 include/linux/time64.h    | 4 ++++
 kernel/time/hrtimer.c     | 5 -----
 kernel/time/itimer.c      | 4 ----
 kernel/time/sched_clock.c | 4 ++--
 kernel/time/timer.c       | 5 -----
 5 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/include/linux/time64.h b/include/linux/time64.h
index c9dcb3e5781f..5117cb5b5656 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -124,6 +124,10 @@ static inline bool timespec64_valid_settod(const struct timespec64 *ts)
  */
 static inline s64 timespec64_to_ns(const struct timespec64 *ts)
 {
+	/* Prevent multiplication overflow */
+	if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX)
+		return KTIME_MAX;
+
 	return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
 }
 
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 3624b9b5835d..387b4bef7dd1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -425,11 +425,6 @@ static inline void debug_hrtimer_deactivate(struct hrtimer *timer)
 	debug_object_deactivate(timer, &hrtimer_debug_descr);
 }
 
-static inline void debug_hrtimer_free(struct hrtimer *timer)
-{
-	debug_object_free(timer, &hrtimer_debug_descr);
-}
-
 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
 			   enum hrtimer_mode mode);
 
diff --git a/kernel/time/itimer.c b/kernel/time/itimer.c
index ca4e6d57d68b..00629e658ca1 100644
--- a/kernel/time/itimer.c
+++ b/kernel/time/itimer.c
@@ -172,10 +172,6 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
 	u64 oval, nval, ointerval, ninterval;
 	struct cpu_itimer *it = &tsk->signal->it[clock_id];
 
-	/*
-	 * Use the to_ktime conversion because that clamps the maximum
-	 * value to KTIME_MAX and avoid multiplication overflows.
-	 */
 	nval = timespec64_to_ns(&value->it_value);
 	ninterval = timespec64_to_ns(&value->it_interval);
 
diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index 0642013dace4..b1b9b12899f5 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -68,13 +68,13 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift)
 	return (cyc * mult) >> shift;
 }
 
-struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
+notrace struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
 {
 	*seq = raw_read_seqcount_latch(&cd.seq);
 	return cd.read_data + (*seq & 1);
 }
 
-int sched_clock_read_retry(unsigned int seq)
+notrace int sched_clock_read_retry(unsigned int seq)
 {
 	return read_seqcount_latch_retry(&cd.seq, seq);
 }
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index de37e33a868d..c3ad64fb9d8b 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -732,11 +732,6 @@ static inline void debug_timer_deactivate(struct timer_list *timer)
 	debug_object_deactivate(timer, &timer_debug_descr);
 }
 
-static inline void debug_timer_free(struct timer_list *timer)
-{
-	debug_object_free(timer, &timer_debug_descr);
-}
-
 static inline void debug_timer_assert_init(struct timer_list *timer)
 {
 	debug_object_assert_init(timer, &timer_debug_descr);


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [GIT pull] x86/urgent for v5.10-rc2
  2020-11-01 13:56 [GIT pull] locking/urgent for v5.10-rc2 Thomas Gleixner
  2020-11-01 13:56 ` [GIT pull] smp/urgent " Thomas Gleixner
  2020-11-01 13:56 ` [GIT pull] timers/urgent " Thomas Gleixner
@ 2020-11-01 13:56 ` Thomas Gleixner
  2020-11-01 19:27   ` pr-tracker-bot
  2020-11-01 19:27 ` [GIT pull] locking/urgent " pr-tracker-bot
  3 siblings, 1 reply; 8+ messages in thread
From: Thomas Gleixner @ 2020-11-01 13:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, x86

Linus,

please pull the latest x86/urgent branch from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-2020-11-01

up to:  cb05143bdf42: x86/debug: Fix DR_STEP vs ptrace_get_debugreg(6)


Three fixes all related to #DB:

 - Handle the BTF bit correctly so it doesn't get lost due to a kernel #DB

 - Only clear and set the virtual DR6 value used by ptrace on user space
   triggered #DB. A kernel #DB must leave it alone to ensure data
   consistency for ptrace.

 - Make the bitmasking of the virtual DR6 storage correct so it does not
   lose DR_STEP.


Thanks,

	tglx

------------------>
Peter Zijlstra (3):
      x86/debug: Fix BTF handling
      x86/debug: Only clear/set ->virtual_dr6 for userspace #DB
      x86/debug: Fix DR_STEP vs ptrace_get_debugreg(6)


 arch/x86/kernel/traps.c | 43 ++++++++++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 3c70fb34028b..e19df6cde35d 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -793,19 +793,6 @@ static __always_inline unsigned long debug_read_clear_dr6(void)
 	set_debugreg(DR6_RESERVED, 6);
 	dr6 ^= DR6_RESERVED; /* Flip to positive polarity */
 
-	/*
-	 * Clear the virtual DR6 value, ptrace routines will set bits here for
-	 * things we want signals for.
-	 */
-	current->thread.virtual_dr6 = 0;
-
-	/*
-	 * The SDM says "The processor clears the BTF flag when it
-	 * generates a debug exception."  Clear TIF_BLOCKSTEP to keep
-	 * TIF_BLOCKSTEP in sync with the hardware BTF flag.
-	 */
-	clear_thread_flag(TIF_BLOCKSTEP);
-
 	return dr6;
 }
 
@@ -873,6 +860,20 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
 	 */
 	WARN_ON_ONCE(user_mode(regs));
 
+	if (test_thread_flag(TIF_BLOCKSTEP)) {
+		/*
+		 * The SDM says "The processor clears the BTF flag when it
+		 * generates a debug exception." but PTRACE_BLOCKSTEP requested
+		 * it for userspace, but we just took a kernel #DB, so re-set
+		 * BTF.
+		 */
+		unsigned long debugctl;
+
+		rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
+		debugctl |= DEBUGCTLMSR_BTF;
+		wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
+	}
+
 	/*
 	 * Catch SYSENTER with TF set and clear DR_STEP. If this hit a
 	 * watchpoint at the same time then that will still be handled.
@@ -935,6 +936,22 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
 	irqentry_enter_from_user_mode(regs);
 	instrumentation_begin();
 
+	/*
+	 * Start the virtual/ptrace DR6 value with just the DR_STEP mask
+	 * of the real DR6. ptrace_triggered() will set the DR_TRAPn bits.
+	 *
+	 * Userspace expects DR_STEP to be visible in ptrace_get_debugreg(6)
+	 * even if it is not the result of PTRACE_SINGLESTEP.
+	 */
+	current->thread.virtual_dr6 = (dr6 & DR_STEP);
+
+	/*
+	 * The SDM says "The processor clears the BTF flag when it
+	 * generates a debug exception."  Clear TIF_BLOCKSTEP to keep
+	 * TIF_BLOCKSTEP in sync with the hardware BTF flag.
+	 */
+	clear_thread_flag(TIF_BLOCKSTEP);
+
 	/*
 	 * If dr6 has no reason to give us about the origin of this trap,
 	 * then it's very likely the result of an icebp/int01 trap.


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [GIT pull] timers/urgent for v5.10-rc2
  2020-11-01 13:56 ` [GIT pull] timers/urgent " Thomas Gleixner
@ 2020-11-01 19:27   ` pr-tracker-bot
  0 siblings, 0 replies; 8+ messages in thread
From: pr-tracker-bot @ 2020-11-01 19:27 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Linus Torvalds, linux-kernel, x86

The pull request you sent on Sun, 01 Nov 2020 13:56:03 -0000:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-urgent-2020-11-01

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/4312e0e8d3eab027d9506db091eb10e6a9ff25d3

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [GIT pull] x86/urgent for v5.10-rc2
  2020-11-01 13:56 ` [GIT pull] x86/urgent " Thomas Gleixner
@ 2020-11-01 19:27   ` pr-tracker-bot
  0 siblings, 0 replies; 8+ messages in thread
From: pr-tracker-bot @ 2020-11-01 19:27 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Linus Torvalds, linux-kernel, x86

The pull request you sent on Sun, 01 Nov 2020 13:56:04 -0000:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-2020-11-01

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/7b56fbd83e261484da43f04090bce07570bd117f

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [GIT pull] smp/urgent for v5.10-rc2
  2020-11-01 13:56 ` [GIT pull] smp/urgent " Thomas Gleixner
@ 2020-11-01 19:27   ` pr-tracker-bot
  0 siblings, 0 replies; 8+ messages in thread
From: pr-tracker-bot @ 2020-11-01 19:27 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Linus Torvalds, linux-kernel, x86

The pull request you sent on Sun, 01 Nov 2020 13:56:02 -0000:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git smp-urgent-2020-11-01

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/82423b46fc9ec699a0ede9e025a8414658cdcf48

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [GIT pull] locking/urgent for v5.10-rc2
  2020-11-01 13:56 [GIT pull] locking/urgent for v5.10-rc2 Thomas Gleixner
                   ` (2 preceding siblings ...)
  2020-11-01 13:56 ` [GIT pull] x86/urgent " Thomas Gleixner
@ 2020-11-01 19:27 ` pr-tracker-bot
  3 siblings, 0 replies; 8+ messages in thread
From: pr-tracker-bot @ 2020-11-01 19:27 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Linus Torvalds, linux-kernel, x86

The pull request you sent on Sun, 01 Nov 2020 13:56:01 -0000:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-urgent-2020-11-01

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/8d99084efcc21bb4e2bc4d818f41a27768d48f6e

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-01 19:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-01 13:56 [GIT pull] locking/urgent for v5.10-rc2 Thomas Gleixner
2020-11-01 13:56 ` [GIT pull] smp/urgent " Thomas Gleixner
2020-11-01 19:27   ` pr-tracker-bot
2020-11-01 13:56 ` [GIT pull] timers/urgent " Thomas Gleixner
2020-11-01 19:27   ` pr-tracker-bot
2020-11-01 13:56 ` [GIT pull] x86/urgent " Thomas Gleixner
2020-11-01 19:27   ` pr-tracker-bot
2020-11-01 19:27 ` [GIT pull] locking/urgent " pr-tracker-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).