qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Nickolai Zeldovich <nickolai@csail.mit.edu>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] slirp: Don't crash on packets from 0.0.0.0/8.
Date: Mon, 12 Nov 2012 10:37:26 +0100	[thread overview]
Message-ID: <50A0C356.6090905@siemens.com> (raw)
In-Reply-To: <1352681983-23159-1-git-send-email-nickolai@csail.mit.edu>

On 2012-11-12 01:59, Nickolai Zeldovich wrote:
> LWIP can generate packets with a source of 0.0.0.0, which triggers an
> assertion failure in arp_table_add().  Instead of crashing, simply return
> to avoid adding an invalid ARP table entry.

I would prefer to filter out such invalid packets at a different level.
Did you analyzed which path it takes through the stack?

> 
> Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
> ---
>  slirp/arp_table.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/slirp/arp_table.c b/slirp/arp_table.c
> index 5d7b8ac..3318ce9 100644
> --- a/slirp/arp_table.c
> +++ b/slirp/arp_table.c
> @@ -38,7 +38,8 @@ void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN])
>                  ethaddr[3], ethaddr[4], ethaddr[5]));
>  
>      /* Check 0.0.0.0/8 invalid source-only addresses */
> -    assert((ip_addr & htonl(~(0xf << 28))) != 0);
> +    if ((ip_addr & htonl(~(0xf << 28))) == 0)
> +        return;

Please follow our coding style. There is also checkpatch.pl to help you.

>  
>      if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
>          /* Do not register broadcast addresses */
> 

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux

  reply	other threads:[~2012-11-12  9:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-12  0:59 [Qemu-devel] [PATCH] slirp: Don't crash on packets from 0.0.0.0/8 Nickolai Zeldovich
2012-11-12  9:37 ` Jan Kiszka [this message]
2012-11-12 14:41   ` Nickolai Zeldovich
2012-11-12 16:24     ` Jan Kiszka

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=50A0C356.6090905@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=nickolai@csail.mit.edu \
    --cc=qemu-devel@nongnu.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).