From patchwork Wed Nov 13 02:17:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13873111 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2B2613A3EC for ; Wed, 13 Nov 2024 02:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731464292; cv=none; b=MegOS/9zUJHSQYP0YU+NOdUC3ylyD6gNnPyJB2Ya32awNZsAUmwd5d3g4zPRvQjIHwZ8bQtKgqfNWlj8vemQIlCKAPDhHmYQD4WUUvDPkU63v6UkY/bleYzUhEYKhc+MwNf5IudGvBc9VNn6R4FimqAiaLcIeUo+JMN54ZBSwf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731464292; c=relaxed/simple; bh=VBaKG7sS3+bFmnPdr4IqHzNMfBCmbNJFBokvNs/FN3Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dNypBqY0v5muNZFFEANPdhOeZ63aU/XJMMbpWskAjFKXdwLiTgKHecRHkwfQ3j/h7XvSGwoTHcjd8ExZQaN0CNd/WJ+a3NFEkzM9elSwtMbX311ASYd4HCPwlxbSv/AQTEkpovp+6wHfLz5clgW9D9hbflJCIbnXaDjx+t7BCF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=bMEjZzhl; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="bMEjZzhl" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20c8c50fdd9so1894205ad.0 for ; Tue, 12 Nov 2024 18:18:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1731464290; x=1732069090; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lKBid5QRb/kAhtogYHDhzeEdvI0mEg25tnKEi7AhX6E=; b=bMEjZzhlgYy/rZ2YCX43m3dvJcUX3qf5Uaw/8u2QHOO1vMxh9rTOFCCj6QyXpbUDGj 3OJt3fEKv3UOIANBiLDF6Hc8U5eaILVZVrTjmWfCyi/89gw07/zEf/UcxvQ1kGoBD59+ 35KUcBSC3gycZNUgvodM4+Mxsd5JGd3HeFmwI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731464290; x=1732069090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lKBid5QRb/kAhtogYHDhzeEdvI0mEg25tnKEi7AhX6E=; b=n+9tjvsOdmb9K+NYarfjTR9zCS690DN8s0m99e8O/9S1AKVEkk4fIWRraWM7K//8wP CsyI76hEKIStKpqhmhVSxWqgE7X81Z63pOVJPq0RSGvbnPcjUJwHo66aKdF5aItwyoK9 vs6gMaR7VRgpMlQ3P5DhbzwGgWUbpYR9WPQL+Hy/pFvGaLqo558zmhgoYfuH0Bit3rmX 78TD8sHXBM8WlIDZtERgHGZxLfRu7GkmFFDL9el6MvOuKaZ8FNT6NoSJfSkl0JEU1EIe Ed1YM/UGbI/445ShxCoE1iWShhxhSP4O65EQpuO4OrP2mL+KhaZlBxuQvsvMEfFJMu/l 7jpA== X-Gm-Message-State: AOJu0Yw+RDXcY7nFRSl2uv1ti4yVSr3sFUeZ+LVVpqKR5o6JcCTt/zSD 2L1dmxHjYZUzxZc/7ytN2/VNidwvzEpCjyOWnfE4BEJMUMDMgUL65BGA1Zu17hktppvx6ltKTTD kJLl26vTvANx4CUpFHnRQE93Rl5fYjXo7fbwkvncM7Y8PlMTee3I4BmrN/LZmFuqipfLAMmP8rv 1Lt8O5Q08+MjZJsE7BJI5lDHwtWfFP5Yyhiq0= X-Google-Smtp-Source: AGHT+IHI5KSL7qnXQ088ADYDMAiYRAqIH80E+3/aTvBMuDhB8SyMPvP3rnQzeByPamSOepx19J3iNA== X-Received: by 2002:a17:903:228d:b0:20c:5d5a:af6f with SMTP id d9443c01a7336-211836e6dcemr267759715ad.10.1731464289523; Tue, 12 Nov 2024 18:18:09 -0800 (PST) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dcb1dfsm100209505ad.14.2024.11.12.18.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 18:18:09 -0800 (PST) From: Joe Damato To: netdev@vger.kernel.org Cc: pabeni@redhat.com, edumazet@google.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, kuba@kernel.org, mkarsten@uwaterloo.ca, Joe Damato , stable@vger.kernel.org, "David S. Miller" , Simon Horman , Mina Almasry , linux-kernel@vger.kernel.org (open list) Subject: [net v2 1/2] netdev-genl: Hold rcu_read_lock in napi_get Date: Wed, 13 Nov 2024 02:17:51 +0000 Message-Id: <20241113021755.11125-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113021755.11125-1-jdamato@fastly.com> References: <20241113021755.11125-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Hold rcu_read_lock in netdev_nl_napi_get_doit, which calls napi_by_id and is required to be called under rcu_read_lock. Cc: stable@vger.kernel.org Fixes: 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi") Signed-off-by: Joe Damato --- v2: - Simplified by removing the helper and calling rcu_read_lock / unlock directly instead. net/core/netdev-genl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 765ce7c9d73b..0b684410b52d 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -233,6 +233,7 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info) return -ENOMEM; rtnl_lock(); + rcu_read_lock(); napi = napi_by_id(napi_id); if (napi) { @@ -242,6 +243,7 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info) err = -ENOENT; } + rcu_read_unlock(); rtnl_unlock(); if (err) From patchwork Wed Nov 13 02:17:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13873112 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23FCA13D53B for ; Wed, 13 Nov 2024 02:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731464294; cv=none; b=ELsmBZq+Ek3ousmTnUCCMNmkG6x9bGbauc3No6EXStVyUqkJutE0LfwkL7h+R6M6Xd3wCcPuxawUiEHJ7RsVckdYuiaJRhjFJOvHlBiqw5MgTeiU9z0WsnEnK27JXDn34FFrRBzX1Vvbo+o2dnh3UG62rxurO6MImbu+YRLQtss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731464294; c=relaxed/simple; bh=nrCk1dGkV8Sk4CWrmNxr+NTAfkg/eL3xFyL1TKB1XTc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JYi6mZzvNt2xSpXR7lpM4tUBlbjaTbbsPloPCNvp77ge3vEccGrFa5X87jFopllncoWIo2ArIyYR1MFeL8DxT81KYZjPjlJY1N1129v0g8OXavydz+AWWLzteFEgKqSZuB38OGNrg0Y0pbQcQpTnW9+8yyTvcxVK0slfnvlFgL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=Z0VQbA8O; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="Z0VQbA8O" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-210e5369b7dso66116635ad.3 for ; Tue, 12 Nov 2024 18:18:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1731464292; x=1732069092; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y1aEFQWTe78u6F+IZ6BU8S97709C2TVDqgfHG0ZtS8A=; b=Z0VQbA8O4AJol381I51hQJho+TTjOoAW3ruNPPXibqHSuxbYmRMsE9W8Crz0uNTaPV kkTTK4pqFOxf9HW0QozkiCZ38gu1N+fx4cn9k44WTOhWZZYMUZ0P9NWNukUwFmF6MVTT RzeeLEd46hFsyx9AYVUZRmAkRwuaiSeRz/3Co= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731464292; x=1732069092; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y1aEFQWTe78u6F+IZ6BU8S97709C2TVDqgfHG0ZtS8A=; b=oapuBOroPbrgRWiO8UxFPSxBTsG05fWZugrpU8zL2vCiSXG8oHEIxYlDetMaE01CU9 gSGjukq7A/WmzLYsuJqiCdqiBXXzOTD+utId1ZfBPXz9092/gkuUbS+z5b6cTYeO8zEY rS896vGkJY++fPtS1T8XtNt0EGlVVJI55EtyZmOX+eYptZIpBErM30m57+bSQDfvl6l1 cVg7s4hA0RUYBIZna0klNN4vkoK7joIvwqApN+39uRKWGxRMImk+EQBEKaesA/+33GQT RJVzJo6HtnuOf7Cp/oGi6zhSg2Xdd2nf2t45POjaii8duPdCID7tm6iAbrwB4N1iivN+ 4j0Q== X-Gm-Message-State: AOJu0Yz6F2KQtPb0xDU3yQCKOH6sy2ZWoOcmnJKVP4q/6yOUiQrtdjgk WcSuLNcsU5D6uyonyRCO9495N90GCDZizRpHQDCQorCI9pp9PWjUmOgatU7EQiWEfm4D9kNOeW5 0yaIVUj+nSXQwIRpJqiLyM4ix68RTy0x091X6csp4eI71dWTSL6H4no314ju7ZgT9rRB4JK1UNi FCspP1zDjr6xpujde1KtXznXxaUskjSgwJ06A= X-Google-Smtp-Source: AGHT+IH+cykyQhf5ILYAg+A7Oqq7FgSl5NS8ZGdD/OwOXspf8aJbdID8nejTn8/tmddQsmmSIfN1Ow== X-Received: by 2002:a17:903:18b:b0:20c:763e:d9cc with SMTP id d9443c01a7336-21183c7e021mr262269115ad.7.1731464291905; Tue, 12 Nov 2024 18:18:11 -0800 (PST) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dcb1dfsm100209505ad.14.2024.11.12.18.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 18:18:11 -0800 (PST) From: Joe Damato To: netdev@vger.kernel.org Cc: pabeni@redhat.com, edumazet@google.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, kuba@kernel.org, mkarsten@uwaterloo.ca, Joe Damato , "David S. Miller" , Simon Horman , Mina Almasry , linux-kernel@vger.kernel.org (open list) Subject: [net v2 2/2] netdev-genl: Hold rcu_read_lock in napi_set Date: Wed, 13 Nov 2024 02:17:52 +0000 Message-Id: <20241113021755.11125-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241113021755.11125-1-jdamato@fastly.com> References: <20241113021755.11125-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Hold rcu_read_lock during netdev_nl_napi_set_doit, which calls napi_by_id and requires rcu_read_lock to be held. Closes: https://lore.kernel.org/netdev/719083c2-e277-447b-b6ea-ca3acb293a03@redhat.com/ Fixes: 1287c1ae0fc2 ("netdev-genl: Support setting per-NAPI config values") Signed-off-by: Joe Damato --- v2: - Simplified by adding rcu_read_lock/unlock instead of using the helper proposed in the RFC. net/core/netdev-genl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 0b684410b52d..9527dd46e4dc 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -348,6 +348,7 @@ int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info) napi_id = nla_get_u32(info->attrs[NETDEV_A_NAPI_ID]); rtnl_lock(); + rcu_read_lock(); napi = napi_by_id(napi_id); if (napi) { @@ -357,6 +358,7 @@ int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info) err = -ENOENT; } + rcu_read_unlock(); rtnl_unlock(); return err;