From: Stephen Hemminger <stephen@networkplumber.org>
To: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] netns: Fix an off-by-one strcpy() in netns_map_add().
Date: Wed, 17 Feb 2016 17:55:09 -0800 [thread overview]
Message-ID: <20160217175509.4073210d@xeon-e3> (raw)
In-Reply-To: <1455284859-31210-1-git-send-email-nicolas.cavallari@green-communications.fr>
On Fri, 12 Feb 2016 14:47:39 +0100
Nicolas Cavallari <nicolas.cavallari@green-communications.fr> wrote:
> netns_map_add() does a malloc of (sizeof (struct nsid_cache) +
> strlen(name)) and then proceed with strcpy() of name into the
> zero-length member at the end of the nsid_cache structure. The
> nul-terminator is written outside of the allocated memory and may
> overwrite the allocator's internal structure.
>
> This can trigger a segmentation fault on i386 uclibc with names of size 8:
> after the corruption occurs, the call to closedir() on netns_map_init()
> crashes while freeing the DIR structure.
>
> Here is the relevant valgrind output:
>
> ==1251== Memcheck, a memory error detector
> ==1251== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
> ==1251== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright
> info
> ==1251== Command: ./ip netns
> ==1251==
> ==1251== Invalid write of size 1
> ==1251== at 0x4011975: strcpy (in
> /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
> ==1251== by 0x8058B00: netns_map_add (ipnetns.c:181)
> ==1251== by 0x8058E2A: netns_map_init (ipnetns.c:226)
> ==1251== by 0x8058E79: do_netns (ipnetns.c:776)
> ==1251== by 0x804D9FF: do_cmd (ip.c:110)
> ==1251== by 0x804D814: main (ip.c:300)
Applied, thanks.
prev parent reply other threads:[~2016-02-18 1:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 13:47 [PATCH iproute2] netns: Fix an off-by-one strcpy() in netns_map_add() Nicolas Cavallari
2016-02-18 1:55 ` Stephen Hemminger [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=20160217175509.4073210d@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.cavallari@green-communications.fr \
/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