From: Stephen Hemminger <stephen@networkplumber.org>
To: "Mahesh Bandewar (महेश बंडेवार)" <maheshb@google.com>
Cc: Mahesh Bandewar <mahesh@bandewar.net>, netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH iproute2] iproute2: fix use-after-free
Date: Thu, 13 Sep 2018 08:19:48 -0700 [thread overview]
Message-ID: <20180913081948.1bf8368b@xeon-e3> (raw)
In-Reply-To: <CAF2d9jgpN0T+BuMTk9GwNKVEcmH2V_yC8R=WvWYCZ95E_pkfwg@mail.gmail.com>
On Wed, 12 Sep 2018 23:07:20 -0700
Mahesh Bandewar (महेश बंडेवार) <maheshb@google.com> wrote:
> On Wed, Sep 12, 2018 at 5:33 PM, Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> >
> > On Wed, 12 Sep 2018 16:29:28 -0700
> > Mahesh Bandewar <mahesh@bandewar.net> wrote:
> >
> > > From: Mahesh Bandewar <maheshb@google.com>
> > >
> > > A local program using iproute2 lib pointed out the issue and looking
> > > at the code it is pretty obvious -
> > >
> > > a = (struct nlmsghdr *)b;
> > > ...
> > > free(b);
> > > if (a->nlmsg_seq == seq)
> > > ...
> > >
> > > Fixes: 86bf43c7c2fd ("lib/libnetlink: update rtnl_talk to support malloc buff at run time")
> > > Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> >
> > Yes, this is a real problem.
> >
> > Maybe a minimal patch like this would be enough:
> actually that will leave the memory leak at the 'goto next' line (just
> few lines below) since that jump will overwrite the buf.
It looks like everytime in the while loop. a new buffer is allocated.
So yes, it looks like old, my patch, and your patch would leak there
was an error followed by other data in response.
Though I doubt kernel would ever do that.
The only user of iov style messages to the kernel is in tc batching.
My gut feeling is that if one message in batch has error, then
the netlink code should return that error and stop processing more.
next prev parent reply other threads:[~2018-09-13 20:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-12 23:29 [PATCH iproute2] iproute2: fix use-after-free Mahesh Bandewar
2018-09-13 0:33 ` Stephen Hemminger
2018-09-13 6:07 ` Mahesh Bandewar (महेश बंडेवार)
2018-09-13 15:19 ` Stephen Hemminger [this message]
2018-09-13 17:54 ` Mahesh Bandewar (महेश बंडेवार)
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=20180913081948.1bf8368b@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=mahesh@bandewar.net \
--cc=maheshb@google.com \
--cc=netdev@vger.kernel.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