mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
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: cf6e007eef
("netfilter: conntrack: validate SCTP crc32c in PREROUTING")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
6d18c732b9
commit
f3c0eb05e2
1 changed files with 6 additions and 3 deletions
|
@ -512,16 +512,19 @@ static int sctp_error(struct net *net, struct nf_conn *tpl, struct sk_buff *skb,
|
|||
u8 pf, unsigned int hooknum)
|
||||
{
|
||||
const struct sctphdr *sh;
|
||||
struct sctphdr _sctph;
|
||||
const char *logmsg;
|
||||
|
||||
sh = skb_header_pointer(skb, dataoff, sizeof(_sctph), &_sctph);
|
||||
if (!sh) {
|
||||
if (skb->len < dataoff + sizeof(struct sctphdr)) {
|
||||
logmsg = "nf_ct_sctp: short packet ";
|
||||
goto out_invalid;
|
||||
}
|
||||
if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&
|
||||
skb->ip_summed == CHECKSUM_NONE) {
|
||||
if (!skb_make_writable(skb, dataoff + sizeof(struct sctphdr))) {
|
||||
logmsg = "nf_ct_sctp: failed to read header ";
|
||||
goto out_invalid;
|
||||
}
|
||||
sh = (const struct sctphdr *)(skb->data + dataoff);
|
||||
if (sh->checksum != sctp_compute_cksum(skb, dataoff)) {
|
||||
logmsg = "nf_ct_sctp: bad CRC ";
|
||||
goto out_invalid;
|
||||
|
|
Loading…
Reference in a new issue