netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: vnuorval@tcs.hut.fi
Cc: yoshfuji@linux-ipv6.org, netdev@vger.kernel.org
Subject: Re: [PATCH] IPv6: Fix NULL dereference in ipv6_del_addr()
Date: Sun, 19 Nov 2006 17:51:21 -0500 (EST)	[thread overview]
Message-ID: <20061119.175121.85391637.davem@davemloft.net> (raw)
In-Reply-To: <455E0D19.1060405@tcs.hut.fi>

From: Ville Nuorvala <vnuorval@tcs.hut.fi>
Date: Fri, 17 Nov 2006 21:27:21 +0200

> YOSHIFUJI Hideaki wrote:
> > In article <455DB884.3050203@tcs.hut.fi> (at Fri, 17 Nov 2006 15:26:28 +0200), Ville Nuorvala <vnuorval@tcs.hut.fi> says:
> > 
> > 
> >> -		dst_release(&rt->u.dst);
> >> +		if (rt)
> >> +			dst_release(&rt->u.dst);
> >>  	}
> > 
> > I disagree.  This does NOT fix any bugs.
> > 
> > (void *)&rt->u.dst is ever equal to (void*)rt, and
> > dst_release() checks if the argument is NULL.
> 
> As the check is unnecessary you probably want to clean up the other 
> places where rt is checked before &rt->u.dst is passed, as well ;-)
> This is done at least in addrconf.c, ndisc.c and route.c...
> 
> Seriously though, you are probably right about the pointer being equal 
> to NULL in this case,  but does the C language actually guarantee that 
> the pointer to the structure and its first element are equal, or is it 
> implementation dependent? I don't have my K&R here, so I can't check.

I would imagine that it does.  We rely on similar struct layout
semantics in other areas of the networking.

Also, in the past I've been told by GCC folks that the only way to
guarentee that two objects appear together, one after another, in
the .data segment is to place them into a structure :)

I don't think, therefore, that this will ever break.

      reply	other threads:[~2006-11-19 22:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-17 13:26 [PATCH] IPv6: Fix NULL dereference in ipv6_del_addr() Ville Nuorvala
2006-11-17 14:26 ` YOSHIFUJI Hideaki / 吉藤英明
2006-11-17 19:27   ` Ville Nuorvala
2006-11-19 22:51     ` David Miller [this message]

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=20061119.175121.85391637.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=vnuorval@tcs.hut.fi \
    --cc=yoshfuji@linux-ipv6.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).