mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] proc: fix return value of proc_reg_open() in "too late" case
Date: Tue, 2 Sep 2008 16:26:24 -0700	[thread overview]
Message-ID: <20080902162624.cd9f6d7f.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080830053412.GB25179@x200.localdomain>

On Sat, 30 Aug 2008 09:34:12 +0400
Alexey Dobriyan <adobriyan@gmail.com> wrote:

> If ->open() wasn't called, returning 0 is misleading and, theoretically,
> oopsable:
> 1. remove_proc_entry clears ->proc_fops, drops lock,
> 2. ->open "succeeds",
> 3. ->release oopses, because it assumes ->open was called (single_release()).
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
> 
>  fs/proc/inode.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/fs/proc/inode.c
> +++ b/fs/proc/inode.c
> @@ -350,7 +350,7 @@ static int proc_reg_open(struct inode *inode, struct file *file)
>  	if (!pde->proc_fops) {
>  		spin_unlock(&pde->pde_unload_lock);
>  		kfree(pdeo);
> -		return rv;
> +		return -EINVAL;
>  	}
>  	pde->pde_users++;
>  	open = pde->proc_fops->open;

Can this code path ever actually be executed?  afacit if ->proc_fops is
ever NULL, the caller (proc_get_inode) would have already oopsed:

#ifdef CONFIG_COMPAT
				if (!de->proc_fops->compat_ioctl)
					inode->i_fop =
						&proc_reg_file_ops_no_compat;
				else
#endif
					inode->i_fop = &proc_reg_file_ops;


  reply	other threads:[~2008-09-02 23:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-30  5:34 Alexey Dobriyan
2008-09-02 23:26 ` Andrew Morton [this message]
2008-09-03 14:17   ` Alexey Dobriyan

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=20080902162624.cd9f6d7f.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=adobriyan@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome