Revert "dm bufio: fix deadlock with loop device"
Subsystems (9)
Sasha Levin
maintainerPATCH 1/6 Revert "dm bufio: fix deadlock with loop device"
From: Mikulas Patocka <[email protected]>
[ Upstream commit cf3591ef832915892f2499b7e54b51d4c578b28c ]
Revert the commit bd293d071ffe65e645b4d8104f9d8fe15ea13862. The proper fix has been made available with commit d0a255e795ab ("loop: set PF_MEMALLOC_NOIO for the worker thread").
Note that the fix offered by commit bd293d071ffe doesn't really prevent the deadlock from occuring - if we look at the stacktrace reported by Junxiao Bi, we see that it hangs in bit_wait_io and not on the mutex - i.e. it has already successfully taken the mutex. Changing the mutex from mutex_lock to mutex_trylock won't help with deadlocks that happen afterwards.
PID: 474 TASK: ffff8813e11f4600 CPU: 10 COMMAND: "kswapd0"
#0 [ffff8813dedfb938] __schedule at ffffffff8173f405
#1 [ffff8813dedfb990] schedule at ffffffff8173fa27
#2 [ffff8813dedfb9b0] schedule_timeout at ffffffff81742fec
#3 [ffff8813dedfba60] io_schedule_timeout at ffffffff8173f186 #4 [ffff8813dedfbaa0] bit_wait_io at ffffffff8174034f
#5 [ffff8813dedfbac0] __wait_on_bit at ffffffff8173fec8
#6 [ffff8813dedfbb10] out_of_line_wait_on_bit at ffffffff8173ff81 #7 [ffff8813dedfbb90] __make_buffer_clean at ffffffffa038736f [dm_bufio] #8 [ffff8813dedfbbb0] __try_evict_buffer at ffffffffa0387bb8 [dm_bufio] #9 [ffff8813dedfbbd0] dm_bufio_shrink_scan at ffffffffa0387cc3 [dm_bufio]
#10 [ffff8813dedfbc40] shrink_slab at ffffffff811a87ce
#11 [ffff8813dedfbd30] shrink_zone at ffffffff811ad778
#12 [ffff8813dedfbdc0] kswapd at ffffffff811ae92f
#13 [ffff8813dedfbec0] kthread at ffffffff810a8428
#14 [ffff8813dedfbf50] ret_from_fork at ffffffff81745242
Depends-on: d0a255e795ab ("loop: set PF_MEMALLOC_NOIO for the worker thread")
--- drivers/md/dm-bufio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/dm-bufio.c +3 -1
@@ -1561,7 +1561,9 @@ dm_bufio_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)unsigned long freed; c = container_of(shrink, struct dm_bufio_client, shrinker); -if (!dm_bufio_trylock (c)) +if (sc->gfp_mask & __GFP_FS) +dm_bufio_lock (c); +else if (!dm_bufio_trylock (c))return SHRINK_STOP ; freed =__scan (c, sc->nr_to_scan, sc->gfp_mask);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/6 userfaultfd_release: always remove uffd flags and clear vm_userfaultfd_ctx
From: Oleg Nesterov <[email protected]>
[ Upstream commit 46d0b24c5ee10a15dfb25e20642f5a5ed59c5003 ]
userfaultfd_release() should clear vm_flags/vm_userfaultfd_ctx even if mm->core_state != NULL.
Otherwise a page fault can see userfaultfd_missing() == T and use an already freed userfaultfd_ctx.
--- fs/userfaultfd.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
fs/userfaultfd.c +13 -12
@@ -431,6 +431,7 @@ static int userfaultfd_release(struct inode *inode, struct file *file)/* len == 0 means wake all */ struct userfaultfd_wake_range range = { .len =0 , };unsigned long new_flags; +bool still_valid;ACCESS_ONCE (ctx->released) = true;
@@ -446,8 +447,7 @@ static int userfaultfd_release(struct inode *inode, struct file *file)* taking the mmap_sem for writing. */ down_write (&mm->mmap_sem); -if (!mmget_still_valid (mm)) - goto skip_mm; + still_valid =mmget_still_valid (mm); prev =NULL ;for (vma = mm->mmap; vma; vma = vma->vm_next) {cond_resched ();
@@ -458,19 +458,20 @@ static int userfaultfd_release(struct inode *inode, struct file *file)continue ; } new_flags = vma->vm_flags & ~(VM_UFFD_MISSING |VM_UFFD_WP ); - prev =vma_merge (mm, prev, vma->vm_start, vma->vm_end, - new_flags, vma->anon_vma, - vma->vm_file, vma->vm_pgoff, -vma_policy (vma), -NULL_VM_UFFD_CTX ); -if (prev) - vma = prev; -else - prev = vma; +if (still_valid) { + prev =vma_merge (mm, prev, vma->vm_start, vma->vm_end, + new_flags, vma->anon_vma, + vma->vm_file, vma->vm_pgoff, +vma_policy (vma), +NULL_VM_UFFD_CTX ); +if (prev) + vma = prev; +else + prev = vma; + } vma->vm_flags = new_flags; vma->vm_userfaultfd_ctx =NULL_VM_UFFD_CTX ; } -skip_mm:up_write (&mm->mmap_sem);mmput (mm); wakeup:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/6 mac80211: fix possible sta leak
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 5fd2f91ad483baffdbe798f8a08f1b41442d1e24 ]
If TDLS station addition is rejected, the sta memory is leaked. Avoid this by moving the check before the allocation.
--- net/mac80211/cfg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/mac80211/cfg.c +5 -4
@@ -1211,6 +1211,11 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,if (is_multicast_ether_addr (mac))return -EINVAL ; +if (params->sta_flags_set &BIT (NL80211_STA_FLAG_TDLS_PEER ) && + sdata->vif.type ==NL80211_IFTYPE_STATION && + !sdata->u.mgd.associated) +return -EINVAL ; + sta =sta_info_alloc (sdata, mac,GFP_KERNEL );if (!sta)return -ENOMEM ;
@@ -1228,10 +1233,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,if (params->sta_flags_set &BIT (NL80211_STA_FLAG_TDLS_PEER )) sta->sta.tdls = true; -if (sta->sta.tdls && sdata->vif.type ==NL80211_IFTYPE_STATION && - !sdata->u.mgd.associated) -return -EINVAL ; - err =sta_apply_parameters (local, sta, params);if (err) {sta_info_free (local, sta);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/6 scripts/decode_stacktrace: match basepath using shell prefix operator, not regex
In reply to Sasha LevinFrom: Nicolas Boichat <[email protected]>
[ Upstream commit 31013836a71e07751a6827f9d2ad41ef502ddaff ]
The basepath may contain special characters, which would confuse the regex matcher. ${var#prefix} does the right thing.
--- scripts/decode_stacktrace.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/decode_stacktrace.sh +1 -1
@@ -64,7 +64,7 @@ parse_symbol() { fi # Strip out the base of the path - code=${code//^$basepath/""} + code=${code#$basepath/} # In the case of inlines, move everything to same line code=${code//$'\n'/' '}
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/6 KVM: arm/arm64: Only skip MMIO insn once
In reply to Sasha LevinFrom: Andrew Jones <[email protected]>
[ Upstream commit 2113c5f62b7423e4a72b890bd479704aa85c81ba ]
If after an MMIO exit to userspace a VCPU is immediately run with an immediate_exit request, such as when a signal is delivered or an MMIO emulation completion is needed, then the VCPU completes the MMIO emulation and immediately returns to userspace. As the exit_reason does not get changed from KVM_EXIT_MMIO in these cases we have to be careful not to complete the MMIO emulation again, when the VCPU is eventually run again, because the emulation does an instruction skip (and doing too many skips would be a waste of guest code :-) We need to use additional VCPU state to track if the emulation is complete. As luck would have it, we already have 'mmio_needed', which even appears to be used in this way by other architectures already.
--- arch/arm/kvm/mmio.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/kvm/mmio.c +7 -0
@@ -98,6 +98,12 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)unsigned int len;int mask; +/* Detect an already handled MMIO return */ +if (unlikely (!vcpu->mmio_needed)) +return 0 ; + + vcpu->mmio_needed =0 ; +if (!run->mmio.is_write) { len = run->mmio.len;if (len >sizeof (unsigned long ))
@@ -206,6 +212,7 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, run->mmio.is_write = is_write; run->mmio.phys_addr = fault_ipa; run->mmio.len = len; + vcpu->mmio_needed =1 ;if (!ret) {/* We handled the access successfully in the kernel. */
Signature · 6 lines
2.20.1 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Sasha Levin
maintainerPATCH 6/6 clk: s2mps11: Add used attribute to s2mps11_dt_match
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 9c940bbe2bb47e03ca5e937d30b6a50bf9c0e671 ]
Clang warns after commit 8985167ecf57 ("clk: s2mps11: Fix matching when built as module and DT node contains compatible"):
drivers/clk/clk-s2mps11.c:242:34: warning: variable 's2mps11_dt_match' is not needed and will not be emitted [-Wunneeded-internal-declaration]
static const struct of_device_id s2mps11_dt_match[] = {
^1 warning generated.
This warning happens when a variable is used in some construct that doesn't require a reference to that variable to be emitted in the symbol table; in this case, it's MODULE_DEVICE_TABLE, which only needs to hold the data of the variable, not the variable itself.
$ nm -S drivers/clk/clk-s2mps11.o | rg s2mps11_dt_match 00000078 000003d4 R __mod_of__s2mps11_dt_match_device_table
Normally, with device ID table variables, it means that the variable just needs to be tied to the device declaration at the bottom of the file, like s2mps11_clk_id:
$ nm -S drivers/clk/clk-s2mps11.o | rg s2mps11_clk_id 00000000 00000078 R __mod_platform__s2mps11_clk_id_device_table 00000000 00000078 r s2mps11_clk_id
However, because the comment above this deliberately doesn't want this variable added to .of_match_table, we need to mark s2mps11_dt_match as __used to silence this warning. This makes it clear to Clang that the variable is used for something, even if a reference to it isn't being emitted.
--- drivers/clk/clk-s2mps11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-s2mps11.c +1 -1
@@ -307,7 +307,7 @@ MODULE_DEVICE_TABLE(platform, s2mps11_clk_id);* This requires of_device_id table. In the same time this will not change the * actual *device* matching so do not add .of_match_table. */ -static const struct of_device_id s2mps11_dt_match[] = { +static const struct of_device_id s2mps11_dt_match[]__used = { { .compatible ="samsung,s2mps11-clk" , .data = (void *)S2MPS11X ,
Signature · 1 line
2.20.1