xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/xen: only unlock when USE_SPLIT_PTE_PTLOCKS is true
@ 2020-09-29  6:48 Jason Yan
  2020-09-29  7:32 ` Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Yan @ 2020-09-29  6:48 UTC (permalink / raw)
  To: boris.ostrovsky, jgross, sstabellini, tglx, mingo, bp, x86, hpa,
	xen-devel
  Cc: Jason Yan

When USE_SPLIT_PTE_PTLOCKS is false, xen_pte_lock() actually do nothing
but returns NULL. So xen_pte_unlock() should not actually unlock.
Otherwise a NULL pointer dereference will be triggered.

Fixes: 74260714c56d ("xen: lock pte pages while pinning/unpinning")
Signed-off-by: Jason Yan <yanaijie@huawei.com>
---
 arch/x86/xen/mmu_pv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
index eda78144c000..c70cbdf5c0fa 100644
--- a/arch/x86/xen/mmu_pv.c
+++ b/arch/x86/xen/mmu_pv.c
@@ -656,8 +656,10 @@ static spinlock_t *xen_pte_lock(struct page *page, struct mm_struct *mm)
 
 static void xen_pte_unlock(void *v)
 {
+#if USE_SPLIT_PTE_PTLOCKS
 	spinlock_t *ptl = v;
 	spin_unlock(ptl);
+#endif
 }
 
 static void xen_do_pin(unsigned level, unsigned long pfn)
-- 
2.25.4



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

* Re: [PATCH] x86/xen: only unlock when USE_SPLIT_PTE_PTLOCKS is true
  2020-09-29  6:48 [PATCH] x86/xen: only unlock when USE_SPLIT_PTE_PTLOCKS is true Jason Yan
@ 2020-09-29  7:32 ` Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2020-09-29  7:32 UTC (permalink / raw)
  To: Jason Yan
  Cc: boris.ostrovsky, jgross, sstabellini, tglx, mingo, bp, x86, hpa,
	xen-devel

On 29.09.2020 08:48, Jason Yan wrote:
> When USE_SPLIT_PTE_PTLOCKS is false, xen_pte_lock() actually do nothing
> but returns NULL. So xen_pte_unlock() should not actually unlock.
> Otherwise a NULL pointer dereference will be triggered.
> 
> Fixes: 74260714c56d ("xen: lock pte pages while pinning/unpinning")

I neither see any breakage this commit introduces, nor any NULL
deref. Both calls to (or arrangements to call) xen_pte_unlock() are
guarded by a check of the pointer to be non-NULL. Therefore if
anything this is a cosmetic change, which the description should
express, and which should have no Fixes: tag. (I would guess the
intention back then was to avoid #ifdef-ary where possible, at the
expense of a little bit of dead code.)

Jan


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

end of thread, other threads:[~2020-09-29  7:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29  6:48 [PATCH] x86/xen: only unlock when USE_SPLIT_PTE_PTLOCKS is true Jason Yan
2020-09-29  7:32 ` Jan Beulich

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).