linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Jia-Ju Bai <baijiaju1990@gmail.com>,
	christian@brauner.io, ebiederm@xmission.com,
	akpm@linux-foundation.org, keescook@chromium.org,
	gladkov.alexey@gmail.com, walken@google.com,
	bernd.edlinger@hotmail.de, avagin@gmail.com, deller@gmx.de,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: proc: fix error return code of proc_map_files_readdir()
Date: Tue, 9 Mar 2021 22:05:11 +0300	[thread overview]
Message-ID: <YEfG54xMM7OtPEE5@localhost.localdomain> (raw)
In-Reply-To: <YEe+v+ywMrxgmj05@gmail.com>

On Tue, Mar 09, 2021 at 10:30:23AM -0800, Eric Biggers wrote:
> On Tue, Mar 09, 2021 at 01:55:27AM -0800, Jia-Ju Bai wrote:
> > When get_task_mm() returns NULL to mm, no error return code of
> > proc_map_files_readdir() is assigned.
> > To fix this bug, ret is assigned with -ENOENT in this case.

> > --- a/fs/proc/base.c
> > +++ b/fs/proc/base.c
> > @@ -2332,8 +2332,10 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
> >  		goto out_put_task;
> >  
> >  	mm = get_task_mm(task);
> > -	if (!mm)
> > +	if (!mm) {
> > +		ret = -ENOENT;
> >  		goto out_put_task;
> > +	}
> >  
> >  	ret = mmap_read_lock_killable(mm);
> 
> Is there something in particular that makes you think that returning ENOENT is
> the correct behavior in this case?  Try 'ls /proc/$pid/map_files' where pid is a
> kernel thread; it's an empty directory, which is probably intentional.  Your
> patch would change reading the directory to fail with ENOENT.

Yes. 0 from readdir means "no more stuff", not an error.

  reply	other threads:[~2021-03-09 19:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09  9:55 [PATCH] fs: proc: fix error return code of proc_map_files_readdir() Jia-Ju Bai
2021-03-09 18:30 ` Eric Biggers
2021-03-09 19:05   ` Alexey Dobriyan [this message]
2021-03-10  1:11     ` Jia-Ju Bai

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=YEfG54xMM7OtPEE5@localhost.localdomain \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@gmail.com \
    --cc=baijiaju1990@gmail.com \
    --cc=bernd.edlinger@hotmail.de \
    --cc=christian@brauner.io \
    --cc=deller@gmx.de \
    --cc=ebiederm@xmission.com \
    --cc=ebiggers@kernel.org \
    --cc=gladkov.alexey@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=walken@google.com \
    /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).