Received: by 10.223.185.111 with SMTP id b44csp914098wrg; Fri, 9 Mar 2018 16:43:51 -0800 (PST) X-Google-Smtp-Source: AG47ELtISR7AB+xzgIqh463DEZveqYoEqYff8i6zqM8u7fy651bU+ZHDgKDxWmWtJUoXS7t9E6SR X-Received: by 2002:a17:902:6b81:: with SMTP id p1-v6mr359301plk.181.1520642631874; Fri, 09 Mar 2018 16:43:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642631; cv=none; d=google.com; s=arc-20160816; b=gby/Uo/61Wwbi7U8sDFMLJROyF06y5zCu/ndBQ8MqQSt0prjxhaJLlqTK7vPTyRQY2 fx92QAIGoua4HpCwJeVxMOPBrWUAFgdTyv+IeDe077CLyIQPb52GY2lnMsZd3luExnEV l3iGSpFxBkqu4RTJAyQQ3ilfIMq+bhcVIP1rKD8+cispmbCQtXccPVo9JnKWfnsmHlyu aelzLQW9afB+qa+G9VHLHPbz7SSf3dSvkZZtUPgi73XjsiOcLCrEgUNMw7wpm+5LvUTn B/XME/+lio5QGG0HYkuRpFk4mAoWVKrQwICTtzSJ/LqV2+9iu44R32IeOEeFGnclzGcj ineg== 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=2T2Xac1KsBmwQiJJv1amX+KVQark1oahClZHuxMJDCI=; b=VFErh00OTNBCFhUctmLeXP9hFo4PrvgzgpgyY/S9ojsVCowHVpP2QcKUF/zLrgAgF1 eiLHJty511KZ9x+DD+DJMea6v7i2nWJEi6dN0WVNffUyGR0TAxDmhX/kKGUfL7PatEXP NWlrbIBsAPWaECuulj7PRB5X/z/Ja17RwHIFSS8+/ixFaB23WQ4E8etm3WiPFJdex2bN nakWZYWKCHK245vLX4yfWLHmvlvCi31R177LMhhertibsWAN4j2vQcNQf3jY4G/EFspg fp9EpihjjxHKs2b+F2XHZ0/kKbScYO9AIeB/w/cFQ0+JA+82DPQhA/Mbm90+LXFHji7f ah9A== 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 e5si1800068pfl.5.2018.03.09.16.43.37; Fri, 09 Mar 2018 16:43:51 -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 S933613AbeCJAme (ORCPT + 99 others); Fri, 9 Mar 2018 19:42:34 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39338 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932964AbeCJAUy (ORCPT ); Fri, 9 Mar 2018 19:20:54 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0D75BFC3; Sat, 10 Mar 2018 00:20:53 +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.4 24/36] netlink: ensure to loop over all netns in genlmsg_multicast_allns() Date: Fri, 9 Mar 2018 16:18:40 -0800 Message-Id: <20180310001808.681346858@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001807.213987241@linuxfoundation.org> References: <20180310001807.213987241@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.4-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 @@ -1118,6 +1118,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) { @@ -1129,14 +1130,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;