Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] um: vector: NULL skb dereference in vector_mmsg_rx() on
allocation failure
--
commit e31f8cf054920da38ad1454a853c93da403fdef4
Author: Michael S. Tsirkin [off-list ref]
um: vector: trim skbs before verifying the header
This commit moves pskb_trim() ahead of vp->verify_header() in
vector_legacy_rx() and vector_mmsg_rx() so that received skbs are trimmed
before header verification.
quoted hunk ↗ jump to hunk
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index e902e78c5ff67..828bd61995b86 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -989,6 +989,8 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
for (i = 0; i < packet_count; i++) {
skb = (*skbuff_vector);
if (mmsg_vector->msg_len > vp->header_size) {
+ pskb_trim(skb,
+ mmsg_vector->msg_len - vp->rx_header_size);
if (vp->header_size > 0) {
header_check = vp->verify_header(
mmsg_vector->msg_hdr.msg_iov->iov_base,
[Severity: High]
Can pskb_trim() dereference a NULL skb here when allocation fails?
When prep_skb() fails its GFP_ATOMIC allocation with vp->header_size > 0,
it stores NULL in *skbuff_vector while leaving iov[0] sized to
vp->rx_header_size.
For IPv4 GRE, build_gre_transport_data() adds sizeof(struct iphdr) to
vp->rx_header_size, so an incoming packet into that slot can satisfy
mmsg_vector->msg_len > vp->header_size while skb is NULL.
Before this patch, packets rejected by vp->verify_header() went straight
to NULL-safe dev_kfree_skb_irq(skb) and skipped pskb_trim(). Moving
pskb_trim() first causes a NULL pointer dereference in NAPI softirq even
for invalid or unauthenticated packets.
Checking skb != NULL (and mmsg_vector->msg_len > vp->rx_header_size)
before calling pskb_trim() would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204.rfcv11.99731.0.zakinko@snowrabbit.org?part=2