net: rose: use pskb_may_pull() in CLEAR_REQUEST length check
Subsystems (2)
PATCH 1/1 net: rose: use pskb_may_pull() in CLEAR_REQUEST length check
Commit 2835750dd647 ("net: rose: reject truncated CLEAR_REQUEST frames in state machines") guards against short CLEAR_REQUEST frames using a plain skb->len comparison. Use pskb_may_pull() instead, which both enforces the length requirement and ensures the bytes are in the linear part of the skb, making the subsequent accesses to skb->data[3] and skb->data[4] safe for non-linear buffers.
--- net/rose/rose_in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rose/rose_in.c +1 -1
@@ -274,7 +274,7 @@ int rose_process_rx_frame(struct sock *sk, struct sk_buff *skb)* ROSE_CLEAR_REQUEST carries cause and diagnostic in bytes 3..4. * Reject a malformed frame that is too short to contain them. */ -if (frametype ==ROSE_CLEAR_REQUEST && skb->len <5 ) +if (frametype ==ROSE_CLEAR_REQUEST && !pskb_may_pull (skb,5 ))return 0 ;switch (rose->state) {
Signature · 1 line
2.34.1
Quoted 6 lines · Ashutosh Desai
Commit
2835750dd647("net: rose: reject truncatedCLEAR_REQUESTframes in state machines") guards against shortCLEAR_REQUESTframes using a plainskb->lencomparison. Usepskb_may_pull()instead, which both enforces the length requirement and ensures the bytes are in the linear part of the skb, making the subsequent accesses to skb->data[3] and skb->data[4] safe for non-linear buffers.
Did you review all the other comparisons on skb->len in rose?
rose_route.c- if (frametype == ROSE_CALL_REQUEST &&rose_route.c: (skb->len <= ROSE_CALL_REQ_FACILITIES_OFF ||
rose_route.c- skb->data[ROSE_CALL_REQ_ADDR_LEN_OFF] !=
rose_route.c- ROSE_CALL_REQ_ADDR_LEN_VAL))
rose_loopback.c- if (frametype == ROSE_CALL_REQUEST &&rose_loopback.c: (skb->len <= ROSE_CALL_REQ_FACILITIES_OFF ||
rose_loopback.c- skb->data[ROSE_CALL_REQ_ADDR_LEN_OFF] !=
Do these need the same fix? Are there other places non linear buffers should be considered?
Andrew
Quoted 3 lines · Andrew Lunn
Did you review all the other comparisons on
skb->lenin rose? Do these need the same fix? Are there other places non linear buffers should be considered?
Reviewed all rose files. Thanks for pointing those out - yes, the two spots in rose_route.c and rose_loopback.c have the same issue and need the same fix.
While reviewing I also noticed rose_link.c: rose_link_rx_restart() accesses skb->data[3] in the ROSE_RESTART_REQUEST case and skb->data[3]/skb->data+4 in the ROSE_DIAGNOSTIC case, with only a ROSE_MIN_LEN (3 bytes) guard upstream in the caller. Same linearity concern.
Is it recommended to send a v2 covering all three files?
Quoted 9 lines · Ashutosh Desai
Quoted 3 lines · Andrew Lunn
Did you review all the other comparisons on
skb->lenin rose? Do these need the same fix? Are there other places non linear buffers should be considered?Reviewed all rose files. Thanks for pointing those out - yes, the two spots in
rose_route.candrose_loopback.chave the same issue and need the same fix.
Quoted 7 lines
While reviewing I also noticed
rose_link.c:rose_link_rx_restart()accesses skb->data[3] in theROSE_RESTART_REQUESTcase and skb->data[3]/skb->data+4 in theROSE_DIAGNOSTICcase, with only aROSE_MIN_LEN(3 bytes) guard upstream in the caller. Same linearity concern.Is it recommended to send a v2 covering all three files?
Too late, Jakub just posted patches deleted it all. See the netdev mailing list.
Andrew