Skip to contentSkip to conversation

powerpc/64s: Fix VAS mm use after free

PATCH Applied Nicholas Piggin 3 participants 3 messages Jun 7, 2023 – Jul 3, 2023 PowerPC

lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 powerpc/64s: Fix VAS mm use after free

The refcount on mm is dropped before the coprocessor is detached.

Fixes 7bc6f71bdff5f ("powerpc/vas: Define and use common vas_window struct")
Fixes b22f2d88e435c ("powerpc/pseries/vas: Integrate API with open/close windows")

---
How's this for fixing your vas_deallocate_window warning at radix_tlb.c:991 ?

I added a few new warnings in the TLB flush code recently which is why these new warns are showing up.

Thanks,
Nick

 arch/powerpc/platforms/powernv/vas-window.c | 2 +-
 arch/powerpc/platforms/pseries/vas.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/powernv/vas-window.c +1 -1
index 0072682531d8..b664838008c1 100644
@@ -1310,8 +1310,8 @@ int vas_win_close(struct vas_window *vwin)
 	/* if send window, drop reference to matching receive window */
 	if (window->tx_win) {
 		if (window->user_win) {
-			put_vas_user_win_ref(&vwin->task_ref);
 			mm_context_remove_vas_window(vwin->task_ref.mm);
+			put_vas_user_win_ref(&vwin->task_ref);
 		}
 		put_rx_win(window->rxwin);
 	}
arch/powerpc/platforms/pseries/vas.c +1 -1
index 513180467562..9a44a98ba342 100644
@@ -507,8 +507,8 @@ static int vas_deallocate_window(struct vas_window *vwin)
 	vascaps[win->win_type].nr_open_windows--;
 	mutex_unlock(&vas_pseries_mutex);
 
-	put_vas_user_win_ref(&vwin->task_ref);
 	mm_context_remove_vas_window(vwin->task_ref.mm);
+	put_vas_user_win_ref(&vwin->task_ref);
 
 	kfree(win);
 	return 0;
Signature · 1 line
2.40.1
Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Nicholas Piggin

The refcount on mm is dropped before the coprocessor is detached.

Fixes 7bc6f71bdff5f ("powerpc/vas: Define and use common vas_window struct")
Fixes b22f2d88e435c ("powerpc/pseries/vas: Integrate API with open/close windows")
Quoted 7 lines

---
How's this for fixing your vas_deallocate_window warning at radix_tlb.c:991 ?

I added a few new warnings in the TLB flush code recently which is why these new warns are showing up.

Thanks Nick. This fixes the reported warning.
Nx-gzip as well as mce error inject tests completed successfully.

- Sachin