From patchwork Wed Jul 24 01:46:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Bainbridge X-Patchwork-Id: 13740538 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 50E2FBE71; Wed, 24 Jul 2024 01:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721785632; cv=none; b=FPsLs1/1wHswQZlnD6GoiEPaTiDxbJaPTlz18/z0o7G77K6E+AecR+bKVfTlJmDnGeh8Trbh4+5vn2wWQ2BECXbsTV4OwaIWYPcNnnEQZVvA16EKp5DG9RxhG9BxibLetJp2QSYWjgkp2OD60+fyq46gqMYYDXGqzSRBAqMqJ2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721785632; c=relaxed/simple; bh=jAi3voPlWolVP4YYB3fnxXWHT9iDk/r0DIOHX8TFBdA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YQXMxHL4MhBIvrqwAczAIHtB6H2X9Ep9bTtLSF0P08UAor4FshqQLRnsNBCqOEqFeXipiYIEq8ie96ycw/EavWtXV/FRcYyj98C+D4zBB3x3JRUaoJxt5CGTW3SxsKq/cJzLGPJfLzE3uzlpy/LlBFBntNk73S/UUR+dE3An3dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KtVlUxN5; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KtVlUxN5" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-70d2b921c48so1971026b3a.1; Tue, 23 Jul 2024 18:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721785630; x=1722390430; 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=lHbtbS513JbptLsFw2uOg7AhwIYd2Buyfky5JBypwaI=; b=KtVlUxN5mMHskMkRtB256ECpxBrTNLedK3fEQ5pImFguhn3Rcsn7eueDy4mrcUiiaA RBNuN8IHrY52QBWAv2mggQpbuEfTBFB4sAwTI0cxxvQdmzBSd0AJGE3opV9SgYJgy/yg 2sc4WWvBBvrzcRt+5dvzs+RsDILA2LDx1O+KHatc8nsS+cMKWMUo1+/RzXETHtHED0uB M2+1DesvdeciitJ8dE/LPQ8byDmNEWjTFd0RHq1il/tEFZ1wrHis/JT8k57QxGF0vSlL /QYZmhPHDz2QcwMOwBk4etF89E4W/njmu78pPWTFesAHZkz8Az8zKchRKa+2z9slmhqc /l7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721785630; x=1722390430; 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=lHbtbS513JbptLsFw2uOg7AhwIYd2Buyfky5JBypwaI=; b=ng1s4LktkJH/6FBln6TemHyh0ssbBdNtDutP7QCNXMw5sIHk/pDnvkxlXtw3aZaDEq /bgAQRsu3D+dGAGo0Hr0gYIPcjQEOsWRC/+8DYBeDtzCVcebjzVN8sQ+W7k5BvqvYQBJ 3pD9Tyf9Aykg/tE3HYnZidiEC2J1ZiVI/8fKK6BrXDLYMpEhd8iJaIrujg2iO6EwaOjn 2wuAnwGCdEefyF0XXdy+ShzO1s3tKhWYh7rnelUGlayPIqlwcJSRCTDBuyYMh0ivzkWz DMZemWL/6o8MQ4ASjr506jMX0XvBBwi04jKl/ygLVYk9wAQnpBn0g5yRTYlWBgSHVwGh /MPQ== X-Forwarded-Encrypted: i=1; AJvYcCXRPO12ugkpDUFieoMjil6YSvYsOGR91gAQl7L1dqoLipB8JOQNlqi5MVNWEgTCoo+Uz4CXG0eMfDj53darOxRvbk45y+/CydcPySwK X-Gm-Message-State: AOJu0Yye41/j02LOycZTehm7M0uLhuXjyWGjnpNsXjXOasBtgqaevEZd LeEq+rlMLhGzHFOK7wC4JHTd8Bzbep5y3K3AyLUjaNYsdqGhX4zzvisyQspf X-Google-Smtp-Source: AGHT+IG7cxyYe0Vou1ofkiw5iGJhZNQC7uqZLG8kBFIYJcdgDOwAl38ebUEeqwcIi+E+n24sO4Ar6g== X-Received: by 2002:a05:6a20:6a2c:b0:1c4:214e:93fa with SMTP id adf61e73a8af0-1c4619e96a0mr1056935637.46.1721785629963; Tue, 23 Jul 2024 18:47:09 -0700 (PDT) Received: from localhost.localdomain ([159.196.197.79]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb73a5f5asm314564a91.8.2024.07.23.18.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 18:47:09 -0700 (PDT) From: Jamie Bainbridge To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Jamie Bainbridge , Johannes Berg , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH net 1/4] net-sysfs: check device is present when showing carrier Date: Wed, 24 Jul 2024 11:46:50 +1000 Message-Id: <066463d84fa14d5f61247b95340fca12d4d3bf34.1721784184.git.jamie.bainbridge@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: 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 A sysfs reader can race with a device reset or removal. This was fixed for speed_show with commit 4224cfd7fb65 ("net-sysfs: add check for netdevice being present to speed_show") so add the same check to carrier_show. Fixes: facd15dfd691 ("net: core: synchronize link-watch when carrier is queried") Signed-off-by: Jamie Bainbridge --- net/core/net-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 0e2084ce7b7572bff458ed7e02358d9258c74628..7fabe5afa3012ecad6551e12f478b755952933b8 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -206,7 +206,7 @@ static ssize_t carrier_show(struct device *dev, if (!rtnl_trylock()) return restart_syscall(); - if (netif_running(netdev)) { + if (netif_running(netdev) && netif_device_present(netdev)) { /* Synchronize carrier state with link watch, * see also rtnl_getlink(). */ From patchwork Wed Jul 24 01:46:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Bainbridge X-Patchwork-Id: 13740539 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 2EAB4134DE; Wed, 24 Jul 2024 01:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721785636; cv=none; b=SGX+fcPwBAoGTWOg2/yyejC/VuOagy4tZ3qy1YvFc/Vg4U8BQWlsBDUATiNT+FxCscNJELEq7dVVtpk5Jvvo6FYa6jUTvHnU1sTq6G9ka1HkqDJn7ZdQfBZ/X4ls2e9BkCvRvPGfCNkPq4nzPo/lainiSfZLk5H/v1d2NQFEU9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721785636; c=relaxed/simple; bh=RRiFrZgzAdxtadZssrRgYYenCeicBdiczxoMgVLyZRk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U47bI6XyodhVDC7aqIm0WME+dG6Gj7ilW0NdlW1H7jzC+DiVNQPSMHsq5fM0BaINxHs+bvh7KmWoF8toO9Y0WdcnGRn6kHB6zEcHhyGeRSQjBjuJT81rRC7vtVDo8X8ekbvAJFZVHa1/9pY+SKnW34to/ADQoOiMNBW3Y1EKFsk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=K3SP7yxd; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K3SP7yxd" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2cb57e25387so3917551a91.3; Tue, 23 Jul 2024 18:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721785634; x=1722390434; 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=D6mREQmkxMWGeSPDPiv6IBNi7tWuWaCf4o+Mf9Xiwjo=; b=K3SP7yxd6dzBCSh/zP8JqMoaVnC19B9Fntxuqul2DLSggxH2aa5sfZU9Uhg3rkDPOT 7MCDZS0G8lNpFEEDzXIBaqQNWrT2A9RSI8kNRBxo5ICFIN6fUYi9I1Js9RG0qRPrAjjq IwAbH38JnJ/vyvAt4gYtBx3mU7uWkbOtYDt7sfckPzSso8nbTiR5chOMK4v9Gqds5NiB 23jw9jKhCv2beVqbMbPxhoiNbgRxXjiShBq47L8VRNlRv2DaFbiS6wrozDJ3jAdXUjxO wXBoVZdj0h9BZv2IV065CJ/F5zTjb+mQTw1x5SZSr2H9LRj0c5QGXEDJUp3iFpxbGgD2 AdYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721785634; x=1722390434; 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=D6mREQmkxMWGeSPDPiv6IBNi7tWuWaCf4o+Mf9Xiwjo=; b=qe5HI/AUNROixSuNVk/NyJ9SSBKtUb6YZ6TXp2njrgW4Bh0difDlBShvN9DHsstewn wZX9l2odK9y8l+o7mihrzt9sSoc1R+jvWyBsWh3MamOOfA6mL6JYt7URCrl+mC30arpj LVH5xxnOGgwZJV82kqTCXdjstpGfJoNof7l59h3SjxPWSszYPJ7K3AuzZt4ji295XZZ1 qAj668sSv/JY/kIzhromMwQhZqQj5twDcwKhDU1EZzT/3txiMegLSn6EMzM/kj6aklTn 9WMozUqlkdYPOqPwuKpBYoMj8gsRR9KkEl1f96RJDPI4CZeGXu5gvaFiNeW/dxDh2OFj HNdA== X-Forwarded-Encrypted: i=1; AJvYcCXgNcNLynudR2g/jewspm7e0Hn+K7k+Pv6/nAFHVXm24y9Wy/ah+jXMna5IoNEHe3YY74G/6N16UBKZMVtKr67oxkTyUM83C4qTOS+O X-Gm-Message-State: AOJu0Yyi6T8isSEYG4u6GOKmFVKArORUHfLA8M5dFrJE2f9sV0WkRc1R OUH+8XVE7i4WEdU8uup8b1AHu5mGLfToFuJf92wfOPA+w/dW6zp0fs0Ff/vA X-Google-Smtp-Source: AGHT+IFpJMucoex5Iams7A4EI9gSuS1aXy0D3+wE3hhFmoW6nR2s1YA5rlgV3vhgGcXLPwx6F6PB3Q== X-Received: by 2002:a17:90a:c908:b0:2c9:6ad7:659d with SMTP id 98e67ed59e1d1-2cdae2ec122mr1681152a91.6.1721785633996; Tue, 23 Jul 2024 18:47:13 -0700 (PDT) Received: from localhost.localdomain ([159.196.197.79]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb73a5f5asm314564a91.8.2024.07.23.18.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 18:47:13 -0700 (PDT) From: Jamie Bainbridge To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Jamie Bainbridge , David Decotigny , linux-kernel@vger.kernel.org Subject: [PATCH net 2/4] net-sysfs: check device is present when showing duplex Date: Wed, 24 Jul 2024 11:46:51 +1000 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: 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 A sysfs reader can race with a device reset or removal. This was fixed for speed_show with commit 4224cfd7fb65 ("net-sysfs: add check for netdevice being present to speed_show") so add the same check to duplex_show. Fixes: 8ae6daca85c8 ("ethtool: Call ethtool's get/set_settings callbacks with cleaned data") Signed-off-by: Jamie Bainbridge --- net/core/net-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 7fabe5afa3012ecad6551e12f478b755952933b8..3a539a2bd4d11c5f5d7b6f15a23d61439f178c3b 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -261,7 +261,7 @@ static ssize_t duplex_show(struct device *dev, if (!rtnl_trylock()) return restart_syscall(); - if (netif_running(netdev)) { + if (netif_running(netdev) && netif_device_present(netdev)) { struct ethtool_link_ksettings cmd; if (!__ethtool_get_link_ksettings(netdev, &cmd)) { From patchwork Wed Jul 24 01:46:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Bainbridge X-Patchwork-Id: 13740540 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 621AA1AAC4; Wed, 24 Jul 2024 01:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721785640; cv=none; b=dr0QPOpj6VkPzFNUBQTGUbcgloVqvBCFMec9gHWGYIbdpuvqdkGwvG8SMj+LUpoMsOKrc9Wcc7HqLmq4UIqBhXlTxGT9qtY1RRi2gZrAbYpyg03iy6AGtAG4JBw8Gygfy6O1oFERYdvhSBTUue1gUUsQ2TkKqSUpZEMMI5dBsME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721785640; c=relaxed/simple; bh=c3GncpxPZcA1taNUudoTyAcqB+R4JU5v2hVYCyR26mU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fsEwm59/EZLyBH7qpHzNxmKI7Vy+4FXw4YbwXBRCC9/AGSjcFyqcpMig9QfVDdmJqZOSqV2U71XJBVQ92KSGzahX90atJNgwCQOrAKsaHBtnuJe++lEvIHkDOTL5ncDGAjxtn+QQs+VSH0dJ/k7HToST3EUnUCNPip93X0uRXpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mRlgJSf2; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mRlgJSf2" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2cb56c2c30eso293987a91.1; Tue, 23 Jul 2024 18:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721785638; x=1722390438; 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=UzoaOAE8mtc4ll9mWUV2yqA7g11y//aTQ0G+wfCrhNk=; b=mRlgJSf2J8jfus5pRxHfp/BLzYeTIIKMTEsnH/M3sUvSxRms9wbE5m5SakYRuHKqkB 7205lsCrYrpK714bR00te+tXmqj30lSEfQHcVqfV1qwcrY7mqMpo4Rj7aiKiQHifw6Fd rIQsfmPDhOJJMn/oRHwrAYXvj4QtDj3mh6IZdBAjZracitgGmNN3eanv2IMJqA2bDQNs EbLGPb8EoMHfAuGaKA8dpPEeWPF9RsC2xYEXYMdAuZO07cEM6iyRw9VaOoBggtY9MMn6 dNcraBaL9VOHkWAZQdetJVZI+Ud+eDLI/ONTgzQDO54ISJReQQYTYuaHdD8zUgX2UGsj U8LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721785638; x=1722390438; 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=UzoaOAE8mtc4ll9mWUV2yqA7g11y//aTQ0G+wfCrhNk=; b=tKsIe+KgHJn3BHSZatUKQn9v0A1gUuX89BGC1lDR3EuAUwvueJrhz86dWt4BVwQNv8 5mL54zCMFlzSOjdPgxO/0BCEm/5L71QdFZQpe+W27vNtrsCQDnOJX+biycygHts5oyI0 pQpOd1OzFFJfheQAXVkGKOcNElRWL+ac8Wi15/Evf6pqlZ1Z9/GaXLnxmQw9qDc31rah mcR+vejr13LCxFoX5K5qFyZBTimfNeDg3rr8XCOamOk7REkhFhp8k1vbJfl15xsywDXc gu9C/VJnaCA4dC2WLDV+ws2Utm8hsC06sxW9pnR1anTn8ki0Ayj953tcuCEWoEMDO2Jf 4rZw== X-Forwarded-Encrypted: i=1; AJvYcCWKg0INRbgcsBYgRI3nd6bLEfc6n9hSczK3MNEPcNwf6p7hRwSbndOza6q0PqRTbnzprwwlZGaeOuC1rKCIgHcLVqvVIYjYhrq0m/aC X-Gm-Message-State: AOJu0Yyg0ajkN1XUiD+i1ZkJW4krRKiettEGwAQOLFy1aVO/JoiFd3y8 qgjlSSC46FDU/wMWDJvpgVm5hBxR39K5XR3ATc77V8zdwLEvEi0Kv7CHySiK X-Google-Smtp-Source: AGHT+IERHuUZtKUvDN6QlVo1a+k+ACP65aDBdLCNUACZKnA1Cw0PbBgvOz/ps4ZWrTlpsQxKn46yMw== X-Received: by 2002:a17:90a:3484:b0:2cb:58e1:abc8 with SMTP id 98e67ed59e1d1-2cdb941f681mr635135a91.21.1721785638297; Tue, 23 Jul 2024 18:47:18 -0700 (PDT) Received: from localhost.localdomain ([159.196.197.79]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb73a5f5asm314564a91.8.2024.07.23.18.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 18:47:17 -0700 (PDT) From: Jamie Bainbridge To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Jamie Bainbridge , Andrew Lunn , Florian Fainelli , linux-kernel@vger.kernel.org Subject: [PATCH net 3/4] net-sysfs: check device is present when showing testing Date: Wed, 24 Jul 2024 11:46:52 +1000 Message-Id: <2a96f450e4150e9b8c39fb000d82c17987c5bbc5.1721784184.git.jamie.bainbridge@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: 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 A sysfs reader can race with a device reset or removal. This was fixed for speed_show with commit 4224cfd7fb65 ("net-sysfs: add check for netdevice being present to speed_show") so add the same check to testing_show. Fixes: db30a57779b1 ("net: Add testing sysfs attribute") Signed-off-by: Jamie Bainbridge --- net/core/net-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 3a539a2bd4d11c5f5d7b6f15a23d61439f178c3b..17927832a4fbb56d3e1dfbed29c567d70ab944be 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -291,7 +291,7 @@ static ssize_t testing_show(struct device *dev, { struct net_device *netdev = to_net_dev(dev); - if (netif_running(netdev)) + if (netif_running(netdev) && netif_device_present(netdev)) return sysfs_emit(buf, fmt_dec, !!netif_testing(netdev)); return -EINVAL; From patchwork Wed Jul 24 01:46:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Bainbridge X-Patchwork-Id: 13740541 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.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 921941C6B2; Wed, 24 Jul 2024 01:47:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721785644; cv=none; b=Y2cqfow//rABzycRameSVDxK5rEWAtqXpDoPxNpPMa3it1TfI340BmLlfZ0K/3no2Y24+W9rR6Eh+oob6EjpkxJ9bxOV62Be6vr96lyz9CSBttHzZKvboena95gS/ynwUGzyeef2S6R2jr48z9vNGvjiS3wFDK4RUr0KcUO2PWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721785644; c=relaxed/simple; bh=HIPZaFh9Yecwx65PpnkfqLQC2xvEgZhlTWGXWm9wIlk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CPu8vnU+jOsH3PdqRjVzIYAHGw/O3vLOgFzU1U7es9lgJ0A0eBu4gU06NZAEQ+0r6NJOWhQvoihpn/41/mczsYgDwH4bxUXhz6D0Q5fm6XYdEX7ImdIjQwepIWNUhj368QeLG5HTgx6Nl4PgWKfYQWSbKqAynQvqkurSqzOlkew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dDwMFZfq; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dDwMFZfq" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70d24d0a8d4so1814339b3a.0; Tue, 23 Jul 2024 18:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721785642; x=1722390442; 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=ixBaPt3HwUBSQNgJD5/MCt2lI2he2/bUzlD4zYQg34g=; b=dDwMFZfq5reqpiOFepVaOhIPc/R0rG4nmhLUdQ7jOcn9Yt+vcKp3sZFqlbnlqQ9do3 CrCOuM7b3nkf0EydYWwerm+WbYVo4MJo/1vW2FOPMV3bvoJvv7SmIPV7aDZzCoEmKMzs 6pETPSuP7SQiXtmcKuMlnK0QnqgViCXdfk38WelJo4s+TVOk54gnC1Ufz3t2kxHCC5Y5 L9l7+egf2f27jYZJ5h+OqJTNTxXfXPwPeqXneiQDi9SCwkSL3SxonP5n61xqX+7vF1Uf MO3SJfct/ACQUfOHmKCtSgrpvzeLnu7TyWrNM58FyMgc/KCLxTa6P7rwXhSkNfa2L7Ly Dj1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721785642; x=1722390442; 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=ixBaPt3HwUBSQNgJD5/MCt2lI2he2/bUzlD4zYQg34g=; b=g495qGGoCNo85PVV02nH8liaXHMjfuDxjOL3JVkVitdMtssiKAa478du+gV3t5Ayrs wci9ZjEDxPo2YXAqBKRPwF/NX6H+XLqjUG+qNUO/cIavsRiKRIQyzh1o5Fp3DOQePj3w 94+Anmth7Xti4aePYjPEGJQHOdZAvSP9VEW/f+FgrE+zu/xqNrmYtrXGsU09+hX4eS0p x91fB7cLKs+SIsG0NM2pyjKNxQdMTw2aw2OPws0R25XqFImggUMC0xaVQ9mj4lNLZ3BQ ZfFYs6A0lWXrufvsrRFUETO0JGdi5Oxt0YQ5XQ+Rrn3+RXf3blcfWpyjMn8ErHPgvIzI ZEfg== X-Forwarded-Encrypted: i=1; AJvYcCVzSqamxUv75pBsQCY2t4RIF2rgdCKfzWwK5/14IqTHHnOswTsozzRgRt6/3MKzCW1xFitv74UEXbiJZ0YXDIeHp9QXaxxNUwNHEvuE X-Gm-Message-State: AOJu0YwblsyHVm1MdP7qwM5tl7NuLB7yZr+43E/G3h32V15tjLoVrXDd S8GYiP0iz3J6VJUh4Skk9nNaQ0fW8VIO9u7ijFLtPNuLEx2dt2dyO1K/eBvV X-Google-Smtp-Source: AGHT+IEzb3HhOlXc05SU9bt4B8hsihQpnQJiUMKfpkiSYXtvWZtRhKv4Q3D5pKN5cYFnan7xoExGSA== X-Received: by 2002:a05:6a20:841e:b0:1c4:2540:1735 with SMTP id adf61e73a8af0-1c4254017aemr13020132637.16.1721785642340; Tue, 23 Jul 2024 18:47:22 -0700 (PDT) Received: from localhost.localdomain ([159.196.197.79]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb73a5f5asm314564a91.8.2024.07.23.18.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 18:47:21 -0700 (PDT) From: Jamie Bainbridge To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Jamie Bainbridge , Stefan Rompf , linux-kernel@vger.kernel.org Subject: [PATCH net 4/4] net-sysfs: check device is present when showing dormant Date: Wed, 24 Jul 2024 11:46:53 +1000 Message-Id: <5d51ac5ca591bb38cc822376e878f0b30864b916.1721784184.git.jamie.bainbridge@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: 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 A sysfs reader can race with a device reset or removal. This was fixed for speed_show with commit 4224cfd7fb65 ("net-sysfs: add check for netdevice being present to speed_show") so add the same check to dormant_show. Fixes: b00055aacdb1 ("[NET] core: add RFC2863 operstate") Signed-off-by: Jamie Bainbridge --- net/core/net-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 17927832a4fbb56d3e1dfbed29c567d70ab944be..ff2a1f6ef7e18be56c2de51902519066431e47a8 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -303,7 +303,7 @@ static ssize_t dormant_show(struct device *dev, { struct net_device *netdev = to_net_dev(dev); - if (netif_running(netdev)) + if (netif_running(netdev) && netif_device_present(netdev)) return sysfs_emit(buf, fmt_dec, !!netif_dormant(netdev)); return -EINVAL;