Skip to content

Commit 4d73eae

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for net: 1) Out-of-bound access to packet data from the snmp nat helper, from Jann Horn. 2) ICMP(v6) error packets are set as related traffic by conntrack, update protocol number before calling nf_nat_ipv4_manip_pkt() to use ICMP(v6) rather than the original protocol number, from Florian Westphal. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 31b58ad + 8303b7e commit 4d73eae

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎net/ipv4/netfilter/nf_nat_l3proto_ipv4.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb,
215215

216216
/* Change outer to look like the reply to an incoming packet */
217217
nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
218+
target.dst.protonum = IPPROTO_ICMP;
218219
if (!nf_nat_ipv4_manip_pkt(skb, 0, &target, manip))
219220
return 0;
220221

‎net/ipv4/netfilter/nf_nat_snmp_basic_main.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ static void fast_csum(struct snmp_ctx *ctx, unsigned char offset)
105105
int snmp_version(void *context, size_t hdrlen, unsigned char tag,
106106
const void *data, size_t datalen)
107107
{
108+
if (datalen != 1)
109+
return -EINVAL;
108110
if (*(unsigned char *)data > 1)
109111
return -ENOTSUPP;
110112
return 1;
@@ -114,8 +116,11 @@ int snmp_helper(void *context, size_t hdrlen, unsigned char tag,
114116
const void *data, size_t datalen)
115117
{
116118
struct snmp_ctx *ctx = (struct snmp_ctx *)context;
117-
__be32 *pdata = (__be32 *)data;
119+
__be32 *pdata;
118120

121+
if (datalen != 4)
122+
return -EINVAL;
123+
pdata = (__be32 *)data;
119124
if (*pdata == ctx->from) {
120125
pr_debug("%s: %pI4 to %pI4\n", __func__,
121126
(void *)&ctx->from, (void *)&ctx->to);

‎net/ipv6/netfilter/nf_nat_l3proto_ipv6.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,
226226
}
227227

228228
nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
229+
target.dst.protonum = IPPROTO_ICMPV6;
229230
if (!nf_nat_ipv6_manip_pkt(skb, 0, &target, manip))
230231
return 0;
231232

0 commit comments

Comments
 (0)