Received: by 10.223.185.111 with SMTP id b44csp910336wrg; Fri, 9 Mar 2018 16:37:46 -0800 (PST) X-Google-Smtp-Source: AG47ELsKjsyI1NmEfKuxsnPh+xo7/v5m+G31swQ/wGmL5p+lkFB3qvUEnTV7QyL/7oy9dBtHKAbn X-Received: by 2002:a17:902:461:: with SMTP id 88-v6mr380784ple.88.1520642266027; Fri, 09 Mar 2018 16:37:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642265; cv=none; d=google.com; s=arc-20160816; b=UwF/d2L1pBmShgiN9W+8V9ZXW4aDWnLoIGJF5p2xD84D0s7G5tpjSC0Hy4G5N78tzw 14r8wa+9X5qu06UvPilpp+3/OWEpakK0UFf5FmoZUvuQarUBDvSu4z4hFyLiAGRll07H 1XegWBDRM9e/sdfpRRj0L0vWplds0+JqJwnn9yOKlu0vFwoFrZBJkzm+bQ8KG3m0JB+8 Za4wUddHXXP4Z/pcoQt6qZ6dnalsydNJx4eTobxnNsqO4702tpGGSRkEGHn0+1FQf4Kz Xmsq1DCtZM/FGBv6SL4E0nJS8zNwj0XM7ghFJgiuK3QOMFXk1gLiE/QpmV1sIcKeWJP8 pp6w== 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=8+neLeWGdBi5aDTighUoRKT5RO+6S9pjg8Uv7nOc6Dc=; b=f3QJoHmiS/W02e/xQZ+JCBlgiA0Giny3CQ9SYrCt1iqr8FuLIQOXJt1UPoIAC8rg7h XafcHSOEAhAo9nysb1LOpNOv6iFrKF703ZmydePBN7VuRYUI5aaQ+YXKD/KyMgIJqfDd bUmJ55OQEFGHyijcfm7SMolkUFVaMdJvoPb76iSqW7ZUUwCMgZeegENZUBDKuiP+/fuz m76fJom2ltxOiWIPHDdgnobUfxZcbtkDrlQx/1nuBUtui3e7JpfKvn2X+fp9ukCu/hCn a9TtG/2baJA/4Qumz9PkxVbImawt/AndVD4VgYKu4Rp/1AeJYA+kXDh9S8hW1YA7KZS4 +u/w== 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 z23-v6si1792756plo.272.2018.03.09.16.37.31; Fri, 09 Mar 2018 16:37:45 -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 S933684AbeCJAgJ (ORCPT + 99 others); Fri, 9 Mar 2018 19:36:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39832 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933761AbeCJAWA (ORCPT ); Fri, 9 Mar 2018 19:22:00 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 11F89FE0; Sat, 10 Mar 2018 00:21:59 +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.9 39/65] netlink: ensure to loop over all netns in genlmsg_multicast_allns() Date: Fri, 9 Mar 2018 16:18:39 -0800 Message-Id: <20180310001828.152582509@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001824.927996722@linuxfoundation.org> References: <20180310001824.927996722@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.9-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 @@ -1103,6 +1103,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) { @@ -1114,14 +1115,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;