From nobody Tue Apr 7 10:39:26 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 7BA7D3822B0 for ; Fri, 13 Mar 2026 20:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773435539; cv=none; b=bj+ExQXSoyUyxP8xCnyUAe1IoEztDV3Z43iOwb0q4Ppse4Zqcm6uzT1Tg7N0qhO7Y8oTNcAZOWCuqUwBybTZefJyYgGAvBS+101LCi6o+hQcNmqLYwdVZTId5hBZvm4h2JBoqGceN1OMHyvA173eKDbDkzZdYqngmyWu8CZ7atM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773435539; c=relaxed/simple; bh=EjlOG59djdew0+CoAm6FPU4BQF51f7/++vwrXk3pauQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BJtNdVIh2bNd/rdFSKJQRLnNi61SspRuh5+ixVljiD3ujkyBtg/GIzSbu7JMaQMCu9dJVk6F4sz+xt+ph6AS0mkMjf8V/Qsk0P5QInD1FEmVUlVWgiVs+HgtoVLuVrV7mTj89hmO02zpavUefZf61lsLo9z0jW47XDoZry5Xtc4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Tgj2ykcK; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Tgj2ykcK" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4852f8ac7e9so30091325e9.1 for ; Fri, 13 Mar 2026 13:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1773435533; x=1774040333; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IyL9HjXlVtkM7LllEkbV4aKNC8jKN7b938wPwskLBwc=; b=Tgj2ykcKd1OSqQFNk4hDh7KMoxqVRSAWfBcZVvhLM8l9BIqsYpsU1g/F9Pm8I7eQa6 SSf9XOHc6a7ggClEKdwYe8AyJHw3eYp6y7wcyU3rs9LsEELyi3T7/zWPx4D8tdycRHyB nmm54VymCoSEVyFehwk+VyNN0lMezpdlbUryNzAUr2G7G9beCKimcftcgUxvCqJjsIFW ATwz7PGZyvsgbrJjW0uz7E3m/sWf2cy+oin1eQ4jtQbrWPRSeyAZjYhJsGGH7TUlxJI2 YUsVGWn6fBjJkfxPhZ6o8mIs4T88YL8V4Q8MQsYTfKjp+xKcKeM5OxS4pEEgZDy+6pGj ZHHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773435533; x=1774040333; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=IyL9HjXlVtkM7LllEkbV4aKNC8jKN7b938wPwskLBwc=; b=G0gwiIzHSQ3qW34NU5nlfJW0W2XYQPH5yOdWVBPipRkVD0RpAo5tLlmq8kLdm6X2a9 Go97rDhuyku5DdeaeekqZaqlRYsS2KU4NJHtMu1PLiVNSFBF1DQn5fIcAeeh+rQO4Via 8gFXKgII6OXm6E3KZ4vGyDlCzlDUpCwakx3oiKjl4TtHKkXm2tMYxJRnhXLmWNCENYOj snZNbBv82LykK3eqK5Cuy1XoB5CXxLYS6AXCCesNNJIaOdSI6nxpHM3JyWGy/eVpjG71 KJdgm8HwMRK41zdoojwjsXfoUyU3KoLqDTIIpjpy2n8MSfuUGUgr41mMLDBpKYiKp1KL IUbQ== X-Forwarded-Encrypted: i=1; AJvYcCUqZF7Qu736TqeuuOOwt0Qw4D//3aOJC2+Rp8lPZD+2U7OUMH/Z6B5W1tSLSOQvUABX/rx82qRMQ8Opfp4=@vger.kernel.org X-Gm-Message-State: AOJu0YzH9ESOHbFzm5g5kS0/Q2RYpqz+TYOkFyCjwgcwTTCyl8WHNSx+ ggGN17eqHNuqAZr9UbXjmtBQYGgog7mmWCuxAKjS+f8Li6z/8rd/gEUqc5KjXA1dOPA= X-Gm-Gg: ATEYQzw9UX2IJFdbsdq3TKVIIVPCAJjAWlCv5NHts+7S/g/3ch7IRoRigsqCWs1DKpx srjGDL/zOpSkj4f9HvBOSpqYB/aujOqFGsUYozjVaPUostRDiapwBBlacTuR/1+gK/3FM705wiY Cc5xkMGKD4UGKWypv9c1TivLhM86Lqs/dLcHlqBHdykpbmL1LXLjK4CSCYfSLeXw2LjocTOJjm0 KcA/+Y0HQaNrOdjnGsgNTBFOYpwh7iwga08jgnjCYhOEctRBcmMZ/1L5SjelHZ0VIM53NsqpxGg FoXGJc3ZV9MJ396BWFMGzQaDSkDK87VhEzG+VkhkdzVIFQv85KJwwRRVY+bD3+Qk+mXNQ32qLeo 8RLDp17yL5fxtxTDNyGlPpZjp09Hb6x3qEZNPfAuEzo8a2SBMsBn7sFRsLzbaJ+gHCGZBK829yB qr9jC25Ie9nwww+HmakSS2 X-Received: by 2002:a05:600c:3106:b0:485:3ae3:b394 with SMTP id 5b1f17b1804b1-48556711ec9mr93938275e9.31.1773435533423; Fri, 13 Mar 2026 13:58:53 -0700 (PDT) Received: from [127.0.0.1] ([2804:5078:834:1300:58f2:fc97:371f:3]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2beab526d3csm4042611eec.18.2026.03.13.13.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 13:58:52 -0700 (PDT) From: Marcos Paulo de Souza Date: Fri, 13 Mar 2026 17:58:34 -0300 Subject: [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260313-lp-tests-old-fixes-v1-3-71ac6dfb3253@suse.com> References: <20260313-lp-tests-old-fixes-v1-0-71ac6dfb3253@suse.com> In-Reply-To: <20260313-lp-tests-old-fixes-v1-0-71ac6dfb3253@suse.com> To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan Cc: live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Marcos Paulo de Souza X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1773435515; l=4054; i=mpdesouza@suse.com; s=20231031; h=from:subject:message-id; bh=EjlOG59djdew0+CoAm6FPU4BQF51f7/++vwrXk3pauQ=; b=xZN725oHRhRMUg03sM0SZCOuYCUu9nt2V0hUx489e2bRu67lftT7q8cyHkbL3lWbpZa14HSz7 hFuv+iFkRw+Ayny0g91NJzaN2GfJQ55AD558wEgqL6bGe6yz0o0MgOi X-Developer-Key: i=mpdesouza@suse.com; a=ed25519; pk=/Ni/TsKkr69EOmdZXkp1Q/BlzDonbOBRsfPa18ySIwU= Running the upstream selftests on older kernels can presente some issues regarding features being not present. One of such issues if the missing capability of having both kprobes and livepatches on the same function. The support was introduced in commit 0bc11ed5ab60c ("kprobes: Allow kprobes coexist with livepatch"), which means that older kernels may lack this change. The lack of this feature can be checked when a kprobe without a post_handler is loaded and checking that the enabled_function's file shows the flag "I". A kernel with the proper support for kprobes and livepatches would presente the flag only when a post_handler is registered. No functional changes. Signed-off-by: Marcos Paulo de Souza --- tools/testing/selftests/livepatch/test-kprobe.sh | 52 ++++++++++++++------= ---- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/livepatch/test-kprobe.sh b/tools/testi= ng/selftests/livepatch/test-kprobe.sh index cdf31d0e51955..44cd16156dbd4 100755 --- a/tools/testing/selftests/livepatch/test-kprobe.sh +++ b/tools/testing/selftests/livepatch/test-kprobe.sh @@ -16,30 +16,19 @@ setup_config # when it uses a post_handler since only one IPMODIFY maybe be registered # to any given function at a time. =20 -start_test "livepatch interaction with kprobed function with post_handler" - -echo 1 > "$SYSFS_KPROBES_DIR/enabled" - -load_mod $MOD_KPROBE has_post_handler=3D1 -load_failing_mod $MOD_LIVEPATCH -unload_mod $MOD_KPROBE - -check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=3D1 -% insmod test_modules/$MOD_LIVEPATCH.ko -livepatch: enabling patch '$MOD_LIVEPATCH' -livepatch: '$MOD_LIVEPATCH': initializing patching transition -livepatch: failed to register ftrace handler for function 'cmdline_proc_sh= ow' (-16) -livepatch: failed to patch object 'vmlinux' -livepatch: failed to enable patch '$MOD_LIVEPATCH' -livepatch: '$MOD_LIVEPATCH': canceling patching transition, going to unpat= ch -livepatch: '$MOD_LIVEPATCH': completing unpatching transition -livepatch: '$MOD_LIVEPATCH': unpatching complete -insmod: ERROR: could not insert module test_modules/$MOD_LIVEPATCH.ko: Dev= ice or resource busy -% rmmod test_klp_kprobe" - start_test "livepatch interaction with kprobed function without post_handl= er" =20 load_mod $MOD_KPROBE has_post_handler=3D0 + +# Check if commit 0bc11ed5ab60c ("kprobes: Allow kprobes coexist with live= patch") +# is missing, meaning that livepatches and kprobes can't be used together. +# When the commit is missing, kprobes always set IPMODIFY (the I flag), ev= en +# when the post handler is missing. +if grep --quiet ") R I" "$SYSFS_DEBUG_DIR/tracing/enabled_functions"; then + unload_mod $MOD_KPROBE + skip "Running kernel doesn't support kprobes along livepatches" +fi + load_lp $MOD_LIVEPATCH =20 unload_mod $MOD_KPROBE @@ -61,4 +50,25 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching trans= ition livepatch: '$MOD_LIVEPATCH': unpatching complete % rmmod $MOD_LIVEPATCH" =20 +start_test "livepatch interaction with kprobed function with post_handler" + +echo 1 > "$SYSFS_KPROBES_DIR/enabled" + +load_mod $MOD_KPROBE has_post_handler=3D1 +load_failing_mod $MOD_LIVEPATCH +unload_mod $MOD_KPROBE + +check_result "% insmod test_modules/test_klp_kprobe.ko has_post_handler=3D1 +% insmod test_modules/$MOD_LIVEPATCH.ko +livepatch: enabling patch '$MOD_LIVEPATCH' +livepatch: '$MOD_LIVEPATCH': initializing patching transition +livepatch: failed to register ftrace handler for function 'cmdline_proc_sh= ow' (-16) +livepatch: failed to patch object 'vmlinux' +livepatch: failed to enable patch '$MOD_LIVEPATCH' +livepatch: '$MOD_LIVEPATCH': canceling patching transition, going to unpat= ch +livepatch: '$MOD_LIVEPATCH': completing unpatching transition +livepatch: '$MOD_LIVEPATCH': unpatching complete +insmod: ERROR: could not insert module test_modules/$MOD_LIVEPATCH.ko: Dev= ice or resource busy +% rmmod test_klp_kprobe" + exit 0 --=20 2.52.0