Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drbd: Add NULL check for net_conf to prevent dereference in state validation

If the net_conf pointer is NULL and the code attempts to access its
fields without a check, it will lead to a null pointer dereference.
Add a NULL check before dereferencing the pointer.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 44ed167da748 ("drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf")
Cc: stable@vger.kernel.org
Signed-off-by: Mikhail Lobanov <m.lobanov@rosalinux.ru>
Link: https://lore.kernel.org/r/20240909133740.84297-1-m.lobanov@rosalinux.ru
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Mikhail Lobanov and committed by
Jens Axboe
a5e61b50 acc8c0a9

+1 -1
+1 -1
drivers/block/drbd/drbd_state.c
··· 876 876 ns.disk == D_OUTDATED) 877 877 rv = SS_CONNECTED_OUTDATES; 878 878 879 - else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && 879 + else if (nc && (ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && 880 880 (nc->verify_alg[0] == 0)) 881 881 rv = SS_NO_VERIFY_ALG; 882 882