aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-11-19 19:54:48 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-21 14:46:12 -0500
commitf869c912869edc2754355af9e10e5aaff8ff5a40 (patch)
treee70a9e95f1b235903f50821d8c9f3a0dd7842fda /net/sctp
parent44c8bc3ce39f4cbeb7bf13162666fb6d0aad864d (diff)
net: sctp: keep owned chunk in destructor_arg instead of skb->cb
It's just silly to hold the skb destructor argument around inside skb->cb[] as we currently do in SCTP. Nowadays, we're sort of cheating on data accounting in the sense that due to commit 4c3a5bdae293 ("sctp: Don't charge for data in sndbuf again when transmitting packet"), we orphan the skb already in the SCTP output path, i.e. giving back charged data memory, and use a different destructor only to make sure the sk doesn't vanish on skb destruction time. Thus, cb[] is still valid here as we operate within the SCTP layer. (It's generally actually a big candidate for future rework, imho.) However, storing the destructor in the cb[] can easily cause issues should an non sctp_packet_set_owner_w()'ed skb ever escape the SCTP layer, since cb[] may get overwritten by lower layers and thus can corrupt the chunk pointer. There are no such issues at present, but lets keep the chunk in destructor_arg, as this is the actual purpose for it. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r--net/sctp/socket.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 2120292c842d..85e0b653edd7 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -162,7 +162,7 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)
162 162
163 chunk->skb->destructor = sctp_wfree; 163 chunk->skb->destructor = sctp_wfree;
164 /* Save the chunk pointer in skb for sctp_wfree to use later. */ 164 /* Save the chunk pointer in skb for sctp_wfree to use later. */
165 *((struct sctp_chunk **)(chunk->skb->cb)) = chunk; 165 skb_shinfo(chunk->skb)->destructor_arg = chunk;
166 166
167 asoc->sndbuf_used += SCTP_DATA_SNDSIZE(chunk) + 167 asoc->sndbuf_used += SCTP_DATA_SNDSIZE(chunk) +
168 sizeof(struct sk_buff) + 168 sizeof(struct sk_buff) +
@@ -6870,14 +6870,10 @@ static void sctp_wake_up_waiters(struct sock *sk,
6870 */ 6870 */
6871static void sctp_wfree(struct sk_buff *skb) 6871static void sctp_wfree(struct sk_buff *skb)
6872{ 6872{
6873 struct sctp_association *asoc; 6873 struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg;
6874 struct sctp_chunk *chunk; 6874 struct sctp_association *asoc = chunk->asoc;
6875 struct sock *sk; 6875 struct sock *sk = asoc->base.sk;
6876 6876
6877 /* Get the saved chunk pointer. */
6878 chunk = *((struct sctp_chunk **)(skb->cb));
6879 asoc = chunk->asoc;
6880 sk = asoc->base.sk;
6881 asoc->sndbuf_used -= SCTP_DATA_SNDSIZE(chunk) + 6877 asoc->sndbuf_used -= SCTP_DATA_SNDSIZE(chunk) +
6882 sizeof(struct sk_buff) + 6878 sizeof(struct sk_buff) +
6883 sizeof(struct sctp_chunk); 6879 sizeof(struct sctp_chunk);