Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1244240

Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP SNMP counter values

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Ben Cox <ben@benjojo.co.uk>
Newsgroups linux.kernel
Subject Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP SNMP counter values
Date Mon, 12 Oct 2015 00:20:02 +0200
Message-ID <qix8e-4PI-15@gated-at.bofh.it> (permalink)
References <qiwvw-3Qd-15@gated-at.bofh.it> <qix8d-4PI-1@gated-at.bofh.it>
X-Original-To Eric Dumazet <eric.dumazet@gmail.com>
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Rh2nBIeg/ODiGs0HC1GF+yHZS6lmC4BCTafQIS94DUM=; b=lxxAOVm5YtTcMIULTDp4xpIdf6s7zSDBlkUahvHGWW5GSlFe3vLL5pH5JbrYl9h11y piRb9yYWD6X15Hn/EJwuS6gAx9kdnwoBIaXRRG4YNlFX2CvWzJjW8gw2u9YHbyAoVJB2 PHDNqJzbgGmEnBeg26edP90pEPdZFh4MbFzv+RQ4WHEZeVo7TDU1oPXgmRPFj7JW8ncg L9kDEKYzduClQtMNYjn2Bnr4SKumWacX0XmP+PaA8+AjHiTKCwkLH2jgpTmE0Qm6kHeQ vZIcwU2VVK2QMuk7uXQgRKfGuUU7r4i4tiUZYvOis7bZrUZmzuuq4esnnGFTdCVZepCp D1Pw==
X-Gm-Message-State ALoCoQmbnyvAAJcorTiywGTVwyv7BMO5OmoeCAwI2mK6hxiHiy+Jzld71z8G0BykQ2wa/XMW//wZ
MIME-Version 1.0
X-Received by 10.13.255.194 with SMTP id p185mr20481554ywf.207.1444601822435; Sun, 11 Oct 2015 15:17:02 -0700 (PDT)
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 54
Organization linux.* mail to news gateway
X-Original-Cc Ben Cartwright-Cox <ben@benjojo.co.uk>, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ben+patches@benjojo.co.uk, David L Stevens <dlstevens@us.ibm.com>
X-Original-Date Sun, 11 Oct 2015 23:17:02 +0100
X-Original-Message-ID <CAL=9YSVgnCDzZkDM4JujD89V3GpUnDGXyMk7qMnWg7LtmT5G7w@mail.gmail.com>
X-Original-References <20151011205528.GA4322@benjojo.co.uk> <1444601448.27760.143.camel@edumazet-glaptop2.roam.corp.google.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1244240

Show key headers only | View raw


Forgive me for possibly being a little stupid here (This is my first
patch to Linux so I am slightly over my head)

Is this issue not addressed above the file where the following check is done?

if (iphlen > length)
    goto error_free;



On Sun, Oct 11, 2015 at 11:10 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Sun, 2015-10-11 at 20:55 +0000, Ben Cartwright-Cox wrote:
>> Sending ICMP packets with raw sockets ends up in the SNMP counters
>> logging the type as the first byte of the IPv4 header rather than
>> the ICMP header (in nearly all cases this is seen as "OutType69".
>> This is fixed by adding the IP Header Length to the casting into
>> a icmphdr struct.
>>
>> Signed-off-by: Ben Cartwright-Cox <ben@benjojo.co.uk>
>> ---
>>  net/ipv4/raw.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
>> index 561cd4b..1ad8bae 100644
>> --- a/net/ipv4/raw.c
>> +++ b/net/ipv4/raw.c
>> @@ -409,7 +409,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
>>       }
>>       if (iph->protocol == IPPROTO_ICMP)
>>               icmp_out_count(net, ((struct icmphdr *)
>> -                     skb_transport_header(skb))->type);
>> +                     skb_transport_header(skb) + iphlen)->type);
>>
>>       err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, sk, skb,
>>                     NULL, rt->dst.dev, dst_output_sk);
>
>
> Hmm... This seems to lack checks against a malicious user ?
>
> The only guarantee you have here is that iphlen < length.
>
> It is not enough.
>
> Make sure you do not access not initialized memory or even non existent
> one.
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP SNMP  counter values Ben Cartwright-Cox <ben@benjojo.co.uk> - 2015-10-11 23:40 +0200
  Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP  SNMP counter values Eric Dumazet <eric.dumazet@gmail.com> - 2015-10-12 00:20 +0200
    Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP  SNMP counter values Ben Cox <ben@benjojo.co.uk> - 2015-10-12 00:20 +0200
      Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP  SNMP counter values Eric Dumazet <eric.dumazet@gmail.com> - 2015-10-12 00:50 +0200
        Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP  SNMP counter values Eric Dumazet <eric.dumazet@gmail.com> - 2015-10-12 00:50 +0200
          Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP  SNMP counter values Eric Dumazet <eric.dumazet@gmail.com> - 2015-10-12 01:20 +0200
            Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP  SNMP counter values Ben Cox <ben@benjojo.co.uk> - 2015-10-12 01:20 +0200
              Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP  SNMP counter values Eric Dumazet <eric.dumazet@gmail.com> - 2015-10-12 01:40 +0200

csiph-web