Skip to contentSkip to conversation

net: Check if nc is NULL in qemu_get_vnet_hdr_len()

PATCH In review Akihiko Odaki 5 participants 5 messages Aug 17, 2024 – Oct 18, 2024 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: Check if nc is NULL in qemu_get_vnet_hdr_len()

A netdev may not have a peer specified, resulting in NULL. We should make it behave like /dev/null in such a case instead of letting it cause segmentatin fault.

Fixes 4b52d63249a5 ("tap: Remove qemu_using_vnet_hdr()")
---
 net/net.c | 4 ++++
 1 file changed, 4 insertions(+)
net/net.c +4 -0
index 6938da05e077..4c21d91f9450 100644
@@ -542,6 +542,10 @@ void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
 
 int qemu_get_vnet_hdr_len(NetClientState *nc)
 {
+    if (!nc) {
+        return 0;
+    }
+
     return nc->vnet_hdr_len;
 }
 

---
base-commit: 31669121a01a14732f57c49400bc239cf9fd505f
change-id: 20240817-net-dc461895a295

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>
#1 lore raw
Quoted 7 lines · On Sat, 17 Aug 2024 16:00:43 +0900 Akihiko Odaki <[email protected]>…

A netdev may not have a peer specified, resulting in NULL. We should make it behave like /dev/null in such a case instead of letting it cause segmentatin fault.

Fixes 4b52d63249a5 ("tap: Remove qemu_using_vnet_hdr()")

FWIW fixed my issue. I'd forgotten about but noticed that it was still in my tree after a rebase.

Tested-by; Jonathan Cameron <[email protected]>

Quoted 25 lines
---
 net/net.c | 4 ++++
 1 file changed, 4 insertions(+)
net/net.c +4 -1
index 6938da05e077..4c21d91f9450 100644
@@ -542,6 +542,10 @@ void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
 
 int qemu_get_vnet_hdr_len(NetClientState *nc)
 {
+    if (!nc) {
+        return 0;
+    }
+
     return nc->vnet_hdr_len;
 }
 
 
---

base-commit: 31669121a01a14732f57c49400bc239cf9fd505f
change-id: 20240817-net-dc461895a295

Best regards,

Acked-by on v1 1/1
#2 lore raw
In reply to Akihiko Odaki
Quoted 3 lines · Akihiko Odaki

A netdev may not have a peer specified, resulting in NULL. We should make it behave like /dev/null in such a case instead of letting it cause segmentatin fault.

segmentation

Quoted 4 lines
Fixes 4b52d63249a5 ("tap: Remove qemu_using_vnet_hdr()")

Jason, you tree?

Quoted 27 lines
---
 net/net.c | 4 ++++
 1 file changed, 4 insertions(+)
net/net.c +4 -1
index 6938da05e077..4c21d91f9450 100644
@@ -542,6 +542,10 @@ void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
 
 int qemu_get_vnet_hdr_len(NetClientState *nc)
 {
+    if (!nc) {
+        return 0;
+    }
+
     return nc->vnet_hdr_len;
 }
 
 
---

base-commit: 31669121a01a14732f57c49400bc239cf9fd505f
change-id: 20240817-net-dc461895a295

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>
#3 lore raw
Quoted 9 lines · Michael S. Tsirkin
Quoted 3 lines · Akihiko Odaki

A netdev may not have a peer specified, resulting in NULL. We should make it behave like /dev/null in such a case instead of letting it cause segmentatin fault.

segmentation

Quoted 1 line
Quoted 9 lines
Quoted 3 lines
Fixes 4b52d63249a5 ("tap: Remove qemu_using_vnet_hdr()")

Jason, you tree?

Yes.

Queued.

Thanks

#4 lore raw
In reply to Akihiko Odaki
Quoted 5 lines · Akihiko Odaki

A netdev may not have a peer specified, resulting in NULL. We should make it behave like /dev/null in such a case instead of letting it cause segmentatin fault.

Fixes 4b52d63249a5 ("tap: Remove qemu_using_vnet_hdr()")

Feels like qemu-stable material (Cc'd).

/mjt