Received: by 10.223.185.116 with SMTP id b49csp5461554wrg; Wed, 7 Mar 2018 12:09:35 -0800 (PST) X-Google-Smtp-Source: AG47ELtcjG16bKz4ekwJjvggp1oeZ5GkuhWiUI4sTSVWtE7WjKtbpy6gVH8Ivrr5fqTwD7yRAo5X X-Received: by 10.98.157.18 with SMTP id i18mr23857800pfd.62.1520453375824; Wed, 07 Mar 2018 12:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520453375; cv=none; d=google.com; s=arc-20160816; b=q8HzqNHiFOZROo/4F9zJ5Zeh97xc4uYGc7/mVSm+4V7iX39CSBzkp0c99eSgRL3pNc cRvMiUkJekuXqyy2CSZJoWu/ezdiE8d4gO9ODjfncfnXCYCdKuL/GYRdNTyZWN6veqEX 5n3a+4DbWr/vaAO/mDEdeFN5pzEXwKu5yQztqzVoQW+sjbVFaSGN0Qs5Btu+GomAg0TE xzaENEyMTi0piyo6+KlYCWCpQbMRwywd19D1nCE5oHuJIcStTfZCFdD6T+8qHTi1meh8 SLI33QcRuEG0w1mdfDh99Jcucm8Z8Wc+lwgsZD88TqXyWiXG+0TjMXTBrABA2ZmdM0TF 0/iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=BbLQ2DiitoyeXeVDNOXaG735WU4A+RXDmzev96o+RKg=; b=hfd9d+Nl7qxOS4bcI9OgFmvY4GujtwTSfQYTs1IxwIIz1y9rnuLZ1p10VeHKOjNdI3 HfCaVsEcbP5z5R/wSDybM8f2kZXJLafA2Xy8e1jJyCT8Gq9nArSlTLDubvfYEaeM+//d /zPGXCRXhWlDKYHOmb6FUcoEJZbLlFgsWbemzU0luQ6ylddVemgyWd9Wdk8eyF/qQrZd vidd+QIsB6JRSdURRVHp7UzWxtKraEMB2jHEnSz3v2U9efgaYo9q9a8UuPLfxhhpWhcH vHUmGkBO354TlICHAeZe7eLd6Dxk5VCWh+wCtD4tM5m6S1OjrNAipBsQeiMnGupAAvT8 uAmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11-v6si13464891pli.826.2018.03.07.12.09.21; Wed, 07 Mar 2018 12:09:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935066AbeCGUIb (ORCPT + 99 others); Wed, 7 Mar 2018 15:08:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44306 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964807AbeCGTps (ORCPT ); Wed, 7 Mar 2018 14:45:48 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 18AF7F0B; Wed, 7 Mar 2018 19:45:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Nicolas Dichtel , "David S. Miller" Subject: [PATCH 4.14 042/110] netlink: ensure to loop over all netns in genlmsg_multicast_allns() Date: Wed, 7 Mar 2018 11:38:25 -0800 Message-Id: <20180307191045.128205302@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nicolas Dichtel [ Upstream commit cb9f7a9a5c96a773bbc9c70660dc600cfff82f82 ] Nowadays, nlmsg_multicast() returns only 0 or -ESRCH but this was not the case when commit 134e63756d5f was pushed. However, there was no reason to stop the loop if a netns does not have listeners. Returns -ESRCH only if there was no listeners in all netns. To avoid having the same problem in the future, I didn't take the assumption that nlmsg_multicast() returns only 0 or -ESRCH. Fixes: 134e63756d5f ("genetlink: make netns aware") CC: Johannes Berg Signed-off-by: Nicolas Dichtel Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/netlink/genetlink.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -1081,6 +1081,7 @@ static int genlmsg_mcast(struct sk_buff { struct sk_buff *tmp; struct net *net, *prev = NULL; + bool delivered = false; int err; for_each_net_rcu(net) { @@ -1092,14 +1093,21 @@ static int genlmsg_mcast(struct sk_buff } err = nlmsg_multicast(prev->genl_sock, tmp, portid, group, flags); - if (err) + if (!err) + delivered = true; + else if (err != -ESRCH) goto error; } prev = net; } - return nlmsg_multicast(prev->genl_sock, skb, portid, group, flags); + err = nlmsg_multicast(prev->genl_sock, skb, portid, group, flags); + if (!err) + delivered = true; + else if (err != -ESRCH) + goto error; + return delivered ? 0 : -ESRCH; error: kfree_skb(skb); return err;