[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC PKS/PMEM 56/58] dax: Stray access protection for dax_direct_access()
 
- To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>,	Thomas Gleixner <tglx@xxxxxxxxxxxxx>,	Ingo Molnar <mingo@xxxxxxxxxx>,	Borislav Petkov <bp@xxxxxxxxx>,	Andy Lutomirski <luto@xxxxxxxxxx>,	Peter Zijlstra <peterz@xxxxxxxxxxxxx>
 
- From: ira.weiny@xxxxxxxxx
 
- Date: Fri,  9 Oct 2020 12:50:31 -0700
 
- Cc: Ira Weiny <ira.weiny@xxxxxxxxx>,	x86@xxxxxxxxxx,	Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>,	Dan Williams <dan.j.williams@xxxxxxxxx>,	Fenghua Yu <fenghua.yu@xxxxxxxxx>,	linux-doc@xxxxxxxxxxxxxxx,	linux-kernel@xxxxxxxxxxxxxxx,	linux-nvdimm@xxxxxxxxxxxx,	linux-fsdevel@xxxxxxxxxxxxxxx,	linux-mm@xxxxxxxxx,	linux-kselftest@xxxxxxxxxxxxxxx,	linuxppc-dev@xxxxxxxxxxxxxxxx,	kvm@xxxxxxxxxxxxxxx,	netdev@xxxxxxxxxxxxxxx,	bpf@xxxxxxxxxxxxxxx,	kexec@xxxxxxxxxxxxxxxxxxx,	linux-bcache@xxxxxxxxxxxxxxx,	linux-mtd@xxxxxxxxxxxxxxxxxxx,	devel@xxxxxxxxxxxxxxxxxxxx,	linux-efi@xxxxxxxxxxxxxxx,	linux-mmc@xxxxxxxxxxxxxxx,	linux-scsi@xxxxxxxxxxxxxxx,	target-devel@xxxxxxxxxxxxxxx,	linux-nfs@xxxxxxxxxxxxxxx,	ceph-devel@xxxxxxxxxxxxxxx,	linux-ext4@xxxxxxxxxxxxxxx,	linux-aio@xxxxxxxxx,	io-uring@xxxxxxxxxxxxxxx,	linux-erofs@xxxxxxxxxxxxxxxx,	linux-um@xxxxxxxxxxxxxxxxxxx,	linux-ntfs-dev@xxxxxxxxxxxxxxxxxxxxx,	reiserfs-devel@xxxxxxxxxxxxxxx,	linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx,	linux-nilfs@xxxxxxxxxxxxxxx,	cluster-devel@xxxxxxxxxx,	ecryptfs@xxxxxxxxxxxxxxx,	linux-cifs@xxxxxxxxxxxxxxx,	linux-btrfs@xxxxxxxxxxxxxxx,	linux-afs@xxxxxxxxxxxxxxxxxxx,	linux-rdma@xxxxxxxxxxxxxxx,	amd-gfx@xxxxxxxxxxxxxxxxxxxxx,	dri-devel@xxxxxxxxxxxxxxxxxxxxx,	intel-gfx@xxxxxxxxxxxxxxxxxxxxx,	drbd-dev@xxxxxxxxxxxxxxxx,	linux-block@xxxxxxxxxxxxxxx,	xen-devel@xxxxxxxxxxxxxxxxxxxx,	linux-cachefs@xxxxxxxxxx,	samba-technical@xxxxxxxxxxxxxxx,	intel-wired-lan@xxxxxxxxxxxxxxxx
 
- Delivery-date: Fri, 09 Oct 2020 19:54:09 +0000
 
- Ironport-sdr: c5c8lWx53OKNfJTf5ukBb57x4xGzHo3/RsCiYSxlMsrD0E9zKISdhlW1OfiP938gwC0kIn9Ony mzjXzkcVlXMQ==
 
- Ironport-sdr: NEiErKYZfPZGqrWyxIZ0z43ef9+IKjrcXd9NJIRckxXQwdDEMd5poh/dknsqhifod6Ym/UoaZd Mu4h9c7DJvbA==
 
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
 
 
 
From: Ira Weiny <ira.weiny@xxxxxxxxx>
dax_direct_access() is a special case of accessing pmem via a page
offset and without a struct page.
Because the dax driver is well aware of the special protections it has
mapped memory with, call dev_access_[en|dis]able() directly instead of
the unnecessary overhead of trying to get a page to kmap.
Similar to kmap, we leverage existing functions, dax_read_[un]lock(),
because they are already required to surround the use of the memory
returned from dax_direct_access().
Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx>
---
 drivers/dax/super.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index e84070b55463..0ddb3ee73e36 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -30,6 +30,7 @@ static DEFINE_SPINLOCK(dax_host_lock);
 
 int dax_read_lock(void)
 {
+       dev_access_enable(false);
        return srcu_read_lock(&dax_srcu);
 }
 EXPORT_SYMBOL_GPL(dax_read_lock);
@@ -37,6 +38,7 @@ EXPORT_SYMBOL_GPL(dax_read_lock);
 void dax_read_unlock(int id)
 {
        srcu_read_unlock(&dax_srcu, id);
+       dev_access_disable(false);
 }
 EXPORT_SYMBOL_GPL(dax_read_unlock);
 
-- 
2.28.0.rc0.12.gb6a658bd00c9
 
    
     |