* [patch] Btrfs: dereferencing free'd memory in panic message
@ 2012-06-22 7:14 Dan Carpenter
2012-06-22 13:09 ` Josef Bacik
0 siblings, 1 reply; 9+ messages in thread
From: Dan Carpenter @ 2012-06-22 7:14 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs, kernel-janitors
We free "node" and then dereference it in the panic message on the next
line. I considered moving the kfree() after the panic given that panic
can return under certain configurations, but in the end I decided it
doesn't matter if we leak a bit after a panic.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 790f492..c50d80a 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1239,7 +1239,6 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
node->bytenr, &node->rb_node);
spin_unlock(&rc->reloc_root_tree.lock);
if (rb_node) {
- kfree(node);
btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
"for start=%llu while inserting into relocation "
"tree\n", node->bytenr);
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [patch] Btrfs: dereferencing free'd memory in panic message
2012-06-22 7:14 [patch] Btrfs: dereferencing free'd memory in panic message Dan Carpenter
@ 2012-06-22 13:09 ` Josef Bacik
2012-06-22 13:30 ` Dan Carpenter
0 siblings, 1 reply; 9+ messages in thread
From: Josef Bacik @ 2012-06-22 13:09 UTC (permalink / raw)
To: Dan Carpenter
Cc: Chris L. Mason, linux-btrfs@vger.kernel.org,
kernel-janitors@vger.kernel.org
On 06/22/2012 03:14 AM, Dan Carpenter wrote:
> We free "node" and then dereference it in the panic message on the next
> line. I considered moving the kfree() after the panic given that panic
> can return under certain configurations, but in the end I decided it
> doesn't matter if we leak a bit after a panic.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 790f492..c50d80a 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -1239,7 +1239,6 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
> node->bytenr, &node->rb_node);
> spin_unlock(&rc->reloc_root_tree.lock);
> if (rb_node) {
> - kfree(node);
> btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
> "for start=%llu while inserting into relocation "
> "tree\n", node->bytenr);
Except btrfs_panic can not panic the box if it's mounted to not panic on
errors, so we still need to do the kfree afterwards. Thanks,
Josef
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Btrfs: dereferencing free'd memory in panic message
2012-06-22 13:09 ` Josef Bacik
@ 2012-06-22 13:30 ` Dan Carpenter
2012-06-22 13:32 ` Josef Bacik
0 siblings, 1 reply; 9+ messages in thread
From: Dan Carpenter @ 2012-06-22 13:30 UTC (permalink / raw)
To: Josef Bacik
Cc: Chris L. Mason, linux-btrfs@vger.kernel.org,
kernel-janitors@vger.kernel.org
On Fri, Jun 22, 2012 at 09:09:04AM -0400, Josef Bacik wrote:
> On 06/22/2012 03:14 AM, Dan Carpenter wrote:
> >We free "node" and then dereference it in the panic message on the next
> >line. I considered moving the kfree() after the panic given that panic
> >can return under certain configurations, but in the end I decided it
> >doesn't matter if we leak a bit after a panic.
> >
> >Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> >diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> >index 790f492..c50d80a 100644
> >--- a/fs/btrfs/relocation.c
> >+++ b/fs/btrfs/relocation.c
> >@@ -1239,7 +1239,6 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
> > node->bytenr, &node->rb_node);
> > spin_unlock(&rc->reloc_root_tree.lock);
> > if (rb_node) {
> >- kfree(node);
> > btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
> > "for start=%llu while inserting into relocation "
> > "tree\n", node->bytenr);
>
> Except btrfs_panic can not panic the box if it's mounted to not
> panic on errors, so we still need to do the kfree afterwards.
> Thanks,
Right. I mentioned that in my change log, but I figured a one time
memory leak was the least of our concerns in that case. I will
resend. This should probably return -EEXIST here as well yes?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Btrfs: dereferencing free'd memory in panic message
2012-06-22 13:30 ` Dan Carpenter
@ 2012-06-22 13:32 ` Josef Bacik
2012-06-25 11:15 ` [patch v2] Btrfs: fix error handling in __add_reloc_root() Dan Carpenter
0 siblings, 1 reply; 9+ messages in thread
From: Josef Bacik @ 2012-06-22 13:32 UTC (permalink / raw)
To: Dan Carpenter
Cc: Chris L. Mason, linux-btrfs@vger.kernel.org,
kernel-janitors@vger.kernel.org
On 06/22/2012 09:30 AM, Dan Carpenter wrote:
> On Fri, Jun 22, 2012 at 09:09:04AM -0400, Josef Bacik wrote:
>> On 06/22/2012 03:14 AM, Dan Carpenter wrote:
>>> We free "node" and then dereference it in the panic message on the next
>>> line. I considered moving the kfree() after the panic given that panic
>>> can return under certain configurations, but in the end I decided it
>>> doesn't matter if we leak a bit after a panic.
>>>
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>>
>>> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
>>> index 790f492..c50d80a 100644
>>> --- a/fs/btrfs/relocation.c
>>> +++ b/fs/btrfs/relocation.c
>>> @@ -1239,7 +1239,6 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
>>> node->bytenr, &node->rb_node);
>>> spin_unlock(&rc->reloc_root_tree.lock);
>>> if (rb_node) {
>>> - kfree(node);
>>> btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
>>> "for start=%llu while inserting into relocation "
>>> "tree\n", node->bytenr);
>>
>> Except btrfs_panic can not panic the box if it's mounted to not
>> panic on errors, so we still need to do the kfree afterwards.
>> Thanks,
>
> Right. I mentioned that in my change log, but I figured a one time
> memory leak was the least of our concerns in that case. I will
> resend. This should probably return -EEXIST here as well yes?
>
Ah sorry I thought you were talking about BUG_ON() not actually stopping
the box in some cases. But yes I'd like to not leak anyway and return
-EEXIST. Thanks,
Josef
^ permalink raw reply [flat|nested] 9+ messages in thread
* [patch v2] Btrfs: fix error handling in __add_reloc_root()
2012-06-22 13:32 ` Josef Bacik
@ 2012-06-25 11:15 ` Dan Carpenter
2012-06-25 13:41 ` Josef Bacik
0 siblings, 1 reply; 9+ messages in thread
From: Dan Carpenter @ 2012-06-25 11:15 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs, Josef Bacik, kernel-janitors
We dereferenced "node" in the error message after freeing it. Also
btrfs_panic() can return so we should return an error code instead of
continuing.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: in the first version I just deleted the kfree().
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 790f492..4da0865 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1239,10 +1239,11 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
node->bytenr, &node->rb_node);
spin_unlock(&rc->reloc_root_tree.lock);
if (rb_node) {
- kfree(node);
btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
"for start=%llu while inserting into relocation "
"tree\n", node->bytenr);
+ kfree(node);
+ return -EEXIST;
}
list_add_tail(&root->root_list, &rc->reloc_roots);
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [patch v2] Btrfs: fix error handling in __add_reloc_root()
2012-06-25 11:15 ` [patch v2] Btrfs: fix error handling in __add_reloc_root() Dan Carpenter
@ 2012-06-25 13:41 ` Josef Bacik
2012-06-25 13:53 ` Dan Carpenter
0 siblings, 1 reply; 9+ messages in thread
From: Josef Bacik @ 2012-06-25 13:41 UTC (permalink / raw)
To: Dan Carpenter
Cc: Chris L. Mason, linux-btrfs@vger.kernel.org, Josef Bacik,
kernel-janitors@vger.kernel.org
On Mon, Jun 25, 2012 at 05:15:23AM -0600, Dan Carpenter wrote:
> We dereferenced "node" in the error message after freeing it. Also
> btrfs_panic() can return so we should return an error code instead of
> continuing.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: in the first version I just deleted the kfree().
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 790f492..4da0865 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -1239,10 +1239,11 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
> node->bytenr, &node->rb_node);
> spin_unlock(&rc->reloc_root_tree.lock);
> if (rb_node) {
> - kfree(node);
> btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
> "for start=%llu while inserting into relocation "
> "tree\n", node->bytenr);
> + kfree(node);
> + return -EEXIST;
> }
>
> list_add_tail(&root->root_list, &rc->reloc_roots);
I'm not sure why but it seems like this patch is wrapped. At first I thought it
was thunderbird but then I opened it up and saved it from mutt and I got the
same problem. I will fix it up, but you may want to check your mail client.
Thanks,
Josef
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch v2] Btrfs: fix error handling in __add_reloc_root()
2012-06-25 13:41 ` Josef Bacik
@ 2012-06-25 13:53 ` Dan Carpenter
2012-06-26 1:21 ` santosh prasad nayak
0 siblings, 1 reply; 9+ messages in thread
From: Dan Carpenter @ 2012-06-25 13:53 UTC (permalink / raw)
To: Josef Bacik
Cc: Chris L. Mason, linux-btrfs@vger.kernel.org,
kernel-janitors@vger.kernel.org
On Mon, Jun 25, 2012 at 09:41:12AM -0400, Josef Bacik wrote:
> On Mon, Jun 25, 2012 at 05:15:23AM -0600, Dan Carpenter wrote:
> > We dereferenced "node" in the error message after freeing it. Also
> > btrfs_panic() can return so we should return an error code instead of
> > continuing.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > v2: in the first version I just deleted the kfree().
> >
> > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> > index 790f492..4da0865 100644
> > --- a/fs/btrfs/relocation.c
> > +++ b/fs/btrfs/relocation.c
> > @@ -1239,10 +1239,11 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
> > node->bytenr, &node->rb_node);
> > spin_unlock(&rc->reloc_root_tree.lock);
> > if (rb_node) {
> > - kfree(node);
> > btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
> > "for start=%llu while inserting into relocation "
> > "tree\n", node->bytenr);
> > + kfree(node);
> > + return -EEXIST;
> > }
> >
> > list_add_tail(&root->root_list, &rc->reloc_roots);
>
> I'm not sure why but it seems like this patch is wrapped. At first I thought it
> was thunderbird but then I opened it up and saved it from mutt and I got the
> same problem. I will fix it up, but you may want to check your mail client.
The message that went through to kernel-janitors applies fine for
me. I'm not sure what to say.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch v2] Btrfs: fix error handling in __add_reloc_root()
2012-06-25 13:53 ` Dan Carpenter
@ 2012-06-26 1:21 ` santosh prasad nayak
2012-06-26 6:41 ` Dan Carpenter
0 siblings, 1 reply; 9+ messages in thread
From: santosh prasad nayak @ 2012-06-26 1:21 UTC (permalink / raw)
To: Dan Carpenter
Cc: Josef Bacik, Chris L. Mason, linux-btrfs@vger.kernel.org,
kernel-janitors@vger.kernel.org
I am also facing similar issue while applying this patch.
[santosh@localhost linux-next]$ sudo git am mail_Dan.txt
Patch format detection failed.
[santosh@localhost linux-next]$
regards
santosh
On Mon, Jun 25, 2012 at 7:23 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Mon, Jun 25, 2012 at 09:41:12AM -0400, Josef Bacik wrote:
>> On Mon, Jun 25, 2012 at 05:15:23AM -0600, Dan Carpenter wrote:
>> > We dereferenced "node" in the error message after freeing it. Also
>> > btrfs_panic() can return so we should return an error code instead of
>> > continuing.
>> >
>> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> > ---
>> > v2: in the first version I just deleted the kfree().
>> >
>> > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
>> > index 790f492..4da0865 100644
>> > --- a/fs/btrfs/relocation.c
>> > +++ b/fs/btrfs/relocation.c
>> > @@ -1239,10 +1239,11 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
>> > node->bytenr, &node->rb_node);
>> > spin_unlock(&rc->reloc_root_tree.lock);
>> > if (rb_node) {
>> > - kfree(node);
>> > btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
>> > "for start=%llu while inserting into relocation "
>> > "tree\n", node->bytenr);
>> > + kfree(node);
>> > + return -EEXIST;
>> > }
>> >
>> > list_add_tail(&root->root_list, &rc->reloc_roots);
>>
>> I'm not sure why but it seems like this patch is wrapped. At first I thought it
>> was thunderbird but then I opened it up and saved it from mutt and I got the
>> same problem. I will fix it up, but you may want to check your mail client.
>
> The message that went through to kernel-janitors applies fine for
> me. I'm not sure what to say.
>
> regards,
> dan carpenter
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch v2] Btrfs: fix error handling in __add_reloc_root()
2012-06-26 1:21 ` santosh prasad nayak
@ 2012-06-26 6:41 ` Dan Carpenter
0 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2012-06-26 6:41 UTC (permalink / raw)
To: santosh prasad nayak
Cc: Josef Bacik, Chris L. Mason, linux-btrfs@vger.kernel.org,
kernel-janitors@vger.kernel.org
On Tue, Jun 26, 2012 at 06:51:39AM +0530, santosh prasad nayak wrote:
> I am also facing similar issue while applying this patch.
>
> [santosh@localhost linux-next]$ sudo git am mail_Dan.txt
> Patch format detection failed.
> [santosh@localhost linux-next]$
>
The problem is not on my end. It made it to marc.info without
getting corrupted. Marc.info strips out the From: and Subject:
headers so you'd have to add them in manually.
1) Save this file:
http://marc.info/?l=kernel-janitors&m=134062314509635&q=raw
2) Edit the file and add these two lines add the top:
From: Dan Carpenter <dan.carpenter@oracle.com>
Subject: [patch v2] Btrfs: fix error handling in __add_reloc_root()
3) $ git am /home/dcarpenter/tmp/html2/btrfs_raw.txt
Applying: Btrfs: fix error handling in __add_reloc_root()
regards,
dan carpenter
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-06-26 6:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-22 7:14 [patch] Btrfs: dereferencing free'd memory in panic message Dan Carpenter
2012-06-22 13:09 ` Josef Bacik
2012-06-22 13:30 ` Dan Carpenter
2012-06-22 13:32 ` Josef Bacik
2012-06-25 11:15 ` [patch v2] Btrfs: fix error handling in __add_reloc_root() Dan Carpenter
2012-06-25 13:41 ` Josef Bacik
2012-06-25 13:53 ` Dan Carpenter
2012-06-26 1:21 ` santosh prasad nayak
2012-06-26 6:41 ` Dan Carpenter
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).