mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH] double free in decompressor.c
@ 2013-11-22 21:50 Geyslan Gregório Bem
  2013-11-22 21:59 ` Richard Weinberger
  2013-11-22 23:25 ` Phillip Lougher
  0 siblings, 2 replies; 5+ messages in thread
From: Geyslan Gregório Bem @ 2013-11-22 21:50 UTC (permalink / raw)
  To: phillip; +Cc: LKML

Coverity caught double free possibility (CID 1130962).

I can patch this, but I have to know if is correct to free comp_opts
in the function squashfs_decompressor_create() or it had to be done in
the caller. My bet is the caller.


128void *squashfs_decompressor_setup(struct super_block *sb, unsigned
short flags)
129{
130        struct squashfs_sb_info *msblk = sb->s_fs_info;
131        void *stream, *comp_opts = get_comp_opts(sb, flags);
132

1. Condition "IS_ERR(comp_opts)", taking false branch
133        if (IS_ERR(comp_opts))
134                return comp_opts;
135

2. freed_arg: "squashfs_decompressor_create(struct squashfs_sb_info *,
void *)" frees "comp_opts".[show details]
136        stream = squashfs_decompressor_create(msblk, comp_opts);

3. Condition "IS_ERR(stream)", taking true branch
137        if (IS_ERR(stream))

CID 1130962 (#1 of 1): Double free (USE_AFTER_FREE)4. double_free:
Calling "kfree(void const *)" frees pointer "comp_opts" which has
already been freed.
138                kfree(comp_opts);
139
140        return stream;
141}


-- 
Regards,

Geyslan G. Bem
hackingbits.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] double free in decompressor.c
  2013-11-22 21:50 [RFC PATCH] double free in decompressor.c Geyslan Gregório Bem
@ 2013-11-22 21:59 ` Richard Weinberger
  2013-11-22 22:14   ` Geyslan Gregório Bem
  2013-11-22 23:25 ` Phillip Lougher
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2013-11-22 21:59 UTC (permalink / raw)
  To: Geyslan Gregório Bem; +Cc: phillip, LKML

On Fri, Nov 22, 2013 at 10:50 PM, Geyslan Gregório Bem
<geyslan@gmail.com> wrote:
> Coverity caught double free possibility (CID 1130962).

Just wondering, where can one find/verify such CIDs?

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] double free in decompressor.c
  2013-11-22 21:59 ` Richard Weinberger
@ 2013-11-22 22:14   ` Geyslan Gregório Bem
  0 siblings, 0 replies; 5+ messages in thread
From: Geyslan Gregório Bem @ 2013-11-22 22:14 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: phillip, LKML

2013/11/22 Richard Weinberger <richard.weinberger@gmail.com>:
> On Fri, Nov 22, 2013 at 10:50 PM, Geyslan Gregório Bem
> <geyslan@gmail.com> wrote:
>> Coverity caught double free possibility (CID 1130962).
>
> Just wondering, where can one find/verify such CIDs?
>
> --
> Thanks,
> //richard

Anyone can sign in (https://scan.coverity.com/) and choose an open
source project or register one (as maintainer) indeed. After that,
configure to receive "new defects" updates.

-- 
Regards,

Geyslan G. Bem
hackingbits.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] double free in decompressor.c
  2013-11-22 21:50 [RFC PATCH] double free in decompressor.c Geyslan Gregório Bem
  2013-11-22 21:59 ` Richard Weinberger
@ 2013-11-22 23:25 ` Phillip Lougher
  2013-11-23  1:14   ` Geyslan Gregório Bem
  1 sibling, 1 reply; 5+ messages in thread
From: Phillip Lougher @ 2013-11-22 23:25 UTC (permalink / raw)
  To: Geyslan Gregório Bem; +Cc: phillip, LKML

On 22/11/13 21:50, Geyslan Gregório Bem wrote:
> Coverity caught double free possibility (CID 1130962).
>
> I can patch this, but I have to know if is correct to free comp_opts
> in the function squashfs_decompressor_create() or it had to be done in
> the caller. My bet is the caller.
>
>
> 128void *squashfs_decompressor_setup(struct super_block *sb, unsigned
> short flags)
> 129{
> 130        struct squashfs_sb_info *msblk = sb->s_fs_info;
> 131        void *stream, *comp_opts = get_comp_opts(sb, flags);
> 132
>
> 1. Condition "IS_ERR(comp_opts)", taking false branch
> 133        if (IS_ERR(comp_opts))
> 134                return comp_opts;
> 135
>
> 2. freed_arg: "squashfs_decompressor_create(struct squashfs_sb_info *,
> void *)" frees "comp_opts".[show details]
> 136        stream = squashfs_decompressor_create(msblk, comp_opts);
>
> 3. Condition "IS_ERR(stream)", taking true branch
> 137        if (IS_ERR(stream))

FALSE positive.

squashfs_decompressor_create() frees comp_opts only on success.

If IS_ERR(stream) is true, then comp_opts has not been freed by
squashfs_decompressor_create().

Phillip


>
> CID 1130962 (#1 of 1): Double free (USE_AFTER_FREE)4. double_free:
> Calling "kfree(void const *)" frees pointer "comp_opts" which has
> already been freed.
> 138                kfree(comp_opts);
> 139
> 140        return stream;
> 141}
>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] double free in decompressor.c
  2013-11-22 23:25 ` Phillip Lougher
@ 2013-11-23  1:14   ` Geyslan Gregório Bem
  0 siblings, 0 replies; 5+ messages in thread
From: Geyslan Gregório Bem @ 2013-11-23  1:14 UTC (permalink / raw)
  To: Phillip Lougher; +Cc: phillip, LKML

2013/11/22 Phillip Lougher <phillip@lougher.demon.co.uk>:
> On 22/11/13 21:50, Geyslan Gregório Bem wrote:
>>
>> Coverity caught double free possibility (CID 1130962).
>>
>> I can patch this, but I have to know if is correct to free comp_opts
>> in the function squashfs_decompressor_create() or it had to be done in
>> the caller. My bet is the caller.
>>
>>
>> 128void *squashfs_decompressor_setup(struct super_block *sb, unsigned
>> short flags)
>> 129{
>> 130        struct squashfs_sb_info *msblk = sb->s_fs_info;
>> 131        void *stream, *comp_opts = get_comp_opts(sb, flags);
>> 132
>>
>> 1. Condition "IS_ERR(comp_opts)", taking false branch
>> 133        if (IS_ERR(comp_opts))
>> 134                return comp_opts;
>> 135
>>
>> 2. freed_arg: "squashfs_decompressor_create(struct squashfs_sb_info *,
>> void *)" frees "comp_opts".[show details]
>> 136        stream = squashfs_decompressor_create(msblk, comp_opts);
>>
>> 3. Condition "IS_ERR(stream)", taking true branch
>> 137        if (IS_ERR(stream))
>
>
> FALSE positive.
>
> squashfs_decompressor_create() frees comp_opts only on success.
>
> If IS_ERR(stream) is true, then comp_opts has not been freed by
> squashfs_decompressor_create().
>
> Phillip
>
>
>
>>
>> CID 1130962 (#1 of 1): Double free (USE_AFTER_FREE)4. double_free:
>> Calling "kfree(void const *)" frees pointer "comp_opts" which has
>> already been freed.
>> 138                kfree(comp_opts);
>> 139
>> 140        return stream;
>> 141}
>>
>>
>

Philip, set as false positive in Coverity. Thanks.

-- 
Regards,

Geyslan G. Bem
hackingbits.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-23  1:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-22 21:50 [RFC PATCH] double free in decompressor.c Geyslan Gregório Bem
2013-11-22 21:59 ` Richard Weinberger
2013-11-22 22:14   ` Geyslan Gregório Bem
2013-11-22 23:25 ` Phillip Lougher
2013-11-23  1:14   ` Geyslan Gregório Bem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®