From: David Miller <davem@davemloft.net>
To: johannes@sipsolutions.net
Cc: Jason@zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] af_netlink: ensure that NLMSG_DONE never fails in dumps
Date: Sat, 11 Nov 2017 23:21:01 +0900 (KST) [thread overview]
Message-ID: <20171111.232101.352298023245450121.davem@davemloft.net> (raw)
In-Reply-To: <1510409721.12037.3.camel@sipsolutions.net>
From: Johannes Berg <johannes@sipsolutions.net>
Date: Sat, 11 Nov 2017 15:15:21 +0100
> On Sat, 2017-11-11 at 23:09 +0900, David Miller wrote:
>> From: "Jason A. Donenfeld" <Jason@zx2c4.com>
>> Date: Thu, 9 Nov 2017 13:04:44 +0900
>>
>> > @@ -2195,13 +2197,15 @@ static int netlink_dump(struct sock *sk)
>> > return 0;
>> > }
>> >
>> > - nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE, sizeof(len), NLM_F_MULTI);
>> > - if (!nlh)
>> > + nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE,
>> > + sizeof(nlk->dump_done_errno), NLM_F_MULTI);
>> > + if (WARN_ON(!nlh))
>> > goto errout_skb;
>>
>> If you're handling this by forcing another read() to procude the
>> NLMSG_DONE, then you have no reason to WARN_ON() here.
>>
>> In fact you are adding a WARN_ON() which is trivially triggerable by
>> any user.
>
> I added this in my suggestion for how this could work, but I don't
> think you're right, since we previously check if there's enough space.
> The patch is missing the full context, but this is:
...
> So unless the nlmsg_total_size() vs. nlmsg_put_answer() suddenly gets a
> different idea of how much space is needed, nlh shouldn't ever be NULL
> once we get here.
Aha, that's what I missed. Indeed, it cannot happen.
My bad.
next prev parent reply other threads:[~2017-11-11 14:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 11:29 [PATCH] af_netlink: give correct bounds to dump skb for NLMSG_DONE Jason A. Donenfeld
2017-11-08 6:03 ` Jason A. Donenfeld
2017-11-08 6:16 ` Johannes Berg
2017-11-08 6:35 ` Jason A. Donenfeld
2017-11-08 7:06 ` Jason A. Donenfeld
2017-11-08 7:21 ` [PATCH v2] " Jason A. Donenfeld
2017-11-09 1:42 ` [PATCH v3] af_netlink: ensure that NLMSG_DONE never fails in dumps Jason A. Donenfeld
2017-11-09 2:02 ` Johannes Berg
2017-11-09 2:57 ` Jason A. Donenfeld
2017-11-09 4:04 ` [PATCH v4] " Jason A. Donenfeld
2017-11-11 2:26 ` Jason A. Donenfeld
2017-11-11 2:37 ` David Miller
2017-11-11 2:47 ` Jason A. Donenfeld
2017-11-11 14:09 ` David Miller
2017-11-11 14:15 ` Johannes Berg
2017-11-11 14:18 ` Johannes Berg
2017-11-11 15:18 ` Jason A. Donenfeld
2017-11-11 14:21 ` David Miller [this message]
2017-11-13 1:18 ` David Miller
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=20171111.232101.352298023245450121.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=Jason@zx2c4.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).