From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Debabrata Banerjee <dbanerje@akamai.com>
Cc: kdevcore@akamai.com, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] procfs: Fix error handling of proc_register()
Date: Thu, 23 Oct 2014 09:23:44 +0200 [thread overview]
Message-ID: <5448AD00.50809@6wind.com> (raw)
In-Reply-To: <20141022154033.3e2064d866e86a5b1c3c8230@linux-foundation.org>
Le 23/10/2014 00:40, Andrew Morton a écrit :
> On Thu, 16 Oct 2014 16:46:02 -0400 Debabrata Banerjee <dbanerje@akamai.com> wrote:
>
>> I don't see why this should print warnings at all instead of properly
>> unrolling allocations and returning an appropriate error. It's actually
>> leaking resources currently.
>
> I think the warnings are useful - a duplicate name in /proc is a
> significant kernel bug and we'll want to know precisely what caused it
> and get it fixed up quickly. So let's keep that bit.
>
>> --- a/fs/proc/generic.c
>> +++ b/fs/proc/generic.c
>> @@ -304,6 +304,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
>> dp->proc_iops = &proc_file_inode_operations;
>> } else {
>> WARN_ON(1);
>> + proc_free_inum(dp->low_ino);
>> return -EINVAL;
>> }
>>
>> @@ -311,9 +312,13 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
>>
>> for (tmp = dir->subdir; tmp; tmp = tmp->next)
>> if (strcmp(tmp->name, dp->name) == 0) {
>> - WARN(1, "proc_dir_entry '%s/%s' already registered\n",
>> - dir->name, dp->name);
>> - break;
>> + spin_unlock(&proc_subdir_lock);
>> +
>> + if (S_ISDIR(dp->mode))
>> + dir->nlink--;
>> +
>> + proc_free_inum(dp->low_ino);
>> + return -EEXIST;
>> }
>
> Your patch conflicts somewhat with Nicolas's "fs/proc: use a rb tree for
> the directory entries". Here's what I ended up with:
>
>
>
> From: Debabrata Banerjee <dbanerje@akamai.com>
> Subject: procfs: fix error handling of proc_register()
>
> proc_register() error paths are leaking inodes and directory refcounts.
>
> Signed-off-by: Debabrata Banerjee <dbanerje@akamai.com>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2014-10-23 7:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-16 20:46 [PATCH] procfs: Fix error handling of proc_register() Debabrata Banerjee
2014-10-22 22:40 ` Andrew Morton
2014-10-23 7:23 ` Nicolas Dichtel [this message]
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=5448AD00.50809@6wind.com \
--to=nicolas.dichtel@6wind.com \
--cc=akpm@linux-foundation.org \
--cc=dbanerje@akamai.com \
--cc=kdevcore@akamai.com \
--cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).