Re: [PATCH] fs-verity: use kmap_local_page() instead of kmap()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 19, 2022 at 09:50:37AM +0200, Fabio M. De Francesco wrote:
> On venerdì 19 agosto 2022 00:40:10 CEST Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@xxxxxxxxxx>
> > 
> > Convert the use of kmap() to its recommended replacement
> > kmap_local_page().  This avoids the overhead of doing a non-local
> > mapping, which is unnecessary in this case.
> > 
> > Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> > ---
> >  fs/verity/read_metadata.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> It looks good to me...
> 
> > -		virt = kmap(page);
> > +		virt = kmap_local_page(page);
> >  		if (copy_to_user(buf, virt + offs_in_page, bytes_to_copy)) 
> {
> > -			kunmap(page);
> > +			kunmap_local(virt);
> >  			put_page(page);
> >  			err = -EFAULT;
> >  			break;
> >  		}
> > -		kunmap(page);
> > +		kunmap_local(virt);

Is this a common pattern?  eg do we want something like:

static inline int copy_user_page(void __user *dst, struct page *page,
		size_t offset, size_t len)
{
	char *src = kmap_local_page(page) + offset;
	int err = 0;

	VM_BUG_ON(offset + len > PAGE_SIZE);
	if (copy_to_user(dst, src, len))
		err = -EFAULT;

	kunmap_local(src);
	return err;
}

in highmem.h?



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux