linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark
@ 2022-08-22  2:29 Gaosheng Cui
  2022-08-22  8:50 ` Jan Kara
  0 siblings, 1 reply; 8+ messages in thread
From: Gaosheng Cui @ 2022-08-22  2:29 UTC (permalink / raw)
  To: paul, eparis, mszeredi, jack, amir73il, cuigaosheng1
  Cc: linux-audit, linux-kernel

Audit_alloc_mark() assign pathname to audit_mark->path, on error path
from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
of audit_mark->path, but the caller of audit_alloc_mark will free
the pathname again, so there will be double free problem.

Fix this by resetting audit_mark->path to NULL pointer on error path
from fsnotify_add_inode_mark().

Fixes: 7b1293234084d ("fsnotify: Add group pointer in fsnotify_init_mark()")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 kernel/audit_fsnotify.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
index 6432a37ac1c9..c565fbf66ac8 100644
--- a/kernel/audit_fsnotify.c
+++ b/kernel/audit_fsnotify.c
@@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
 
 	ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
 	if (ret < 0) {
+		audit_mark->path = NULL;
 		fsnotify_put_mark(&audit_mark->mark);
 		audit_mark = ERR_PTR(ret);
 	}
-- 
2.25.1


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

* Re: [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark
  2022-08-22  2:29 [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark Gaosheng Cui
@ 2022-08-22  8:50 ` Jan Kara
  2022-08-22 14:34   ` Paul Moore
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kara @ 2022-08-22  8:50 UTC (permalink / raw)
  To: Gaosheng Cui
  Cc: paul, eparis, mszeredi, jack, amir73il, linux-audit, linux-kernel

On Mon 22-08-22 10:29:05, Gaosheng Cui wrote:
> Audit_alloc_mark() assign pathname to audit_mark->path, on error path
> from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
> of audit_mark->path, but the caller of audit_alloc_mark will free
> the pathname again, so there will be double free problem.
> 
> Fix this by resetting audit_mark->path to NULL pointer on error path
> from fsnotify_add_inode_mark().
> 
> Fixes: 7b1293234084d ("fsnotify: Add group pointer in fsnotify_init_mark()")
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>

Good spotting! The patch looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  kernel/audit_fsnotify.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
> index 6432a37ac1c9..c565fbf66ac8 100644
> --- a/kernel/audit_fsnotify.c
> +++ b/kernel/audit_fsnotify.c
> @@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
>  
>  	ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
>  	if (ret < 0) {
> +		audit_mark->path = NULL;
>  		fsnotify_put_mark(&audit_mark->mark);
>  		audit_mark = ERR_PTR(ret);
>  	}
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark
  2022-08-22  8:50 ` Jan Kara
@ 2022-08-22 14:34   ` Paul Moore
  2022-08-22 15:20     ` Jan Kara
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Moore @ 2022-08-22 14:34 UTC (permalink / raw)
  To: Jan Kara
  Cc: Gaosheng Cui, eparis, mszeredi, amir73il, linux-audit, linux-kernel

On Mon, Aug 22, 2022 at 4:50 AM Jan Kara <jack@suse.cz> wrote:
> On Mon 22-08-22 10:29:05, Gaosheng Cui wrote:
> > Audit_alloc_mark() assign pathname to audit_mark->path, on error path
> > from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
> > of audit_mark->path, but the caller of audit_alloc_mark will free
> > the pathname again, so there will be double free problem.
> >
> > Fix this by resetting audit_mark->path to NULL pointer on error path
> > from fsnotify_add_inode_mark().
> >
> > Fixes: 7b1293234084d ("fsnotify: Add group pointer in fsnotify_init_mark()")
> > Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
>
> Good spotting! The patch looks good to me. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
> > ---
> >  kernel/audit_fsnotify.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
> > index 6432a37ac1c9..c565fbf66ac8 100644
> > --- a/kernel/audit_fsnotify.c
> > +++ b/kernel/audit_fsnotify.c
> > @@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
> >
> >       ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
> >       if (ret < 0) {
> > +             audit_mark->path = NULL;
> >               fsnotify_put_mark(&audit_mark->mark);

As I'm tracing the code path from audit through fsnotify, and back
into audit, I'm wondering if we still have a problem.  When
fsnotify_add_inode_mark() fails it will end up freeing not just
audit_mark->path, but audit_mark itself via audit_fsnotify_mark_free()
(via a call into fsnotify_put_mark()), yes?  If that is the case, I
think the better fix would simply be to just remove the
fsnotify_put_mark() call and add a small comment in this error patch
mentioning that fsnotify_put_mark() will release audit_mark on error.

Thoughts?

> >               audit_mark = ERR_PTR(ret);
> >       }

-- 
paul-moore.com

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

* Re: [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark
  2022-08-22 14:34   ` Paul Moore
@ 2022-08-22 15:20     ` Jan Kara
  2022-08-22 17:39       ` Paul Moore
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kara @ 2022-08-22 15:20 UTC (permalink / raw)
  To: Paul Moore
  Cc: Jan Kara, Gaosheng Cui, eparis, mszeredi, amir73il, linux-audit,
	linux-kernel

On Mon 22-08-22 10:34:15, Paul Moore wrote:
> On Mon, Aug 22, 2022 at 4:50 AM Jan Kara <jack@suse.cz> wrote:
> > On Mon 22-08-22 10:29:05, Gaosheng Cui wrote:
> > > Audit_alloc_mark() assign pathname to audit_mark->path, on error path
> > > from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
> > > of audit_mark->path, but the caller of audit_alloc_mark will free
> > > the pathname again, so there will be double free problem.
> > >
> > > Fix this by resetting audit_mark->path to NULL pointer on error path
> > > from fsnotify_add_inode_mark().
> > >
> > > Fixes: 7b1293234084d ("fsnotify: Add group pointer in fsnotify_init_mark()")
> > > Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> >
> > Good spotting! The patch looks good to me. Feel free to add:
> >
> > Reviewed-by: Jan Kara <jack@suse.cz>
> >
> > > ---
> > >  kernel/audit_fsnotify.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
> > > index 6432a37ac1c9..c565fbf66ac8 100644
> > > --- a/kernel/audit_fsnotify.c
> > > +++ b/kernel/audit_fsnotify.c
> > > @@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
> > >
> > >       ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
> > >       if (ret < 0) {
> > > +             audit_mark->path = NULL;
> > >               fsnotify_put_mark(&audit_mark->mark);
> 
> As I'm tracing the code path from audit through fsnotify, and back
> into audit, I'm wondering if we still have a problem.  When
> fsnotify_add_inode_mark() fails it will end up freeing not just
> audit_mark->path, but audit_mark itself via audit_fsnotify_mark_free()
> (via a call into fsnotify_put_mark()), yes?

I don't think so. fsnotify_add_mark_locked() will call fsnotify_put_mark()
but that is just a counter part to fsnotify_get_mark() a few lines above.
The caller of fsnotify_add_inode_mark() still holds its own mark reference
which prevents mark from being freed.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark
  2022-08-22 15:20     ` Jan Kara
@ 2022-08-22 17:39       ` Paul Moore
  2022-08-22 17:59         ` Jan Kara
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Moore @ 2022-08-22 17:39 UTC (permalink / raw)
  To: Jan Kara
  Cc: Gaosheng Cui, eparis, mszeredi, amir73il, linux-audit, linux-kernel

On Mon, Aug 22, 2022 at 11:20 AM Jan Kara <jack@suse.cz> wrote:
> On Mon 22-08-22 10:34:15, Paul Moore wrote:
> > On Mon, Aug 22, 2022 at 4:50 AM Jan Kara <jack@suse.cz> wrote:
> > > On Mon 22-08-22 10:29:05, Gaosheng Cui wrote:
> > > > Audit_alloc_mark() assign pathname to audit_mark->path, on error path
> > > > from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
> > > > of audit_mark->path, but the caller of audit_alloc_mark will free
> > > > the pathname again, so there will be double free problem.
> > > >
> > > > Fix this by resetting audit_mark->path to NULL pointer on error path
> > > > from fsnotify_add_inode_mark().
> > > >
> > > > Fixes: 7b1293234084d ("fsnotify: Add group pointer in fsnotify_init_mark()")
> > > > Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> > >
> > > Good spotting! The patch looks good to me. Feel free to add:
> > >
> > > Reviewed-by: Jan Kara <jack@suse.cz>
> > >
> > > > ---
> > > >  kernel/audit_fsnotify.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
> > > > index 6432a37ac1c9..c565fbf66ac8 100644
> > > > --- a/kernel/audit_fsnotify.c
> > > > +++ b/kernel/audit_fsnotify.c
> > > > @@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
> > > >
> > > >       ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
> > > >       if (ret < 0) {
> > > > +             audit_mark->path = NULL;
> > > >               fsnotify_put_mark(&audit_mark->mark);
> >
> > As I'm tracing the code path from audit through fsnotify, and back
> > into audit, I'm wondering if we still have a problem.  When
> > fsnotify_add_inode_mark() fails it will end up freeing not just
> > audit_mark->path, but audit_mark itself via audit_fsnotify_mark_free()
> > (via a call into fsnotify_put_mark()), yes?
>
> I don't think so. fsnotify_add_mark_locked() will call fsnotify_put_mark()
> but that is just a counter part to fsnotify_get_mark() a few lines above.
> The caller of fsnotify_add_inode_mark() still holds its own mark reference
> which prevents mark from being freed.

Okay, that sounds reasonable, but I'm still looking for a code path
that only frees audit_mark:path and not the audit_mark itself.  What
am I not seeing?

-- 
paul-moore.com

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

* Re: [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark
  2022-08-22 17:39       ` Paul Moore
@ 2022-08-22 17:59         ` Jan Kara
  2022-08-22 22:49           ` Paul Moore
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kara @ 2022-08-22 17:59 UTC (permalink / raw)
  To: Paul Moore
  Cc: Jan Kara, Gaosheng Cui, eparis, mszeredi, amir73il, linux-audit,
	linux-kernel

On Mon 22-08-22 13:39:23, Paul Moore wrote:
> On Mon, Aug 22, 2022 at 11:20 AM Jan Kara <jack@suse.cz> wrote:
> > On Mon 22-08-22 10:34:15, Paul Moore wrote:
> > > On Mon, Aug 22, 2022 at 4:50 AM Jan Kara <jack@suse.cz> wrote:
> > > > On Mon 22-08-22 10:29:05, Gaosheng Cui wrote:
> > > > > Audit_alloc_mark() assign pathname to audit_mark->path, on error path
> > > > > from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
> > > > > of audit_mark->path, but the caller of audit_alloc_mark will free
> > > > > the pathname again, so there will be double free problem.
> > > > >
> > > > > Fix this by resetting audit_mark->path to NULL pointer on error path
> > > > > from fsnotify_add_inode_mark().
> > > > >
> > > > > Fixes: 7b1293234084d ("fsnotify: Add group pointer in fsnotify_init_mark()")
> > > > > Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> > > >
> > > > Good spotting! The patch looks good to me. Feel free to add:
> > > >
> > > > Reviewed-by: Jan Kara <jack@suse.cz>
> > > >
> > > > > ---
> > > > >  kernel/audit_fsnotify.c | 1 +
> > > > >  1 file changed, 1 insertion(+)
> > > > >
> > > > > diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
> > > > > index 6432a37ac1c9..c565fbf66ac8 100644
> > > > > --- a/kernel/audit_fsnotify.c
> > > > > +++ b/kernel/audit_fsnotify.c
> > > > > @@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
> > > > >
> > > > >       ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
> > > > >       if (ret < 0) {
> > > > > +             audit_mark->path = NULL;
> > > > >               fsnotify_put_mark(&audit_mark->mark);
> > >
> > > As I'm tracing the code path from audit through fsnotify, and back
> > > into audit, I'm wondering if we still have a problem.  When
> > > fsnotify_add_inode_mark() fails it will end up freeing not just
> > > audit_mark->path, but audit_mark itself via audit_fsnotify_mark_free()
> > > (via a call into fsnotify_put_mark()), yes?
> >
> > I don't think so. fsnotify_add_mark_locked() will call fsnotify_put_mark()
> > but that is just a counter part to fsnotify_get_mark() a few lines above.
> > The caller of fsnotify_add_inode_mark() still holds its own mark reference
> > which prevents mark from being freed.
> 
> Okay, that sounds reasonable, but I'm still looking for a code path
> that only frees audit_mark:path and not the audit_mark itself.  What
> am I not seeing?

The callers of audit_alloc_mark() call kfree(path) if audit_alloc_mark()
returns error (which is a sensible thing because in some cases path indeed
needs freeing).

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark
  2022-08-22 17:59         ` Jan Kara
@ 2022-08-22 22:49           ` Paul Moore
  2022-08-23  2:06             ` cuigaosheng
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Moore @ 2022-08-22 22:49 UTC (permalink / raw)
  To: Jan Kara
  Cc: Gaosheng Cui, eparis, mszeredi, amir73il, linux-audit, linux-kernel

On Mon, Aug 22, 2022 at 1:59 PM Jan Kara <jack@suse.cz> wrote:
> On Mon 22-08-22 13:39:23, Paul Moore wrote:
> > On Mon, Aug 22, 2022 at 11:20 AM Jan Kara <jack@suse.cz> wrote:
> > > On Mon 22-08-22 10:34:15, Paul Moore wrote:
> > > > On Mon, Aug 22, 2022 at 4:50 AM Jan Kara <jack@suse.cz> wrote:
> > > > > On Mon 22-08-22 10:29:05, Gaosheng Cui wrote:
> > > > > > Audit_alloc_mark() assign pathname to audit_mark->path, on error path
> > > > > > from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
> > > > > > of audit_mark->path, but the caller of audit_alloc_mark will free
> > > > > > the pathname again, so there will be double free problem.
> > > > > >
> > > > > > Fix this by resetting audit_mark->path to NULL pointer on error path
> > > > > > from fsnotify_add_inode_mark().
> > > > > >
> > > > > > Fixes: 7b1293234084d ("fsnotify: Add group pointer in fsnotify_init_mark()")
> > > > > > Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> > > > >
> > > > > Good spotting! The patch looks good to me. Feel free to add:
> > > > >
> > > > > Reviewed-by: Jan Kara <jack@suse.cz>
> > > > >
> > > > > > ---
> > > > > >  kernel/audit_fsnotify.c | 1 +
> > > > > >  1 file changed, 1 insertion(+)
> > > > > >
> > > > > > diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
> > > > > > index 6432a37ac1c9..c565fbf66ac8 100644
> > > > > > --- a/kernel/audit_fsnotify.c
> > > > > > +++ b/kernel/audit_fsnotify.c
> > > > > > @@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
> > > > > >
> > > > > >       ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
> > > > > >       if (ret < 0) {
> > > > > > +             audit_mark->path = NULL;
> > > > > >               fsnotify_put_mark(&audit_mark->mark);
> > > >
> > > > As I'm tracing the code path from audit through fsnotify, and back
> > > > into audit, I'm wondering if we still have a problem.  When
> > > > fsnotify_add_inode_mark() fails it will end up freeing not just
> > > > audit_mark->path, but audit_mark itself via audit_fsnotify_mark_free()
> > > > (via a call into fsnotify_put_mark()), yes?
> > >
> > > I don't think so. fsnotify_add_mark_locked() will call fsnotify_put_mark()
> > > but that is just a counter part to fsnotify_get_mark() a few lines above.
> > > The caller of fsnotify_add_inode_mark() still holds its own mark reference
> > > which prevents mark from being freed.
> >
> > Okay, that sounds reasonable, but I'm still looking for a code path
> > that only frees audit_mark:path and not the audit_mark itself.  What
> > am I not seeing?
>
> The callers of audit_alloc_mark() call kfree(path) if audit_alloc_mark()
> returns error (which is a sensible thing because in some cases path indeed
> needs freeing).

Of course!  Thanks for that, I think I got a bit of tunnel vision on
this for some reason.

I'll merge this into audit/stable-6.0 now and once testing is complete
I'll send it up to Linus.  Thanks everyone!

-- 
paul-moore.com

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

* Re: [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark
  2022-08-22 22:49           ` Paul Moore
@ 2022-08-23  2:06             ` cuigaosheng
  0 siblings, 0 replies; 8+ messages in thread
From: cuigaosheng @ 2022-08-23  2:06 UTC (permalink / raw)
  To: Paul Moore, Jan Kara, cuigaosheng1
  Cc: eparis, mszeredi, amir73il, linux-audit, linux-kernel


在 2022/8/23 6:49, Paul Moore 写道:
> On Mon, Aug 22, 2022 at 1:59 PM Jan Kara <jack@suse.cz> wrote:
>> On Mon 22-08-22 13:39:23, Paul Moore wrote:
>>> On Mon, Aug 22, 2022 at 11:20 AM Jan Kara <jack@suse.cz> wrote:
>>>> On Mon 22-08-22 10:34:15, Paul Moore wrote:
>>>>> On Mon, Aug 22, 2022 at 4:50 AM Jan Kara <jack@suse.cz> wrote:
>>>>>> On Mon 22-08-22 10:29:05, Gaosheng Cui wrote:
>>>>>>> Audit_alloc_mark() assign pathname to audit_mark->path, on error path
>>>>>>> from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
>>>>>>> of audit_mark->path, but the caller of audit_alloc_mark will free
>>>>>>> the pathname again, so there will be double free problem.
>>>>>>>
>>>>>>> Fix this by resetting audit_mark->path to NULL pointer on error path
>>>>>>> from fsnotify_add_inode_mark().
>>>>>>>
>>>>>>> Fixes: 7b1293234084d ("fsnotify: Add group pointer in fsnotify_init_mark()")
>>>>>>> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
>>>>>> Good spotting! The patch looks good to me. Feel free to add:
>>>>>>
>>>>>> Reviewed-by: Jan Kara <jack@suse.cz>
>>>>>>
>>>>>>> ---
>>>>>>>   kernel/audit_fsnotify.c | 1 +
>>>>>>>   1 file changed, 1 insertion(+)
>>>>>>>
>>>>>>> diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
>>>>>>> index 6432a37ac1c9..c565fbf66ac8 100644
>>>>>>> --- a/kernel/audit_fsnotify.c
>>>>>>> +++ b/kernel/audit_fsnotify.c
>>>>>>> @@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
>>>>>>>
>>>>>>>        ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
>>>>>>>        if (ret < 0) {
>>>>>>> +             audit_mark->path = NULL;
>>>>>>>                fsnotify_put_mark(&audit_mark->mark);
>>>>> As I'm tracing the code path from audit through fsnotify, and back
>>>>> into audit, I'm wondering if we still have a problem.  When
>>>>> fsnotify_add_inode_mark() fails it will end up freeing not just
>>>>> audit_mark->path, but audit_mark itself via audit_fsnotify_mark_free()
>>>>> (via a call into fsnotify_put_mark()), yes?
>>>> I don't think so. fsnotify_add_mark_locked() will call fsnotify_put_mark()
>>>> but that is just a counter part to fsnotify_get_mark() a few lines above.
>>>> The caller of fsnotify_add_inode_mark() still holds its own mark reference
>>>> which prevents mark from being freed.
>>> Okay, that sounds reasonable, but I'm still looking for a code path
>>> that only frees audit_mark:path and not the audit_mark itself.  What
>>> am I not seeing?
>> The callers of audit_alloc_mark() call kfree(path) if audit_alloc_mark()
>> returns error (which is a sensible thing because in some cases path indeed
>> needs freeing).
> Of course!  Thanks for that, I think I got a bit of tunnel vision on
> this for some reason.
>
> I'll merge this into audit/stable-6.0 now and once testing is complete
> I'll send it up to Linus.  Thanks everyone!

Thanks for taking the time to review this patch. Thanks everyone!


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

end of thread, other threads:[~2022-08-23  2:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-22  2:29 [PATCH next] audit: fix potential double free on error path from fsnotify_add_inode_mark Gaosheng Cui
2022-08-22  8:50 ` Jan Kara
2022-08-22 14:34   ` Paul Moore
2022-08-22 15:20     ` Jan Kara
2022-08-22 17:39       ` Paul Moore
2022-08-22 17:59         ` Jan Kara
2022-08-22 22:49           ` Paul Moore
2022-08-23  2:06             ` cuigaosheng

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).