Whamcloud - gitweb
LU-17000 lnet: fix use-after-free in lnet_startup_lndnet 06/51806/2
authorTimothy Day <timday@amazon.com>
Sat, 29 Jul 2023 19:58:47 +0000 (19:58 +0000)
committerOleg Drokin <green@whamcloud.com>
Sat, 19 Aug 2023 05:38:33 +0000 (05:38 +0000)
If the lnd_startup function returns a positive
error code, the ni will get freed. But the code
incorrectly checks only for negative error codes,
leading to a potential use-after-free.

Addresses-Coverity-ID: 397786 ("Use after free")

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I36dd4dbfc0b409de010257e5d9ae9d983fd1817f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51806
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/api-ni.c

index 95dfbf7..8251b81 100644 (file)
@@ -2717,7 +2717,7 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun)
 
                rc = lnet_startup_lndni(ni, tun);
 
-               if (rc < 0)
+               if (rc != 0)
                        goto failed1;
 
                lnet_ni_addref(ni);