From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751358AbdKKOSP (ORCPT ); Sat, 11 Nov 2017 09:18:15 -0500 Received: from s3.sipsolutions.net ([144.76.63.242]:46588 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750928AbdKKOSF (ORCPT ); Sat, 11 Nov 2017 09:18:05 -0500 Message-ID: <1510409880.12037.5.camel@sipsolutions.net> Subject: Re: [PATCH v4] af_netlink: ensure that NLMSG_DONE never fails in dumps From: Johannes Berg To: David Miller , Jason@zx2c4.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 11 Nov 2017 15:18:00 +0100 In-Reply-To: <1510409721.12037.3.camel@sipsolutions.net> References: <20171109014218.20562-1-Jason@zx2c4.com> <20171109040444.1728-1-Jason@zx2c4.com> <20171111.230924.412544731735070222.davem@davemloft.net> <1510409721.12037.3.camel@sipsolutions.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.0-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > 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. Or perhaps I should say this differently: Forcing another read happens through the skb_tailroom(skb) < nlmsg_total_size(...) check, so the nlmsg_put_answer() can't really fail. Handling nlmsg_put_answer() failures by forcing another read would have required jumping to the existing if code with a goto, or restructuring the whole thing completely somehow, and I didn't see how to do that. johannes