lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170424142928.GB23988@quack2.suse.cz>
Date:   Mon, 24 Apr 2017 16:29:28 +0200
From:   Jan Kara <jack@...e.cz>
To:     Fabian Frederick <fabf@...net.be>
Cc:     Jan Kara <jack@...e.com>, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2 linux-next] udf: use kmap_atomic for memcpy copying

On Sun 23-04-17 20:58:34, Fabian Frederick wrote:
> Use temporary mapping for memory copying operations.
> 
> To avoid any sleeping problem,
> 
> mark_inode_dirty(inode) was moved after kunmap() in
> udf_adinicb_readpage()
> 
> down_write(&iinfo->i_data_sem) set before kmap_atomic()
> in udf_expand_file_adinicb()

Yeah, this looks good. I've merged the patch. Thanks.

								Honza
> 
> Signed-off-by: Fabian Frederick <fabf@...net.be>
> ---
> This is untested.
> 
>  fs/udf/file.c  | 10 +++++-----
>  fs/udf/inode.c |  8 ++++----
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/udf/file.c b/fs/udf/file.c
> index e04cc0c..f5eb2d5 100644
> --- a/fs/udf/file.c
> +++ b/fs/udf/file.c
> @@ -44,12 +44,12 @@ static void __udf_adinicb_readpage(struct page *page)
>  	char *kaddr;
>  	struct udf_inode_info *iinfo = UDF_I(inode);
>  
> -	kaddr = kmap(page);
> +	kaddr = kmap_atomic(page);
>  	memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size);
>  	memset(kaddr + inode->i_size, 0, PAGE_SIZE - inode->i_size);
>  	flush_dcache_page(page);
>  	SetPageUptodate(page);
> -	kunmap(page);
> +	kunmap_atomic(kaddr);
>  }
>  
>  static int udf_adinicb_readpage(struct file *file, struct page *page)
> @@ -70,11 +70,11 @@ static int udf_adinicb_writepage(struct page *page,
>  
>  	BUG_ON(!PageLocked(page));
>  
> -	kaddr = kmap(page);
> +	kaddr = kmap_atomic(page);
>  	memcpy(iinfo->i_ext.i_data + iinfo->i_lenEAttr, kaddr, inode->i_size);
> -	mark_inode_dirty(inode);
>  	SetPageUptodate(page);
> -	kunmap(page);
> +	kunmap_atomic(kaddr);
> +	mark_inode_dirty(inode);
>  	unlock_page(page);
>  
>  	return 0;
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index 8715dcd..98c510e 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -276,14 +276,14 @@ int udf_expand_file_adinicb(struct inode *inode)
>  		return -ENOMEM;
>  
>  	if (!PageUptodate(page)) {
> -		kaddr = kmap(page);
> +		kaddr = kmap_atomic(page);
>  		memset(kaddr + iinfo->i_lenAlloc, 0x00,
>  		       PAGE_SIZE - iinfo->i_lenAlloc);
>  		memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr,
>  			iinfo->i_lenAlloc);
>  		flush_dcache_page(page);
>  		SetPageUptodate(page);
> -		kunmap(page);
> +		kunmap_atomic(kaddr);
>  	}
>  	down_write(&iinfo->i_data_sem);
>  	memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr, 0x00,
> @@ -300,11 +300,11 @@ int udf_expand_file_adinicb(struct inode *inode)
>  	if (err) {
>  		/* Restore everything back so that we don't lose data... */
>  		lock_page(page);
> -		kaddr = kmap(page);
>  		down_write(&iinfo->i_data_sem);
> +		kaddr = kmap_atomic(page);
>  		memcpy(iinfo->i_ext.i_data + iinfo->i_lenEAttr, kaddr,
>  		       inode->i_size);
> -		kunmap(page);
> +		kunmap_atomic(kaddr);
>  		unlock_page(page);
>  		iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
>  		inode->i_data.a_ops = &udf_adinicb_aops;
> -- 
> 2.9.3
> 
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ