From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH v4] af_netlink: ensure that NLMSG_DONE never fails in dumps Date: Sat, 11 Nov 2017 23:09:24 +0900 (KST) Message-ID: <20171111.230924.412544731735070222.davem@davemloft.net> References: <20171109014218.20562-1-Jason@zx2c4.com> <20171109040444.1728-1-Jason@zx2c4.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: Jason@zx2c4.com Return-path: In-Reply-To: <20171109040444.1728-1-Jason@zx2c4.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org From: "Jason A. Donenfeld" 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.