Re: [PATCH] kernfs: fix NULL dereferencing in kernfs_remove

From: Tejun Heo
Date: Wed Apr 27 2022 - 13:27:51 EST


On Wed, Apr 27, 2022 at 10:21:51AM -0700, Minchan Kim wrote:
> kernfs_remove supported NULL kernfs_node param to bail out but revent
^
typo
> per-fs lock change introduced regression that dereferencing the
> param without NULL check so kernel goes crash.
>
> This patch checks the NULL kernfs_node in kernfs_remove and if so,
> just return.
...
> Cc: stable@xxxxxxxxxxxxxxx
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=215696
> Link: https://lore.kernel.org/lkml/CAE4VaGDZr_4wzRn2___eDYRtmdPaGGJdzu_LCSkJYuY9BEO3cw@xxxxxxxxxxxxxx/
> Fixes: 393c3714081a (kernfs: switch global kernfs_rwsem lock to per-fs lock)
> Reported-by: Jirka Hladky <jhladky@xxxxxxxxxx>
> Tested-by: Jirka Hladky <jhladky@xxxxxxxxxx>
> Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>

Acked-by: Tejun Heo <tj@xxxxxxxxxx>

Thanks.

--
tejun