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] [thread-next>] [day] [month] [year] [list]
Message-id: <1363572687.14386.66.camel@kjgkr>
Date:	Mon, 18 Mar 2013 11:11:27 +0900
From:	Jaegeuk Kim <jaegeuk.kim@...sung.com>
To:	Namjae Jeon <linkinjeon@...il.com>
Cc:	linux-f2fs-devel@...ts.sourceforge.net,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	Namjae Jeon <namjae.jeon@...sung.com>,
	Amit Sahrawat <a.sahrawat@...sung.com>
Subject: Re: [PATCH 4/5] f2fs: remove nid_free from f2fs_new_inode

2013-03-17 (일), 17:27 +0900, Namjae Jeon:
> From: Namjae Jeon <namjae.jeon@...sung.com>
> 
> we can remove nid_free from new inode allocation part.
> Since, nid_free is used to check if we need to free alloced nid
> in case of failure.
> Instead we can directly call alloc_nid_failed from that point, as
> there is no dependency in that path.
> 
> Signed-off-by: Namjae Jeon <namjae.jeon@...sung.com>
> Signed-off-by: Amit Sahrawat <a.sahrawat@...sung.com>
> ---
>  fs/f2fs/namei.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index d4a171b..261d821 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -24,7 +24,6 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
>  	struct f2fs_sb_info *sbi = F2FS_SB(sb);
>  	nid_t ino;
>  	struct inode *inode;
> -	bool nid_free = false;
>  	int err;
>  
>  	inode = new_inode(sb);
> @@ -58,7 +57,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
>  	err = insert_inode_locked(inode);
>  	if (err) {
>  		err = -EINVAL;
> -		nid_free = true;
> +		alloc_nid_failed(sbi, ino);
>  		goto out;
>  	}
>  
> @@ -70,8 +69,6 @@ out:
>  	unlock_new_inode(inode);
>  fail:
>  	iput(inode);
> -	if (nid_free)
> -		alloc_nid_failed(sbi, ino);

We should call alloc_nid_failed() after iput() is completed.
Otherwise, another f2fs_new_inode() is able to get this just-released
nid before iput(). In such a case, insert_inode_locked() can return
-EBUSY or iput() can free this newly allocated inode due to the i_lock
race.
Thanks,

>  	return ERR_PTR(err);
>  }
>  

-- 
Jaegeuk Kim
Samsung

Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ