From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726AbdI1KkK (ORCPT ); Thu, 28 Sep 2017 06:40:10 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:41815 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751778AbdI1KkJ (ORCPT ); Thu, 28 Sep 2017 06:40:09 -0400 Date: Thu, 28 Sep 2017 12:40:04 +0200 From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes.berg@intel.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Johannes Berg Subject: Re: [PATCH v2] netlink: do not proceed if dump's start() errs Message-ID: <20170928104002.GA25114@zx2c4.com> References: <20170927224144.1749-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170927224144.1749-1-Jason@zx2c4.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 28, 2017 at 12:41:44AM +0200, Jason A. Donenfeld wrote: > diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c > index 327807731b44..94c11cf0459d 100644 > --- a/net/netlink/af_netlink.c > +++ b/net/netlink/af_netlink.c > @@ -2270,10 +2270,13 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb, > > mutex_unlock(nlk->cb_mutex); > > + ret = 0; > if (cb->start) > - cb->start(cb); > + ret = cb->start(cb); > + > + if (!ret) > + ret = netlink_dump(sk); > > - ret = netlink_dump(sk); > sock_put(sk); > > if (ret) FYI, using this horrific hack to currently work around bug: #define KERNEL_VERSION_THAT_HAS_NETLINK_START_FIX KERNEL_VERSION(4, 14, 0) /* Hopefully! */ static int get(struct sk_buff *skb, struct netlink_callback *cb) { #if LINUX_VERSION_CODE < KERNEL_VERSION_THAT_HAS_NETLINK_START_FIX /* https://marc.info/?l=linux-netdev&m=150655213004221&w=2 */ if (!cb->args[0]) { ret = get_start(cb); if (ret) return ret; } #endif ... } static const struct genl_ops genl_ops[] = { { .cmd = CMD_GET, #if LINUX_VERSION_CODE >= KERNEL_VERSION_THAT_HAS_NETLINK_START_FIX /* https://marc.info/?l=linux-netdev&m=150655213004221&w=2 */ .start = get_start, #endif .dumpit = get, ... } } Gross.