Skip to content

Commit f3c0eb0

Browse files
dcarattiummakynes
authored andcommitted
netfilter: conntrack: fix false CRC32c mismatch using paged skb
sctp_compute_cksum() implementation assumes that at least the SCTP header is in the linear part of skb: modify conntrack error callback to avoid false CRC32c mismatch, if the transport header is partially/entirely paged. Fixes: cf6e007 ("netfilter: conntrack: validate SCTP crc32c in PREROUTING") Signed-off-by: Davide Caratti <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 6d18c73 commit f3c0eb0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

net/netfilter/nf_conntrack_proto_sctp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,16 +512,19 @@ static int sctp_error(struct net *net, struct nf_conn *tpl, struct sk_buff *skb,
512512
u8 pf, unsigned int hooknum)
513513
{
514514
const struct sctphdr *sh;
515-
struct sctphdr _sctph;
516515
const char *logmsg;
517516

518-
sh = skb_header_pointer(skb, dataoff, sizeof(_sctph), &_sctph);
519-
if (!sh) {
517+
if (skb->len < dataoff + sizeof(struct sctphdr)) {
520518
logmsg = "nf_ct_sctp: short packet ";
521519
goto out_invalid;
522520
}
523521
if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&
524522
skb->ip_summed == CHECKSUM_NONE) {
523+
if (!skb_make_writable(skb, dataoff + sizeof(struct sctphdr))) {
524+
logmsg = "nf_ct_sctp: failed to read header ";
525+
goto out_invalid;
526+
}
527+
sh = (const struct sctphdr *)(skb->data + dataoff);
525528
if (sh->checksum != sctp_compute_cksum(skb, dataoff)) {
526529
logmsg = "nf_ct_sctp: bad CRC ";
527530
goto out_invalid;

0 commit comments

Comments
 (0)