Skip to content

Commit 168829a

Browse files
committed
Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking updates from Ingo Molnar: "The main changes in this cycle were: - A comprehensive rewrite of the robust/PI futex code's exit handling to fix various exit races. (Thomas Gleixner et al) - Rework the generic REFCOUNT_FULL implementation using atomic_fetch_* operations so that the performance impact of the cmpxchg() loops is mitigated for common refcount operations. With these performance improvements the generic implementation of refcount_t should be good enough for everybody - and this got confirmed by performance testing, so remove ARCH_HAS_REFCOUNT and REFCOUNT_FULL entirely, leaving the generic implementation enabled unconditionally. (Will Deacon) - Other misc changes, fixes, cleanups" * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (27 commits) lkdtm: Remove references to CONFIG_REFCOUNT_FULL locking/refcount: Remove unused 'refcount_error_report()' function locking/refcount: Consolidate implementations of refcount_t locking/refcount: Consolidate REFCOUNT_{MAX,SATURATED} definitions locking/refcount: Move saturation warnings out of line locking/refcount: Improve performance of generic REFCOUNT_FULL code locking/refcount: Move the bulk of the REFCOUNT_FULL implementation into the <linux/refcount.h> header locking/refcount: Remove unused refcount_*_checked() variants locking/refcount: Ensure integer operands are treated as signed locking/refcount: Define constants for saturation and max refcount values futex: Prevent exit livelock futex: Provide distinct return value when owner is exiting futex: Add mutex around futex exit futex: Provide state handling for exec() as well futex: Sanitize exit state handling futex: Mark the begin of futex exit explicitly futex: Set task::futex_state to DEAD right after handling futex exit futex: Split futex_mm_release() for exit/exec exit/exec: Seperate mm_release() futex: Replace PF_EXITPIDONE with a state ...
2 parents 1ae7878 + 500543c commit 168829a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+686
-716
lines changed

arch/Kconfig

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -892,27 +892,6 @@ config STRICT_MODULE_RWX
892892
config ARCH_HAS_PHYS_TO_DMA
893893
bool
894894

895-
config ARCH_HAS_REFCOUNT
896-
bool
897-
help
898-
An architecture selects this when it has implemented refcount_t
899-
using open coded assembly primitives that provide an optimized
900-
refcount_t implementation, possibly at the expense of some full
901-
refcount state checks of CONFIG_REFCOUNT_FULL=y.
902-
903-
The refcount overflow check behavior, however, must be retained.
904-
Catching overflows is the primary security concern for protecting
905-
against bugs in reference counts.
906-
907-
config REFCOUNT_FULL
908-
bool "Perform full reference count validation at the expense of speed"
909-
help
910-
Enabling this switches the refcounting infrastructure from a fast
911-
unchecked atomic_t implementation to a fully state checked
912-
implementation, which can be (slightly) slower but provides protections
913-
against various use-after-free conditions that can be used in
914-
security flaw exploits.
915-
916895
config HAVE_ARCH_COMPILER_H
917896
bool
918897
help

arch/arm/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ config ARM
117117
select OLD_SIGSUSPEND3
118118
select PCI_SYSCALL if PCI
119119
select PERF_USE_VMALLOC
120-
select REFCOUNT_FULL
121120
select RTC_LIB
122121
select SYS_SUPPORTS_APM_EMULATION
123122
# Above selects are sorted alphabetically; please add new ones

arch/arm64/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ config ARM64
182182
select PCI_SYSCALL if PCI
183183
select POWER_RESET
184184
select POWER_SUPPLY
185-
select REFCOUNT_FULL
186185
select SPARSE_IRQ
187186
select SWIOTLB
188187
select SYSCTL_EXCEPTION_TRACE

arch/s390/configs/debug_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ CONFIG_OPROFILE=m
6262
CONFIG_KPROBES=y
6363
CONFIG_JUMP_LABEL=y
6464
CONFIG_STATIC_KEYS_SELFTEST=y
65-
CONFIG_REFCOUNT_FULL=y
6665
CONFIG_LOCK_EVENT_COUNTS=y
6766
CONFIG_MODULES=y
6867
CONFIG_MODULE_FORCE_LOAD=y

arch/x86/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ config X86
7373
select ARCH_HAS_PMEM_API if X86_64
7474
select ARCH_HAS_PTE_DEVMAP if X86_64
7575
select ARCH_HAS_PTE_SPECIAL
76-
select ARCH_HAS_REFCOUNT
7776
select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64
7877
select ARCH_HAS_UACCESS_MCSAFE if X86_64 && X86_MCE
7978
select ARCH_HAS_SET_MEMORY

arch/x86/include/asm/asm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@
141141
# define _ASM_EXTABLE_EX(from, to) \
142142
_ASM_EXTABLE_HANDLE(from, to, ex_handler_ext)
143143

144-
# define _ASM_EXTABLE_REFCOUNT(from, to) \
145-
_ASM_EXTABLE_HANDLE(from, to, ex_handler_refcount)
146-
147144
# define _ASM_NOKPROBE(entry) \
148145
.pushsection "_kprobe_blacklist","aw" ; \
149146
_ASM_ALIGN ; \
@@ -172,9 +169,6 @@
172169
# define _ASM_EXTABLE_EX(from, to) \
173170
_ASM_EXTABLE_HANDLE(from, to, ex_handler_ext)
174171

175-
# define _ASM_EXTABLE_REFCOUNT(from, to) \
176-
_ASM_EXTABLE_HANDLE(from, to, ex_handler_refcount)
177-
178172
/* For C file, we already have NOKPROBE_SYMBOL macro */
179173
#endif
180174

arch/x86/include/asm/refcount.h

Lines changed: 0 additions & 126 deletions
This file was deleted.

arch/x86/mm/extable.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,6 @@ __visible bool ex_handler_fault(const struct exception_table_entry *fixup,
4444
}
4545
EXPORT_SYMBOL_GPL(ex_handler_fault);
4646

47-
/*
48-
* Handler for UD0 exception following a failed test against the
49-
* result of a refcount inc/dec/add/sub.
50-
*/
51-
__visible bool ex_handler_refcount(const struct exception_table_entry *fixup,
52-
struct pt_regs *regs, int trapnr,
53-
unsigned long error_code,
54-
unsigned long fault_addr)
55-
{
56-
/* First unconditionally saturate the refcount. */
57-
*(int *)regs->cx = INT_MIN / 2;
58-
59-
/*
60-
* Strictly speaking, this reports the fixup destination, not
61-
* the fault location, and not the actually overflowing
62-
* instruction, which is the instruction before the "js", but
63-
* since that instruction could be a variety of lengths, just
64-
* report the location after the overflow, which should be close
65-
* enough for finding the overflow, as it's at least back in
66-
* the function, having returned from .text.unlikely.
67-
*/
68-
regs->ip = ex_fixup_addr(fixup);
69-
70-
/*
71-
* This function has been called because either a negative refcount
72-
* value was seen by any of the refcount functions, or a zero
73-
* refcount value was seen by refcount_dec().
74-
*
75-
* If we crossed from INT_MAX to INT_MIN, OF (Overflow Flag: result
76-
* wrapped around) will be set. Additionally, seeing the refcount
77-
* reach 0 will set ZF (Zero Flag: result was zero). In each of
78-
* these cases we want a report, since it's a boundary condition.
79-
* The SF case is not reported since it indicates post-boundary
80-
* manipulations below zero or above INT_MAX. And if none of the
81-
* flags are set, something has gone very wrong, so report it.
82-
*/
83-
if (regs->flags & (X86_EFLAGS_OF | X86_EFLAGS_ZF)) {
84-
bool zero = regs->flags & X86_EFLAGS_ZF;
85-
86-
refcount_error_report(regs, zero ? "hit zero" : "overflow");
87-
} else if ((regs->flags & X86_EFLAGS_SF) == 0) {
88-
/* Report if none of OF, ZF, nor SF are set. */
89-
refcount_error_report(regs, "unexpected saturation");
90-
}
91-
92-
return true;
93-
}
94-
EXPORT_SYMBOL(ex_handler_refcount);
95-
9647
/*
9748
* Handler for when we fail to restore a task's FPU state. We should never get
9849
* here because the FPU state of a task using the FPU (task->thread.fpu.state)

drivers/gpu/drm/drm_connector.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ void drm_connector_list_iter_end(struct drm_connector_list_iter *iter)
719719
__drm_connector_put_safe(iter->conn);
720720
spin_unlock_irqrestore(&config->connector_list_lock, flags);
721721
}
722-
lock_release(&connector_list_iter_dep_map, 0, _RET_IP_);
722+
lock_release(&connector_list_iter_dep_map, _RET_IP_);
723723
}
724724
EXPORT_SYMBOL(drm_connector_list_iter_end);
725725

drivers/gpu/drm/i915/Kconfig.debug

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ config DRM_I915_DEBUG
2222
depends on DRM_I915
2323
select DEBUG_FS
2424
select PREEMPT_COUNT
25-
select REFCOUNT_FULL
2625
select I2C_CHARDEV
2726
select STACKDEPOT
2827
select DRM_DP_AUX_CHARDEV

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,14 @@ void i915_gem_shrinker_taints_mutex(struct drm_i915_private *i915,
509509
I915_MM_SHRINKER, 0, _RET_IP_);
510510

511511
mutex_acquire(&mutex->dep_map, 0, 0, _RET_IP_);
512-
mutex_release(&mutex->dep_map, 0, _RET_IP_);
512+
mutex_release(&mutex->dep_map, _RET_IP_);
513513

514-
mutex_release(&i915->drm.struct_mutex.dep_map, 0, _RET_IP_);
514+
mutex_release(&i915->drm.struct_mutex.dep_map, _RET_IP_);
515515

516516
fs_reclaim_release(GFP_KERNEL);
517517

518518
if (unlock)
519-
mutex_release(&i915->drm.struct_mutex.dep_map, 0, _RET_IP_);
519+
mutex_release(&i915->drm.struct_mutex.dep_map, _RET_IP_);
520520
}
521521

522522
#define obj_to_i915(obj__) to_i915((obj__)->base.dev)

drivers/gpu/drm/i915/gt/intel_engine_pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static inline unsigned long __timeline_mark_lock(struct intel_context *ce)
5252
static inline void __timeline_mark_unlock(struct intel_context *ce,
5353
unsigned long flags)
5454
{
55-
mutex_release(&ce->timeline->mutex.dep_map, 0, _THIS_IP_);
55+
mutex_release(&ce->timeline->mutex.dep_map, _THIS_IP_);
5656
local_irq_restore(flags);
5757
}
5858

drivers/gpu/drm/i915/i915_request.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ long i915_request_wait(struct i915_request *rq,
14951495
dma_fence_remove_callback(&rq->fence, &wait.cb);
14961496

14971497
out:
1498-
mutex_release(&rq->engine->gt->reset.mutex.dep_map, 0, _THIS_IP_);
1498+
mutex_release(&rq->engine->gt->reset.mutex.dep_map, _THIS_IP_);
14991499
trace_i915_request_wait_end(rq);
15001500
return timeout;
15011501
}

drivers/misc/lkdtm/refcount.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
#include "lkdtm.h"
77
#include <linux/refcount.h>
88

9-
#ifdef CONFIG_REFCOUNT_FULL
10-
#define REFCOUNT_MAX (UINT_MAX - 1)
11-
#define REFCOUNT_SATURATED UINT_MAX
12-
#else
13-
#define REFCOUNT_MAX INT_MAX
14-
#define REFCOUNT_SATURATED (INT_MIN / 2)
15-
#endif
16-
179
static void overflow_check(refcount_t *ref)
1810
{
1911
switch (refcount_read(ref)) {
@@ -127,7 +119,7 @@ void lkdtm_REFCOUNT_DEC_ZERO(void)
127119
static void check_negative(refcount_t *ref, int start)
128120
{
129121
/*
130-
* CONFIG_REFCOUNT_FULL refuses to move a refcount at all on an
122+
* refcount_t refuses to move a refcount at all on an
131123
* over-sub, so we have to track our starting position instead of
132124
* looking only at zero-pinning.
133125
*/
@@ -210,7 +202,6 @@ static void check_from_zero(refcount_t *ref)
210202

211203
/*
212204
* A refcount_inc() from zero should pin to zero or saturate and may WARN.
213-
* Only CONFIG_REFCOUNT_FULL provides this protection currently.
214205
*/
215206
void lkdtm_REFCOUNT_INC_ZERO(void)
216207
{

drivers/tty/tty_ldsem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int __ldsem_down_read_nested(struct ld_semaphore *sem,
303303
if (count <= 0) {
304304
lock_contended(&sem->dep_map, _RET_IP_);
305305
if (!down_read_failed(sem, count, timeout)) {
306-
rwsem_release(&sem->dep_map, 1, _RET_IP_);
306+
rwsem_release(&sem->dep_map, _RET_IP_);
307307
return 0;
308308
}
309309
}
@@ -322,7 +322,7 @@ static int __ldsem_down_write_nested(struct ld_semaphore *sem,
322322
if ((count & LDSEM_ACTIVE_MASK) != LDSEM_ACTIVE_BIAS) {
323323
lock_contended(&sem->dep_map, _RET_IP_);
324324
if (!down_write_failed(sem, count, timeout)) {
325-
rwsem_release(&sem->dep_map, 1, _RET_IP_);
325+
rwsem_release(&sem->dep_map, _RET_IP_);
326326
return 0;
327327
}
328328
}
@@ -390,7 +390,7 @@ void ldsem_up_read(struct ld_semaphore *sem)
390390
{
391391
long count;
392392

393-
rwsem_release(&sem->dep_map, 1, _RET_IP_);
393+
rwsem_release(&sem->dep_map, _RET_IP_);
394394

395395
count = atomic_long_add_return(-LDSEM_READ_BIAS, &sem->count);
396396
if (count < 0 && (count & LDSEM_ACTIVE_MASK) == 0)
@@ -404,7 +404,7 @@ void ldsem_up_write(struct ld_semaphore *sem)
404404
{
405405
long count;
406406

407-
rwsem_release(&sem->dep_map, 1, _RET_IP_);
407+
rwsem_release(&sem->dep_map, _RET_IP_);
408408

409409
count = atomic_long_add_return(-LDSEM_WRITE_BIAS, &sem->count);
410410
if (count < 0)

fs/dcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ static void d_walk(struct dentry *parent, void *data,
13191319

13201320
if (!list_empty(&dentry->d_subdirs)) {
13211321
spin_unlock(&this_parent->d_lock);
1322-
spin_release(&dentry->d_lock.dep_map, 1, _RET_IP_);
1322+
spin_release(&dentry->d_lock.dep_map, _RET_IP_);
13231323
this_parent = dentry;
13241324
spin_acquire(&this_parent->d_lock.dep_map, 0, 1, _RET_IP_);
13251325
goto repeat;

0 commit comments

Comments
 (0)