linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: hooanon05g@gmail.com
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Jan Kara <jack@suse.cz>, Eric Dumazet <edumazet@google.com>,
	linux-fsdevel@vger.kernel.org, adilger@dilger.ca, hch@lst.de,
	dchinner@redhat.com, viro@zeniv.linux.org.uk, jlbec@evilplan.org,
	gregkh@linuxfoundation.org
Subject: Re: [RFC 1/3] vfs: get_next_ino(), never inum=0
Date: Tue, 27 May 2014 21:28:04 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.1405272123020.1803@eggly.anvils> (raw)
In-Reply-To: <1400698140-25853-2-git-send-email-hooanon05g@gmail.com>

On Thu, 22 May 2014, hooanon05g@gmail.com wrote:
> From: "J. R. Okajima" <hooanon05g@gmail.com>
> 
> It is very rare for get_next_ino() to return zero as a new inode number
> since its type is unsigned int, but it can surely happen eventually.
> 
> Interestingly, ls(1) and find(1) (actually readdir(3)) don't show a file
> whose inum is zero, so people won't be able to find it. This issue may
> be harmful especially for tmpfs.
> 
> On a very long lived and busy system, users may frequently create files
> on tmpfs. And if unluckily he gets inum=0, then he cannot see its
> filename. If he remembers its name, he may be able to use or unlink it
> by its name since the file surely exists. Otherwise, the file remains on
> tmpfs silently. No one can touch it. This behaviour looks like resource
> leak.
> As a worse case, if a dir gets inum=0 and a user creates several files
> under it, then the leaked memory will increase since a user cannot see
> the name of all files under the dir whose inum=0, regardless the inum of
> the children.
> 
> There is another unpleasant effect when get_next_ino() wraps
> around. When there is a file whose inum=100 on tmpfs, a new file may get
> inum=100, ie. the duplicated inums. I am not sure what will happen when
> the duplicated inums exist on tmpfs. If it happens, then some tools
> won't work correctly such as backup and exporting via NFS, I am afraid.
> Anyway this is not a issue in get_next_ino(). It should be
> fixed in mm/shmem.c separatly if it is really necessary.
> 
> There are many other get_next_ino() callers other than tmpfs, such as
> several drivers, anon_inode, autofs4, freevxfs, procfs, pis, hugetlbfs,
> configfs, ramfs, fuse, ocfs2, debugfs, securityfs, cgroup, socket, ipc.
> Some of them will not care inum so this issue is harmless for them. But
> the others may suffer from inum=0. For example, if procfs gets inum=0
> for a task dir (or for one of its children), then several utilities
> won't work correctly, including ps(1), lsof(8), etc.
> 
> Signed-off-by: J. R. Okajima <hooanon05g@gmail.com>

Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Hugh Dickins <hughd@google.com>

> ---
>  fs/inode.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index f96d2a6..a3e274a 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -848,7 +848,11 @@ unsigned int get_next_ino(void)
>  	}
>  #endif
>  
> -	*p = ++res;
> +	res++;
> +	/* never zero */
> +	if (unlikely(!res))
> +		res++;
> +	*p = res;
>  	put_cpu_var(last_ino);
>  	return res;
>  }
> -- 
> 1.7.10.4

  reply	other threads:[~2014-05-28  4:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 18:48 [RFC 0/3] vfs: get_next_ino(), never inum=0 and uniqueness hooanon05g
2014-05-21 18:48 ` [RFC 1/3] vfs: get_next_ino(), never inum=0 hooanon05g
2014-05-28  4:28   ` Hugh Dickins [this message]
2014-05-28  5:53     ` Eric Dumazet
2014-05-21 18:48 ` [RFC 2/3] vfs: get_next_ino(), support for the uniqueness hooanon05g
2014-05-22 11:56   ` Jan Kara
2014-05-22 15:03     ` J. R. Okajima
2014-05-22 15:12       ` Jan Kara
2014-05-22 15:14         ` Christoph Hellwig
2014-05-22 16:06           ` Jan Kara
2014-05-29 15:46           ` [PATCH v2 1/2] tmpfs: manage the inode-number by IDR J. R. Okajima
2014-05-29 15:46             ` [PATCH v2 2/2] tmpfs: refine a file handle for NFS-exporting J. R. Okajima
2014-05-31  2:43             ` [PATCH v2 1/2] tmpfs: manage the inode-number by IDR J. R. Okajima
2014-06-01 16:18           ` [RFC PATCH v3 0/2] the uniquness of tmpfs inode-number J. R. Okajima
2014-06-01 16:18             ` [RFC PATCH v3 1/2] tmpfs: manage the inode-number by IDR, signed int inum J. R. Okajima
2014-06-03  9:04               ` Jan Kara
2014-06-03 14:36                 ` J. R. Okajima
2014-06-05 12:27                 ` [RFC PATCH v4 0/2] tmpfs: manage the inode-number by IDR (performance measure) J. R. Okajima
2014-06-05 12:27                   ` [RFC PATCH v4 1/2] tmpfs: manage the inode-number by IDR, signed int inum J. R. Okajima
2014-06-05 12:27                   ` [RFC PATCH v4 2/2] tmpfs: refine a file handle for NFS-exporting J. R. Okajima
2014-06-01 16:18             ` [RFC PATCH v3 " J. R. Okajima
2014-05-21 18:49 ` [RFC 3/3] uniqueness of inode number, configfs, debugfs, procfs, ramfs and tmpfs hooanon05g
2014-05-22  1:03   ` J. R. Okajima
2014-05-22 11:53     ` Jan Kara
2014-05-22 14:58       ` J. R. Okajima
2014-05-22 15:09         ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.11.1405272123020.1803@eggly.anvils \
    --to=hughd@google.com \
    --cc=adilger@dilger.ca \
    --cc=akpm@linux-foundation.org \
    --cc=dchinner@redhat.com \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=hooanon05g@gmail.com \
    --cc=jack@suse.cz \
    --cc=jlbec@evilplan.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).