[lvc-project] [PATCH] gfs2: Fix NULL pointer dereference in gfs2_log_flush
Fedor Pchelkin
pchelkin at ispras.ru
Mon Apr 6 12:09:54 MSK 2026
On Mon, 06. Apr 10:40, Nikolai Kuznetsov wrote:
> In gfs2_log_flush(), the pointer sdp->sd_jdesc is dereferenced without
> a prior check. During mount or umount, sd_jdesc may remain NULL while
> the log flush operation is triggered.
>
> Prevent the crash by adding a gfs2_assert_withdraw() that verifies
> sd_jdesc is not NULL.
gfs2_assert_withdraw() предотвращает выполнение текущей функции?
Насколько понимаю, нет. Т.е. от потенциального дальнейшего креша не
спасёт. Также при определённых флагах монтирования ядро может
запаниковать внутри самой gfs2_assert_withdraw(). Польза от правки пока
непонятна.
Без контекста не очень ясно, на какой ветке ядра встретили срабатывание
стат. анализатора и готовили исправление? Бывает полезно осматривать
состояние исследуемого кода в самом свежем апстрим-репозитории ядра [1].
Каков статус проблемы там?
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Nikolai Kuznetsov <niku.csmsu at yandex.ru>
> ---
> fs/gfs2/log.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
> index 347df29d610e..53bf9f68a842 100644
> --- a/fs/gfs2/log.c
> +++ b/fs/gfs2/log.c
> @@ -1036,6 +1036,8 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
> down_write(&sdp->sd_log_flush_lock);
> trace_gfs2_log_flush(sdp, 1, flags);
>
> + gfs2_assert_withdraw(sdp, sdp->sd_jdesc != NULL);
> +
> repeat:
> /*
> * Do this check while holding the log_flush_lock to prevent new
> --
> 2.43.0
More information about the lvc-project
mailing list