From patchwork Fri Mar 13 02:05:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 1254138 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=pq6gwkB3; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48dpvC70xGz9sQx for ; Fri, 13 Mar 2020 13:05:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726443AbgCMCFn (ORCPT ); Thu, 12 Mar 2020 22:05:43 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42138 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbgCMCFm (ORCPT ); Thu, 12 Mar 2020 22:05:42 -0400 Received: by mail-pg1-f193.google.com with SMTP id h8so4034245pgs.9 for ; Thu, 12 Mar 2020 19:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=IpVTh41d2rSBfzu7o/acWAoPFxrqBT4HVHUWc5LixT8=; b=pq6gwkB3LL+9PMBDh+YN0Um3aV8xlhbtFeQ+Yw9HZTof+7hmk4fMg4jV8zW927/hD+ PeqZMSSuUNBcIv4xEQMyCUDLW7jQNXufB96FvzVW9Ez2NhiNhWreSWRVMmhlpwTWjvvY ETxwSV7CT69MxGbJEAUqeyc+Jx6lNYk4PHHa371DWcSKWVp5fP1EOI4lFKy5Ry5pJmxK 0cHKOUnzxvzT0nKrjM1pSpHLn1Ot0ibZoTdH6PH7NFLp3JmYTgAi09NbUUG4M36wC3/A PsNW61V59uodbzsrqqtaSs3sUrEAfAC3GOR4VrLAqcQCVogxGoeuJcUU1S5sNX0C9rjG a8SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IpVTh41d2rSBfzu7o/acWAoPFxrqBT4HVHUWc5LixT8=; b=dK5RG1XT6JsHJ+6uBBq11wBeEOS2pc1+Vrl99Hu3FEsjrLFAsuVtaKsCTMIHPaaSxM tF+PlWIujf68gjU5zZDbWm6FrP/0XHSiMp0qrPwWX28ggyaW5VBCisZtT++MII5qP5/x EhM5HsVgEtkAVSzW2omwWu1bGwAV37Uh9RwAzEaSa2CwLWavbRooxtZjpEQCVq0/SdHt H2nM8jbCEBqdG2z9PgtQVTHhFW+3uhubw/xwZc0PjsE1VNeJdYyEkX3CyobTIJlfStdV yfdOwjJhVv/OokXBkJ6gNOWjK2PmHde8WCvAEXtJezbEA0g26URYtTn82g56h7zb0YcF TEZw== X-Gm-Message-State: ANhLgQ1/jz37K3rgEknzJGdz60sGB2o+W7CzKj6v6oPMuhaqOhJplRzT XOxB/j8Y1b9KmcMyajCNbW0= X-Google-Smtp-Source: ADFU+vvZpJ/MWU5DNtP/qhoHbqTFJBEo8eO8640DEhRLOgy5gSVS2KX4rXCGQIra4+i2EFC3n6m1iQ== X-Received: by 2002:a62:e30f:: with SMTP id g15mr11473348pfh.124.1584065141326; Thu, 12 Mar 2020 19:05:41 -0700 (PDT) Received: from localhost.localdomain ([180.70.143.152]) by smtp.gmail.com with ESMTPSA id s19sm5562388pfh.218.2020.03.12.19.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 19:05:40 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: ap420073@gmail.com Subject: [PATCH net 1/3] hsr: use rcu_read_lock() in hsr_get_node_{list/status}() Date: Fri, 13 Mar 2020 02:05:30 +0000 Message-Id: <20200313020530.31435-1-ap420073@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org hsr_get_node_{list/status}() are not under rtnl_lock() because they are callback functions of generic netlink. But they use __dev_get_by_index() without rtnl_lock(). So, it would use unsafe data. In order to fix it, rcu_read_lock() and dev_get_by_index_rcu() are used instead of __dev_get_by_index(). Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)") Signed-off-by: Taehee Yoo --- net/hsr/hsr_framereg.c | 9 ++------- net/hsr/hsr_netlink.c | 39 +++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index 3ba7f61be107..a64bb64935a6 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c @@ -482,12 +482,9 @@ int hsr_get_node_data(struct hsr_priv *hsr, struct hsr_port *port; unsigned long tdiff; - rcu_read_lock(); node = find_node_by_addr_A(&hsr->node_db, addr); - if (!node) { - rcu_read_unlock(); - return -ENOENT; /* No such entry */ - } + if (!node) + return -ENOENT; ether_addr_copy(addr_b, node->macaddress_B); @@ -522,7 +519,5 @@ int hsr_get_node_data(struct hsr_priv *hsr, *addr_b_ifindex = -1; } - rcu_read_unlock(); - return 0; } diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c index 8dc0547f01d0..d6760df2ad1f 100644 --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c @@ -251,15 +251,16 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info) if (!na) goto invalid; - hsr_dev = __dev_get_by_index(genl_info_net(info), - nla_get_u32(info->attrs[HSR_A_IFINDEX])); + rcu_read_lock(); + hsr_dev = dev_get_by_index_rcu(genl_info_net(info), + nla_get_u32(info->attrs[HSR_A_IFINDEX])); if (!hsr_dev) - goto invalid; + goto rcu_unlock; if (!is_hsr_master(hsr_dev)) - goto invalid; + goto rcu_unlock; /* Send reply */ - skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); + skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); if (!skb_out) { res = -ENOMEM; goto fail; @@ -313,12 +314,10 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info) res = nla_put_u16(skb_out, HSR_A_IF1_SEQ, hsr_node_if1_seq); if (res < 0) goto nla_put_failure; - rcu_read_lock(); port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A); if (port) res = nla_put_u32(skb_out, HSR_A_IF1_IFINDEX, port->dev->ifindex); - rcu_read_unlock(); if (res < 0) goto nla_put_failure; @@ -328,20 +327,22 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info) res = nla_put_u16(skb_out, HSR_A_IF2_SEQ, hsr_node_if2_seq); if (res < 0) goto nla_put_failure; - rcu_read_lock(); port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B); if (port) res = nla_put_u32(skb_out, HSR_A_IF2_IFINDEX, port->dev->ifindex); - rcu_read_unlock(); if (res < 0) goto nla_put_failure; + rcu_read_unlock(); + genlmsg_end(skb_out, msg_head); genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid); return 0; +rcu_unlock: + rcu_read_unlock(); invalid: netlink_ack(skb_in, nlmsg_hdr(skb_in), -EINVAL, NULL); return 0; @@ -351,6 +352,7 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info) /* Fall through */ fail: + rcu_read_unlock(); return res; } @@ -377,15 +379,16 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) if (!na) goto invalid; - hsr_dev = __dev_get_by_index(genl_info_net(info), - nla_get_u32(info->attrs[HSR_A_IFINDEX])); + rcu_read_lock(); + hsr_dev = dev_get_by_index_rcu(genl_info_net(info), + nla_get_u32(info->attrs[HSR_A_IFINDEX])); if (!hsr_dev) - goto invalid; + goto rcu_unlock; if (!is_hsr_master(hsr_dev)) - goto invalid; + goto rcu_unlock; /* Send reply */ - skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); + skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); if (!skb_out) { res = -ENOMEM; goto fail; @@ -405,14 +408,11 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) hsr = netdev_priv(hsr_dev); - rcu_read_lock(); pos = hsr_get_next_node(hsr, NULL, addr); while (pos) { res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, addr); - if (res < 0) { - rcu_read_unlock(); + if (res < 0) goto nla_put_failure; - } pos = hsr_get_next_node(hsr, pos, addr); } rcu_read_unlock(); @@ -422,6 +422,8 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) return 0; +rcu_unlock: + rcu_read_unlock(); invalid: netlink_ack(skb_in, nlmsg_hdr(skb_in), -EINVAL, NULL); return 0; @@ -431,6 +433,7 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) /* Fall through */ fail: + rcu_read_unlock(); return res; } From patchwork Fri Mar 13 02:05:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 1254139 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=nJc4XyYm; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48dpvW3Dx7z9sQx for ; Fri, 13 Mar 2020 13:05:59 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726462AbgCMCF6 (ORCPT ); Thu, 12 Mar 2020 22:05:58 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45336 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbgCMCF6 (ORCPT ); Thu, 12 Mar 2020 22:05:58 -0400 Received: by mail-pg1-f194.google.com with SMTP id m15so4028744pgv.12 for ; Thu, 12 Mar 2020 19:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=olOQEz57ZCzh/4Ac5WIJGRCjx7A0NQAXIpw0Gv1qrdQ=; b=nJc4XyYm/XgUgPL+K4vCKd8cSTKdMfqHcINXcWcpWwkW3y0IVKx18c4Dg2w8qcv+di RgXYk71nkWCwVsxYw1WY8GKxawJU+VfvvTtyzj2qaIEcYdChHZa70sIsJzRb1YdrJikx Uq2PwKHFNxsoZ35cOREVhQRMFSYcI6oiZxCIzZqxWEBQRCVEl2faDYDjR72KyJJb4dQS RLEL8WcDn8LM9VZS4T5Mcbq3tV+W7UGJ+SoN2j+jbmYEkCXQ3ken61PEUObwQ6GtAm/p maYdKT2O8xHB49gtyPN6427SPiaVko/CRIuA1Rq+5DXlJzB3JoBujL+/X8iNxlpxGXVh vJ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=olOQEz57ZCzh/4Ac5WIJGRCjx7A0NQAXIpw0Gv1qrdQ=; b=DljAMqq+L1TCnR56Op5hdE7i5ZRxcmjLpeqQuuGy829mSnqkTBtjmzr8kamsQERQDy Z0WtMU1YQQhx3cHKXX0A/7GHdzKpyGX8X0VBu5mC1LSp49v8sAoDK+USk1BlFpDBIOgi o+TmQZl5zMWaCESjNqYa5zALFkypGALFobhKUlZYC7O/KOXlLhK6875f+0gjqesFEDxf 1KNGInq5S0frrLb2URTuUNImF4lJWo6DuqshRpeAxgACqZiaR6ZMccb92NvgW9sXCD6/ jrnjGC9hmtkA9S9j30nHcJbq6vo3Bdqie5DxZ17ZWIQnC4J/llqI9/LEDBUWZwOMuzbY g+gA== X-Gm-Message-State: ANhLgQ1uVUqCZ555baR252nDNqOh9KRhjFJTnb1ACotVP2gGpyR1x4uZ 1SbGrAgvc26ojOAM2k+R0ks= X-Google-Smtp-Source: ADFU+vukxF8wANHtMqPTO8lHkyl5IdYhBbByKHPLXS4eUb0UrHsYk0WsrBCBPYr4breDXm58DVWpnw== X-Received: by 2002:a63:48e:: with SMTP id 136mr10464885pge.169.1584065157536; Thu, 12 Mar 2020 19:05:57 -0700 (PDT) Received: from localhost.localdomain ([180.70.143.152]) by smtp.gmail.com with ESMTPSA id z20sm25967229pge.62.2020.03.12.19.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 19:05:56 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: ap420073@gmail.com Subject: [PATCH net 2/3] hsr: add restart routine into hsr_get_node_list() Date: Fri, 13 Mar 2020 02:05:50 +0000 Message-Id: <20200313020550.31514-1-ap420073@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The hsr_get_node_list() is to send node addresses to the userspace. If there are so many nodes, it could fail because of buffer size. In order to avoid this failure, the restart routine is added. Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)") Signed-off-by: Taehee Yoo --- net/hsr/hsr_netlink.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c index d6760df2ad1f..6a6e092153ef 100644 --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c @@ -368,9 +368,10 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) struct sk_buff *skb_out; void *msg_head; struct hsr_priv *hsr; - void *pos; + void *pos = NULL; unsigned char addr[ETH_ALEN]; int res; + bool restart = false; if (!info) goto invalid; @@ -387,8 +388,9 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) if (!is_hsr_master(hsr_dev)) goto rcu_unlock; +restart: /* Send reply */ - skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); + skb_out = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_ATOMIC); if (!skb_out) { res = -ENOMEM; goto fail; @@ -402,17 +404,28 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) goto nla_put_failure; } - res = nla_put_u32(skb_out, HSR_A_IFINDEX, hsr_dev->ifindex); - if (res < 0) - goto nla_put_failure; + if (!restart) { + res = nla_put_u32(skb_out, HSR_A_IFINDEX, hsr_dev->ifindex); + if (res < 0) + goto nla_put_failure; + } hsr = netdev_priv(hsr_dev); - pos = hsr_get_next_node(hsr, NULL, addr); + if (!pos) + pos = hsr_get_next_node(hsr, NULL, addr); while (pos) { res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, addr); - if (res < 0) + if (res < 0) { + if (res == -EMSGSIZE) { + genlmsg_end(skb_out, msg_head); + genlmsg_unicast(genl_info_net(info), skb_out, + info->snd_portid); + restart = true; + goto restart; + } goto nla_put_failure; + } pos = hsr_get_next_node(hsr, pos, addr); } rcu_read_unlock(); @@ -429,7 +442,7 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info) return 0; nla_put_failure: - kfree_skb(skb_out); + nlmsg_free(skb_out); /* Fall through */ fail: From patchwork Fri Mar 13 02:06:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 1254140 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=mDUEFUxP; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48dpwF5ZnKz9sQx for ; Fri, 13 Mar 2020 13:06:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726467AbgCMCGg (ORCPT ); Thu, 12 Mar 2020 22:06:36 -0400 Received: from mail-pj1-f68.google.com ([209.85.216.68]:40898 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbgCMCGg (ORCPT ); Thu, 12 Mar 2020 22:06:36 -0400 Received: by mail-pj1-f68.google.com with SMTP id bo3so2040128pjb.5 for ; Thu, 12 Mar 2020 19:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Y/RiGmKu2bGOe1k4hPC/XK5RVGb6F9gd5djR4zEb8Ks=; b=mDUEFUxPwHrIRNcNDDR5OVgOZfPQOgGwu+fzpzzKyKo6FRMD4BTshHH2rYtRryHwGR gNxYIF9MXtLU+ptZPSwVU+u+ys1WEQ4WDZax+bdiUZT16MkhtLAWRjQmCcUeaSZfHrD/ R3knIQJiGcAJEyiAJFp0mHVtuU0WohzAuBw9QvyyuMy3SU+zz/TrncbqSjvG2CIbTHm+ cDKRNfKmBbBMB6vcCQdR3BEHRTzp4pFzzpfiR/Gn5srkMoL1aSE8rqGobncle1mmyAUG F2/enl1bBzO8COkPBhVUo0GGOcAyS0M6BF7khQMwe8UHv+sQ1s6wVigV9MfjgZtaLafF rUBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Y/RiGmKu2bGOe1k4hPC/XK5RVGb6F9gd5djR4zEb8Ks=; b=ip5UVg9+Y3g9YPUGKnWI7qrql8Y+uv3otbtt+tMnS+uaaGh282FB7VJEfrZwC5pK5k zYu8QP9NoYYGUOu0gS1S8x+ODoZZdDaQgw9gGG8S/aHL6KEvoJPujVswPV8NsIfw3OgY LPNm454umgSJ1SomCNZZMVjs4N2rlH0LGNo5PEk1/FF7z8XiBhZ/OEWyfcZVyZkuGSOl kFLAmonXXy4oqaLN02pPd+JqDC3iUP4oDMLjSBvjCMGHjF/3MNianR5Qm7lczziFmvo4 6Rqes/OnSQ+QY+ZWhLCYG4GYS2vDsBSdIAEVpDrv3UFPqrhkZozN+bjXvNVcpvRd1Lvo rfag== X-Gm-Message-State: ANhLgQ1kV/89tyxuFPhj+u5E6MAxWA01/jKIFsNPjaFc5G2AXCrnFOtM yJZBEIJCmKLC5XEl8qEwMqc= X-Google-Smtp-Source: ADFU+vuHy637+eHc+Ub8e4Hg/gxSp28bqDnQ3zK6Eyv/2jzGB9RPd1QvyMlOFmfK5gA8MXyHTC3Sjg== X-Received: by 2002:a17:902:9308:: with SMTP id bc8mr11300211plb.268.1584065195378; Thu, 12 Mar 2020 19:06:35 -0700 (PDT) Received: from localhost.localdomain ([180.70.143.152]) by smtp.gmail.com with ESMTPSA id s61sm10153249pjd.33.2020.03.12.19.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 19:06:34 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: ap420073@gmail.com Subject: [PATCH net 3/3] hsr: set .netnsok flag Date: Fri, 13 Mar 2020 02:06:26 +0000 Message-Id: <20200313020626.31683-1-ap420073@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The hsr module has been supporting the list and status command. (HSR_C_GET_NODE_LIST and HSR_C_GET_NODE_STATUS) These commands send node information to the user-space via generic netlink. But, in the non-init_net namespace, these commands are not allowed because .netnsok flag is false. So, there is no way to get node information in the non-init_net namespace. Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)") Signed-off-by: Taehee Yoo --- net/hsr/hsr_netlink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c index 6a6e092153ef..1d3141aa5766 100644 --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c @@ -473,6 +473,7 @@ static struct genl_family hsr_genl_family __ro_after_init = { .version = 1, .maxattr = HSR_A_MAX, .policy = hsr_genl_policy, + .netnsok = true, .module = THIS_MODULE, .ops = hsr_ops, .n_ops = ARRAY_SIZE(hsr_ops),