Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2414143imm; Thu, 7 Jun 2018 10:10:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLbxFqo6JjV0I6PATxnqhOkJdNDdGLO4EvkPTLF4aHKc3oCH8x+URfJyqsYu3i42HCrfhjP X-Received: by 2002:a17:902:14d:: with SMTP id 71-v6mr2852009plb.275.1528391436866; Thu, 07 Jun 2018 10:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528391436; cv=none; d=google.com; s=arc-20160816; b=o/t30CXfnrIgetxB/yc934BE1vq+NEfj/cM3SJOgDiIfQFWONET721lIpFG1p0dIzs MJAekTyhMYEoJL0X126J9+Nz6PImpWamTF74kcEOAdUixUS0twQZvM8wb+IOLZ3+X6d7 yAdfdUDUFWLyIHr3NcnRT+uDyiXm2y/W0BJbhH5j/SdZryX+iPmVhkHVGVBx9lESK0AL YmQKRAVP4o36yzevY8yIFmF6lFd1apYvnz1EI831vKL59o6sENRV/Ej407T+mFOl0NJD L7vRGS4FsNPVmeDOlHYYbUmb0j6PweAA8qd7YYhmRbloaPuwQUaayb6pXKC93GAZRoDd iH9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=9xVINvb9JNRXx1tYCwbeYDDuF6NZB7c7iyJmIkhf7w8=; b=q83v7Q3J7tl1c7g7qjikDgyUvnGptrje2XqDHFNRlTvwppmXbBRq7VlJhOakx0qnyJ 6LpX8kAfRgomvZf6tvRdlqvZtKFF26oQNYk7T8OsdMgR+F00AukzgXPSRkb51ODCRGoJ 7V6WEWGUKaYq9THUKi28Tu0zk5nIJC0555W7rMB6Cl3hpFSeZkSv9uvzoPHKlCoYgzD1 pgQ5wAiFD0qF4CSonCu5gtoFfeVdYv4ji80yqkHupQ0QCirYelVuFLWpkL+NDsjAGlsM ZmmHgRKyLpq9iyl+CalJJWeKTQwhDev+gVx08FiDE2hRgI8/5dGiTm5ovJZh4sEFh679 labQ== 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 b2-v6si14744713plz.118.2018.06.07.10.10.22; Thu, 07 Jun 2018 10:10:36 -0700 (PDT) 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 S933274AbeFGOb1 (ORCPT + 99 others); Thu, 7 Jun 2018 10:31:27 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39404 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933060AbeFGOJJ (ORCPT ); Thu, 7 Jun 2018 10:09:09 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbA-0005Zs-2Y; Thu, 07 Jun 2018 15:09:08 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb6-00032E-RJ; Thu, 07 Jun 2018 15:09:04 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Johannes Berg" , "David S. Miller" , "Nicolas Dichtel" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 220/410] netlink: ensure to loop over all netns in genlmsg_multicast_allns() In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Nicolas Dichtel commit cb9f7a9a5c96a773bbc9c70660dc600cfff82f82 upstream. 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: Ben Hutchings --- net/netlink/genetlink.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -1042,6 +1042,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) { @@ -1053,14 +1054,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;