From patchwork Wed Jan 8 11:50:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 855830 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 AE0561F9ABF; Wed, 8 Jan 2025 11:50:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736337041; cv=none; b=cbrZVmTgfSaKiaI3j+yV5cdywBqCOZw2ygHG+uFSLf7pWtTu4ETSe0VB9HTVe54g1Hg2a/uOUrB41MS0KubSHdHlliUBldkGyB9tlbZtKkSmceknRHlJ6YUz3KuA5LKoJ+h1YvVVnuOllgwvA98Y/Mdo/w5hwWoZVmhYZnlspMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736337041; c=relaxed/simple; bh=b0dr5T0QwnIxuuEvkRyv8EVkHvyXW4ldpeHd7C+rkBU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HmsUK/Mrt9PNuKp8tKaq9nyWjAs7AOemGQ9EvJkC8q2PzygfDoosVEZUtJ8fTyFrC0dxw3Da3h1EknxwPFM65VbJyB+ZtXcNdiMj0nI7nbhMKnj2S7S6+j0lqOwKh/P8GQueoJv1Nsv3tYgnLRm4cAIlucilhUT81mYdaEm22x4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5d88c355e0dso11017563a12.0; Wed, 08 Jan 2025 03:50:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736337038; x=1736941838; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7Psq5v8QcPJKBmtJbh0DGeIRlVIPLBPUK0VHBQQ4Les=; b=T8iQyCFF7Do1XGhEpoSZLlB3dqLZowlqTWp/tEUQsmIsYEH6+p0JbDMdTdYb4F2k/K gkMvHvuYC2s4K5OBhXPvzJlyGu/UVlBJmXkXQJWTkjYiFerpoydeTerwm4YxWi340WDA djzy4Wp8AI7daPJSmDbMefL1kN3ZOrVBsMHDGTJePfjfMzwRrSkxaiZ8cHsPIWCVcUVP paqVexgiXW0uza8kZBtNRl6B+4GFYXqtwFBcHKCAVSYjda6YXIHpVwxyZENAryxIN57Q pfpeTZCV984hWQ5pRgUye3xWEGpv+JXMOEjc+iab/ckW51raezrq16j3RZXQ/wDwx0Ve iQRg== X-Forwarded-Encrypted: i=1; AJvYcCXKtUhkeZJj/8Yr6xdDVeCMNLMOjzct+DNvJ+JJpFZbeRM5VtPJG212eNSXipcacwurjXgDFx3i6xMJBCtAuKPC@vger.kernel.org, AJvYcCXVV7BLUUUF9zldzKijuZ/SRG6UVSWwj8S6tiQOIkPQc1YqG9wT7p3NVcPW4MYo3IfxwwLZ71LJPf8VhY4=@vger.kernel.org X-Gm-Message-State: AOJu0YzUBjfXepup7p5gamu4ejfUgfUC/8WJ9Hak+oR/5r8QYL+3A661 rnLaQcPR+s4OZTtUZfzUkaI5QMsubrdPwj5prbCy5m7/mc2OX32p X-Gm-Gg: ASbGncv6/dz9f5fwu2JhIkBRj5KRY4YRENKF67AWBGRwNZokZjGq7fxW7M2iSzjmCNr VDQ/cY0VkYqqzZETp5A+2cqYCeq/TgSYjDQ40ETSMKmbTJgCoGe1Q8bHrl+klkqR9dxznspCy5W KKhq+9O/Q7engtRq1yL2rY8I3tsyHQ4NtQCXnnm6f8qyqD0gnG4GVhPm6u86ft6Mp+wyLy9O3qA LHsklQ3xMIorw41wDaDsg2SXk4UoNfQoBBd/IZDZ47Klbo= X-Google-Smtp-Source: AGHT+IFopCOJu21oDNmoL8dIpNxFJc+Y2ey9HhB3yQ4O1yEV8uUW0MjU9SFgmk0F84MMiz2KIKMjMA== X-Received: by 2002:a05:6402:254d:b0:5d0:81dc:f20e with SMTP id 4fb4d7f45d1cf-5d972e1c5cfmr2010285a12.17.1736337037976; Wed, 08 Jan 2025 03:50:37 -0800 (PST) Received: from localhost ([2a03:2880:30ff:6::]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d806fed2a1sm26174988a12.67.2025.01.08.03.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 03:50:37 -0800 (PST) From: Breno Leitao Date: Wed, 08 Jan 2025 03:50:25 -0800 Subject: [PATCH net-next v3 1/4] netconsole: Warn if MAX_USERDATA_ITEMS limit is exceeded Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-netcons_overflow_test-v3-1-3d85eb091bec@debian.org> References: <20250108-netcons_overflow_test-v3-0-3d85eb091bec@debian.org> In-Reply-To: <20250108-netcons_overflow_test-v3-0-3d85eb091bec@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com, Simon Horman X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1033; i=leitao@debian.org; h=from:subject:message-id; bh=b0dr5T0QwnIxuuEvkRyv8EVkHvyXW4ldpeHd7C+rkBU=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnfmaKt0S/vMpwW6p6OgKnXBLS9xdtOqZpapuDk tQu/CcpzRGJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ35migAKCRA1o5Of/Hh3 bS4ID/wOOpk4VqlkC2/I80iu/4R1Nc9Usrx0LUlahssak1vjgUqxrAQf9spzw3atgjl4CuaYICF AD3/pGCV8+yig7qL3QX05W+Ct6I6drWk/eRNKzFT6KsVlQUhkFhnTOBALnJRTc4ijXn1GDxk/vW rHMkcBVu3jruzZHDrNmJwS8X66T8cAD8R9W0wD98IYUEnm3zwj6Zoq7CjPruN/nTcN5uV3n1pzt IFziB4/m0jAqjo5u3tOPmsFLZe1BBSiFUzASd3u7akO7jd/7WURBqy2RSl2luWu05J+Nv7bSumh 80i2wiElapymJ0zFdJRCORMmni4m5IlbtB6OMXNWLf1ZMclf7C/IHlNIPI3uFw0NxmYERYMau0n 4gEVlOuZDbHqXfbursa+q7kFpNMtbIkVFtFYf1Mo4bpP8dA/iKA6La/j/FF0+QTwKM2GnrEvUHh kCL19afZK/9rh8SVPpJ06MMRJGWP/8Wt7G/JKLGisLEAloUiR3jIk5lEE8C5E/9mU8QyiXWyueI fdP6ClxXoq0SB2PLLg2cTFyqiPj5VgPvaYIg/Tq0TbZ2zfTqIjUhI0DnmLMt8gdlnwDvCxg43Z2 pcdDTQn3aFuEK9QSS+9JYIXQ259JQwjEKRbXzkLTDhE/uMo0vnC2pb2kwZm0cc9Vyulq7czjj7L 2ijLk2cneqjcspQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D netconsole configfs helpers doesn't allow the creation of more than MAX_USERDATA_ITEMS items. Add a warning when netconsole userdata update function attempts sees more than MAX_USERDATA_ITEMS entries. Replace silent ignore mechanism with WARN_ON_ONCE() to highlight potential misuse during development and debugging. Signed-off-by: Breno Leitao Reviewed-by: Simon Horman --- drivers/net/netconsole.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index f422a2f666ef2276cf5b10e1dbc6badbc8ef0038..86ab4a42769a49eebe5dd6f01dafafc6c86ec54f 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -730,7 +730,7 @@ static void update_userdata(struct netconsole_target *nt) struct userdatum *udm_item; struct config_item *item; - if (child_count >= MAX_USERDATA_ITEMS) + if (WARN_ON_ONCE(child_count >= MAX_USERDATA_ITEMS)) break; child_count++; From patchwork Wed Jan 8 11:50:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 855829 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 525711FBC91; Wed, 8 Jan 2025 11:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736337045; cv=none; b=o9EDziNWC7HRyk3N4SAEpy4tbHtbS5ld0eaIvXdUTgTqwpeNlNCwfDGzHIOKyPb8vL11x7L+QsNLAl3C+q/y/kR3lxZAap8KVSwLoOsMmdplv4Zrz5O9bAHtAaOAqmXZ1ym+CBoJ3XSCZfXZ6MVMo48jjMh7aYIIw3lWLhG+k9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736337045; c=relaxed/simple; bh=5NsZyre7dhB8gjVJrgCTRYi8hSfLC+Af6awHSBnzZaA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iuYnOzTMhKDqhMB0svLZD64dJhJi4bCCT5vNY7FsqyekP9zBYMCdZGb9RqQmT8incoYzJ93JPBf+y3h5NQKhDCQsRjpvU1MXEtoBG+cu7MNiLKm+27KsJh5WRVuR5Rk+jC5IB6o8iZT2tXMkmsU4c/l01EUxh/4pBFiSgI1LqS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5d3f28881d6so24759579a12.1; Wed, 08 Jan 2025 03:50:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736337041; x=1736941841; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=10Sv9Y7ixrJh+da5K4zI/xAp2zqjv0+XI+pN38JTjZ8=; b=cKJ5eVE5pVWL21KQQGfiJsX/PptL4v4RKoh9tbFJ9CgzyXdypFcFu7iVoiaUpYsqaL C7d+wauGP5hgM3BDuMzHX9HVK3GYI3Rds8ux/epyzGKhvsJzzorokzQxxUIksN/HAcww MU07cmyznAXrkBZsbOcDqBF7ww5u7tNcGdl6w7ufCCNF4n/HxaYc+LzyyP5dEhoSLkzP gCfdSK4/OZVoBUa2e+wC5StiJzGp11Y5JZN9ioBE4GYsrpKvnw6pGGaPhbklu1+bDVOv y86jpD4MF35vsFxQEAAo0SML14YZc63mObP37BNTTYQSeFVSOBhcoJsnFtAYp8KrHSVy 1kfQ== X-Forwarded-Encrypted: i=1; AJvYcCWEmYFgCGpSv59kgqsj0b+PYKOzuAYlrq343QjJ5usOhcaUOX5+RDHrqIpsknztjMhP/82uqlpNG8dmJcz8skwN@vger.kernel.org, AJvYcCXsvq4LQ1RdWcE2UrdEWLtE6xofIRKA3nCQFLPCHzavD/2lzJjKF0FrsVo8r1KxboAO9HcHLRO4aARGlU0=@vger.kernel.org X-Gm-Message-State: AOJu0YwwBRT38jZc8YSTQ6Sp6nCIAhobeylSClMWqldEHKs1zMZ+cDrd kmryP/+TwmSIDE2PoIoLPZ6s42hoafvIiTctkthXoPerTB4rue01 X-Gm-Gg: ASbGncs8UhngJMMJ4ybMYEMNts8SWjncp48+7co7TaMoTZwFnBsiY31JSFbDA4VtPEv caW8vlnWrKj3g+yXXnmFE2KJr8GnZNmVGC59DXybMoFkqTBRDHzlRMhG1p4yvCihmbjWY4HYvQw OKiesGuixv5haxqMCryFT8q95O9fIRWLYneDrXuHdPp8gYVu5YuKEe7ZrRpimZNBZVWG6S72Au/ gD9y7xoG8WAPX3I6f3N+nYfRHs6Rlewr33r+k3gvcACpEGm X-Google-Smtp-Source: AGHT+IH7NRytDkgi57nzFn007chLWDtnMegqO5CoMn01qjqkiJcL0beA2O+M/nI74hZBU5K073h7fQ== X-Received: by 2002:a05:6402:2548:b0:5d4:2ef7:1c with SMTP id 4fb4d7f45d1cf-5d972e639e4mr5337731a12.24.1736337041391; Wed, 08 Jan 2025 03:50:41 -0800 (PST) Received: from localhost ([2a03:2880:30ff:74::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aae8b7de1cesm2321862666b.23.2025.01.08.03.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 03:50:40 -0800 (PST) From: Breno Leitao Date: Wed, 08 Jan 2025 03:50:27 -0800 Subject: [PATCH net-next v3 3/4] netconsole: selftest: Delete all userdata keys Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-netcons_overflow_test-v3-3-3d85eb091bec@debian.org> References: <20250108-netcons_overflow_test-v3-0-3d85eb091bec@debian.org> In-Reply-To: <20250108-netcons_overflow_test-v3-0-3d85eb091bec@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com, Simon Horman X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2070; i=leitao@debian.org; h=from:subject:message-id; bh=5NsZyre7dhB8gjVJrgCTRYi8hSfLC+Af6awHSBnzZaA=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBnfmaKFSsKWkOpGsBGb+V3+6JtTu/T/ABaU304s fNMMYay2/eJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCZ35migAKCRA1o5Of/Hh3 bZzXD/90cStCYZR/lkixASdyf3TlSbyXMF4991WY+3N0N2Kivj9DRwkBaG5s5TP7+76Lhx3Xdej /QG6rTZRrd3SiQ67wunmvXuEwtIjeR6YVLHNxXFIwK1nFbXwEeq/T9kXffs/PS1cgSMAn0BzbTj l4IxTehF8k6Lhzm4bEZrjsAkwtrwL+eeW8PhUljQ5BAonIVxHzm3ZLYd4AQwwdaurJNEqCgMsz1 aiKwywDOhQ7kOl5NiLU+c5cFpcrBjY054pu1hz5CZYHMD/sMmudRgiNNDokXT5CT8RACJ3AeZv0 nfFppHLgQWjk0ANJzbjPgMrd0r3lvvtnC4NPzI55rFNCG1goIvKuSEo6Mm26VXozLOwn9YWVTH9 TX5XH5Qc4+kYJV0xnDssxJ4tZa+n8+AgEC7oy2VSIxcu1Z4DuEUqMuVX+v8ydjUEg+PDOAKbKvF ZimAezn1GtQqSp+EA3/xGYzgklDPDZooF/dJbB74nItNhKam6vZiS/BPeSmj5TTMawZhsusrWJq 4ssbm6tff6hZQxt/jo7a9F4GEoKeTccwMdmop0QMNv5BTJYogceVtEDSNIaAs03pIhiRfrU1G8+ 62oBetljrc10Ya43KTcXsWUw9+5r5K4Df8gr4aGNlUBVT4rCxPtZc8oa8/ZABW/4sVkc56JRDaN LYuwkCrzMQgaIeg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Modify the cleanup function to remove all userdata keys created during the test, instead of just deleting a single predefined key. This ensures a more thorough cleanup of temporary resources. Move the KEY_PATH variable definition inside the set_user_data function to reduce global variables and improve encapsulation. The KEY_PATH variable is now dynamically created when setting user data. This change has no effect on the current test, while improving an upcoming test that would create several userdata entries. Signed-off-by: Breno Leitao Reviewed-by: Simon Horman --- tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh index fdd45a3468f17449eeb66d9a808b7a3b2107e47c..3acaba41ac7b21aa2fd8457ed640a5ac8a41bc12 100644 --- a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh +++ b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh @@ -23,7 +23,6 @@ TARGET=$(mktemp -u netcons_XXXXX) DEFAULT_PRINTK_VALUES=$(cat /proc/sys/kernel/printk) NETCONS_CONFIGFS="/sys/kernel/config/netconsole" NETCONS_PATH="${NETCONS_CONFIGFS}"/"${TARGET}" -KEY_PATH="${NETCONS_PATH}/userdata/${USERDATA_KEY}" # NAMESPACE will be populated by setup_ns with a random value NAMESPACE="" @@ -116,8 +115,8 @@ function cleanup() { # delete netconsole dynamic reconfiguration echo 0 > "${NETCONS_PATH}"/enabled - # Remove key - rmdir "${KEY_PATH}" + # Remove all the keys that got created during the selftest + find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete # Remove the configfs entry rmdir "${NETCONS_PATH}" @@ -139,6 +138,7 @@ function set_user_data() { exit "${ksft_skip}" fi + KEY_PATH="${NETCONS_PATH}/userdata/${USERDATA_KEY}" mkdir -p "${KEY_PATH}" VALUE_PATH="${KEY_PATH}""/value" echo "${USERDATA_VALUE}" > "${VALUE_PATH}"