[ovs-dev] [PATCH v2] netdev-linux: Fix a null pointer dereference in netdev_linux_notify_sock()

Yunjian Wang wangyunjian at huawei.com
Sat Sep 11 06:34:47 UTC 2021


If nl_sock_join_mcgroup() returns an error, the 'sock' is freed and
set to NULL. This issues will lead to null pointer deference in
nl_sock_listen_all_nsid(). To fix it, we call nl_sock_listen_all_nsid()
before joining the mcgroups.

Fixes: cf114a7fce80 ("netlink linux: enable listening to all nsids")
Cc: Flavio Leitner <fbl at redhat.com>
Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
---
v2:
   update code style suggested by David Marchand
---
 lib/netdev-linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 60dd13891..97bd21be4 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -627,6 +627,7 @@ netdev_linux_notify_sock(void)
         if (!error) {
             size_t i;
 
+            nl_sock_listen_all_nsid(sock, true);
             for (i = 0; i < ARRAY_SIZE(mcgroups); i++) {
                 error = nl_sock_join_mcgroup(sock, mcgroups[i]);
                 if (error) {
@@ -636,7 +637,6 @@ netdev_linux_notify_sock(void)
                 }
             }
         }
-        nl_sock_listen_all_nsid(sock, true);
         ovsthread_once_done(&once);
     }
 
-- 
2.18.1



More information about the dev mailing list