Skip to contentSkip to conversation

sctp: load transport header after sk_filter

PATCH In review Willem de Bruijn 3 participants 4 messages Jul 16, 2016 – Jul 18, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: load transport header after sk_filter

From: Willem de Bruijn <[email protected]>

Do not cache pointers into the skb linear segment across sk_filter. The function call can trigger pskb_expand_head.

---

No Fixes tag: existed at the start of git log.

It is probably not necessary to store chunk->sctp_hdr at all, as chunk->skb exists. That is harder to verify, so not suitable for net.

SCTP sk_filter trimming does not work as expected for most packets. sctp_inq_pop marks most truncated linear packets as discarded with pdiscard = 1. The following crude change would make trimming behave as expected on linear data chunks but is probably not safe as is.

- if (unlikely(skb_is_nonlinear(chunk->skb))) {
+ if (1) {

---
 net/sctp/input.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
net/sctp/input.c +1 -4
index a701527..47cf460 100644
@@ -112,7 +112,6 @@ int sctp_rcv(struct sk_buff *skb)
 	struct sctp_ep_common *rcvr;
 	struct sctp_transport *transport = NULL;
 	struct sctp_chunk *chunk;
-	struct sctphdr *sh;
 	union sctp_addr src;
 	union sctp_addr dest;
 	int family;
@@ -127,8 +126,6 @@ int sctp_rcv(struct sk_buff *skb)
 	if (skb_linearize(skb))
 		goto discard_it;
 
-	sh = sctp_hdr(skb);
-
 	/* Pull up the IP and SCTP headers. */
 	__skb_pull(skb, skb_transport_offset(skb));
 	if (skb->len < sizeof(struct sctphdr))
@@ -230,7 +227,7 @@ int sctp_rcv(struct sk_buff *skb)
 	chunk->rcvr = rcvr;
 
 	/* Remember the SCTP header. */
-	chunk->sctp_hdr = sh;
+	chunk->sctp_hdr = sctp_hdr(skb);
 
 	/* Set the source and destination addresses of the incoming chunk.  */
 	sctp_init_addrs(chunk, &src, &dest);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw
Quoted 4 lines

Do not cache pointers into the skb linear segment across sk_filter. The function call can trigger pskb_expand_head.

This is targeted at net.

I forgot to pass the right --subject-prefix='PATCH net'

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Willem de Bruijn
Quoted 6 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Do not cache pointers into the skb linear segment across sk_filter. The function call can trigger pskb_expand_head.

Just note that this change is included in 3acb50c18d8d ("sctp: delay as much as possible skb_linearize") and accepting this one in net will cause a conflict when merging them. Thanks

Quoted 51 lines

---

No Fixes tag: existed at the start of git log.

It is probably not necessary to store chunk->sctp_hdr at all, as chunk->skb exists. That is harder to verify, so not suitable for net.

SCTP sk_filter trimming does not work as expected for most packets. sctp_inq_pop marks most truncated linear packets as discarded with pdiscard = 1. The following crude change would make trimming behave as expected on linear data chunks but is probably not safe as is.

(quoted diff) +1 -2
-        if (unlikely(skb_is_nonlinear(chunk->skb))) {
+        if (1) {
---
 net/sctp/input.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
net/sctp/input.c +1 -4
index a701527..47cf460 100644
@@ -112,7 +112,6 @@ int sctp_rcv(struct sk_buff *skb)
 	struct sctp_ep_common *rcvr;
 	struct sctp_transport *transport = NULL;
 	struct sctp_chunk *chunk;
-	struct sctphdr *sh;
 	union sctp_addr src;
 	union sctp_addr dest;
 	int family;
@@ -127,8 +126,6 @@ int sctp_rcv(struct sk_buff *skb)
 	if (skb_linearize(skb))
 		goto discard_it;
 
-	sh = sctp_hdr(skb);
-
 	/* Pull up the IP and SCTP headers. */
 	__skb_pull(skb, skb_transport_offset(skb));
 	if (skb->len < sizeof(struct sctphdr))
@@ -230,7 +227,7 @@ int sctp_rcv(struct sk_buff *skb)
 	chunk->rcvr = rcvr;
 
 	/* Remember the SCTP header. */
-	chunk->sctp_hdr = sh;
+	chunk->sctp_hdr = sctp_hdr(skb);
 
 	/* Set the source and destination addresses of the incoming chunk.  */
 	sctp_init_addrs(chunk, &src, &dest);
Signature · 1 line
2.8.0.rc3.226.g39d4020