From: David Miller <davem@davemloft.net>
To: dan.carpenter@oracle.com
Cc: kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org,
kaber@trash.net, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch -next] net: writes past the end of the struct
Date: Wed, 11 Jul 2012 08:27:45 +0000 [thread overview]
Message-ID: <20120711.012745.2202204429130083377.davem@davemloft.net> (raw)
In-Reply-To: <20120711063214.GA11812@elgon.mountain>
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 11 Jul 2012 09:32:14 +0300
> There are a couple places that try to set part of the struct to 0 by
> doing:
>
> memset(&rt->rt6i_table, 0, sizeof(*rt) - sizeof(struct dst_entry));
>
> It assumes that the first element is a dst_entry and the second element
> is ->rt6_table. The problem is we changed the struct in 97cac0821a
> ('ipv6: Store route neighbour in rt6_info struct.') and we aren't
> clearing rt->n but instead we're writing past the end of the array.
>
> I've changed it to:
> memset(&rt->n, 0, sizeof(*rt) - offsetof(struct rt6_info, n));
>
> The memset in ip6_dst_alloc() was ok but I changed it to use offsetof()
> as a cleanup.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Steffen Klassert had patches to do this more nicely, using "dst + 1"
as the pointer calculation, which therefore works no matter what
elements we add to struct rt6_info after the dst_entry.
I asked him to fix some things, he did too much casting, but he never
respun his patch set. I definitely prefer this gets fixed his way.
http://patchwork.ozlabs.org/patch/169391/
http://patchwork.ozlabs.org/patch/169395/
next prev parent reply other threads:[~2012-07-11 8:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 6:32 [patch -next] net: writes past the end of the struct Dan Carpenter
2012-07-11 8:27 ` David Miller [this message]
2012-07-11 8:37 ` Dan Carpenter
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=20120711.012745.2202204429130083377.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=dan.carpenter@oracle.com \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--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