From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>, netfilter-devel@vger.kernel.org
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Neil Horman <nhorman@tuxdriver.com>,
pablo@netfilter.org
Subject: [PATCH net] netfilter: set skb transport_header before calling sctp_compute_cksum
Date: Sun, 3 Mar 2019 16:17:21 +0800 [thread overview]
Message-ID: <740683890e28e93c1b2e940a28089ca10f006b7f.1551601041.git.lucien.xin@gmail.com> (raw)
sctp_hdr(skb) only works when skb->transport_header is set
properly.
But in the path of nf_conntrack_in:
sctp_packet() -> sctp_error() -> sctp_compute_cksum().
skb->transport_header is not guaranteed to be right value
for sctp. It will cause to fail to check the checksum for
sctp packets.
So fix it by setting skb transport_header before calling
sctp_compute_cksum().
Fixes: e6d8b64b34aa ("net: sctp: fix and consolidate SCTP checksumming code")
Reported-by: Li Shuang <shuali@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
---
net/netfilter/nf_conntrack_proto_sctp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index d53e3e7..6b53cd2 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -343,7 +343,9 @@ static bool sctp_error(struct sk_buff *skb,
logmsg = "nf_ct_sctp: failed to read header ";
goto out_invalid;
}
- sh = (const struct sctphdr *)(skb->data + dataoff);
+ /* sctp_compute_cksum() depends on correct transport header */
+ skb_set_transport_header(skb, dataoff);
+ sh = sctp_hdr(skb);
if (sh->checksum != sctp_compute_cksum(skb, dataoff)) {
logmsg = "nf_ct_sctp: bad CRC ";
goto out_invalid;
--
2.1.0
next reply other threads:[~2019-03-03 8:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-03 8:17 Xin Long [this message]
2019-03-08 15:50 ` [PATCH net] netfilter: set skb transport_header before calling sctp_compute_cksum Pablo Neira Ayuso
2019-03-09 9:07 ` Xin Long
2019-03-09 9:24 ` Florian Westphal
2019-03-11 11:07 ` Neil Horman
2019-03-12 8:39 ` Xin Long
2019-03-12 9:48 ` Pablo Neira Ayuso
2019-03-12 11:01 ` Xin Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=740683890e28e93c1b2e940a28089ca10f006b7f.1551601041.git.lucien.xin@gmail.com \
--to=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).