[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210329135740.GB4283@quack2.suse.cz>
Date: Mon, 29 Mar 2021 15:57:40 +0200
From: Jan Kara <jack@...e.cz>
To: lyl2019@...l.ustc.edu.cn
Cc: jack@...e.cz, amir73il@...il.com, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [BUG] fs/notify/mark: A potential use after free in
fsnotify_put_mark_wake
Hello!
On Sun 28-03-21 17:11:43, lyl2019@...l.ustc.edu.cn wrote:
> My static analyzer tool reported a use after free in fsnotify_put_mark_wake
> of the file: fs/notify/mark.c.
>
> In fsnotify_put_mark_wake, it calls fsnotify_put_mark(mark). Inside the function
> fsnotify_put_mark(), if conn is NULL, it will call fsnotify_final_mark_destroy(mark)
> to free mark->group by fsnotify_put_group(group) and return. I also had inspected
> the implementation of fsnotify_put_group() and found that there is no cleanup operation
> about group->user_waits.
>
> But after fsnotify_put_mark_wake() returned, mark->group is still used by
> if (atomic_dec_and_test(&group->user_waits) && group->shutdown) and later.
>
> Is this an issue?
I don't think this scenario is possible. fsnotify_put_mark_wake() can be
called only for marks attached to objects and these have mark->conn !=
NULL and we are sure that fsnotify_destroy_group() will wait for all such
marks to be torn down and freed before dropping last group reference and
freeing the group.
Honza
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists