From: Johannes Berg <johannes@sipsolutions.net>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>,
davem@davemloft.net, Netdev <netdev@vger.kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] af_netlink: ensure that NLMSG_DONE never fails in dumps
Date: Thu, 09 Nov 2017 03:02:14 +0100 [thread overview]
Message-ID: <1510192934.11466.0.camel@sipsolutions.net> (raw)
In-Reply-To: <20171109014218.20562-1-Jason@zx2c4.com>
On Thu, 2017-11-09 at 10:42 +0900, Jason A. Donenfeld wrote:
> +++ b/net/netlink/af_netlink.c
> @@ -2136,7 +2136,7 @@ static int netlink_dump(struct sock *sk)
> struct sk_buff *skb = NULL;
> struct nlmsghdr *nlh;
> struct module *module;
> - int len, err = -ENOBUFS;
> + int err = -ENOBUFS;
> int alloc_min_size;
> int alloc_size;
>
> @@ -2183,9 +2183,10 @@ static int netlink_dump(struct sock *sk)
> skb_reserve(skb, skb_tailroom(skb) - alloc_size);
> netlink_skb_set_owner_r(skb, sk);
>
> - len = cb->dump(skb, cb);
> + if (nlk->dump_done_errno > 0)
> + nlk->dump_done_errno = cb->dump(skb, cb);
>
> - if (len > 0) {
> + if (nlk->dump_done_errno > 0 || skb_tailroom(skb) < nlmsg_total_size(sizeof(nlk->dump_done_errno))) {
> mutex_unlock(nlk->cb_mutex);
nit: I think your line got a little long here :)
> - memcpy(nlmsg_data(nlh), &len, sizeof(len));
> + memcpy(nlmsg_data(nlh), &nlk->dump_done_errno, sizeof(nlk->dump_done_errno));
and here
> + nlk->dump_done_errno = INT_MAX;
I guess positive values aren't really returned from dump?
johannes
next prev parent reply other threads:[~2017-11-09 2:02 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 [this message]
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
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=1510192934.11466.0.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=Jason@zx2c4.com \
--cc=davem@davemloft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.