From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796292867; b=QFm9Zit9fbf7ki9tdcS8t58U+FdxeiyHPca/CJn2t7FJpucHgvBYDDOCrntopCE1kMDa CqZBE12MODfKTDpIYRA1QKYPsQYaoQCNUujpWkEnnz8ruqLpG58QMrhsDRGx999Osjyze 8hpsJdm5oR5mlYV0a5OXOjvlw+Hen/x0zKZxNIxOi6hxP0xe2cNcikUkO9ujm4B95AtX2 /T1hF+QSTgS3k8df1QOCBsKHXvrn+2qlg75QlAmz6/nKvbuypUkRC2Xc7zZcSpSSJscv3 hjegATyKrLDWQLZ+qJ9mL/hS24tRwGSCdJ/PE4BuHPcGm9aFv7f7GeVQ78OQ+cJ5PtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796292867; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=sjENKBoN6dj0uiFVNZ03eS5yeJ+RUTT7lctLuaK3ZYA=; b=CQiaPGLiTdcwXuwz3RAS1NCl0geysjOVlUfR5EwsayTpw1GoWju4RhwmnWBpSQplEJ8z rJAg7gA41IhBgSWA71wDC8ZsmEOZReCZ708zRVV48A53s0zajCCJQaiB0JkfFz/2hWqPc wL7Yqs23ahHoO6JvRybV+orII1GNqYT8u3N3Dxj6/RGzEbgPvL4yZOpZTO0lQ/sLt5uzb iO9gpzrKYhy4n3fVztppb/5KHi+RKo+/cZ5/vMW1aeoKWjVde9AEvooE62EKFs+q8IzKI APtAKssgUtlzBbxNZ1MhkiA6+VqXHnF9K9n/V0Vpmv4F3MNbNnR4bbnOqFtN4QiroZw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cVjiXUxw; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8424C606A68F; Thu, 3 Dec 2026 10:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cVjiXUxw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E21B1F000C1; Thu, 3 Dec 2026 10:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796292867; bh=sjENKBoN6dj0uiFVNZ03eS5yeJ+RUTT7lctLuaK3ZYA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=cVjiXUxwSWAkDEa7ZPUgeISUiimCtBtH+8zjHC4O6M5JBZq3Kvp99ibSNdb4qFxbR D4bvxHvezMYKdOgcLMKOc9QI6uHNDpLwrUIqcvaeUrG0FgPntWk8Io7X6mzXTPkhGM ICvmlyWL4885uMzuHbF3kIs5W3eB7aaHRRXIlaZm3mACd3XMswG7y1oARIc5mZoOxy NwKOwH0maZyxKQdA86O11IxybYthCsRsi5TnEPAn6eDbC43UAihzkQb8//lMhLWaZI meKQTfqf8p4WzO4MrPu9QXwZSIfMPdfIdLB/0ElVONOxPC4hoXvsrr/Xbj0SsR2NbY zFIVFwY3kjOSQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 4/4] kselftest/arm64: Add HWCAP test for FEAT_LS64_ACCDATA Reply-To: sashiko-reviews@lists.linux.dev To: "Arnd Bergmann" Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261203095703.655796-5-arnd@kernel.org> References: <20261203095703.655796-1-arnd@kernel.org> <20261203095703.655796-5-arnd@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 10:14:26 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Critical] arm64: NULL dereference of next->mm in ls64_accdata_thread_switch() on exit - [Low] kselftest/arm64: ls64_accdata_sigill() never verifies SIGBUS or BUS_OBJERR -- commit ac9920ac55cd362ba0b8ee0ff7743b42ef69f9c4 Author: Arnd Bergmann kselftest/arm64: Add HWCAP test for FEAT_LS64_ACCDATA This commit adds a HWCAP3_LS64_ACCDATA selftest to the arm64 ABI hwcap test, issuing st64bv0 on a stack buffer to verify the instruction does not raise SIGILL when the feature is reported. Link: https://lore.kernel.org/all/20241202135504.14252-4-yangyicong@huawei.= com/ > diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/se= lftests/arm64/abi/hwcap.c > index 19fca95f7c228..4c89a897837db 100644 > --- a/tools/testing/selftests/arm64/abi/hwcap.c > +++ b/tools/testing/selftests/arm64/abi/hwcap.c > @@ -693,6 +693,48 @@ static void ls64_sigill(void) [ ... ] > +static void ls64_accdata_sigill(void) > +{ > + struct sigaction ign, old; > + char dst[64] __aligned(64); > + > + /* > + * Like LS64, LS64_ACCDATA requires both the feature to be > + * available in hardware, and the address to be on a device > + * capable of the transaction. > + * In addition, the device driver that has mapped the device > + * must have created a PASID that can be used as ACCDATA. > + * > + * For testing the ABI, check only that st64bv0 on a user > + * address gives the expected SIGBUS error when the instruction > + * is not enabled for this thread. If it was enabled, the > + * error status would be reported in 'st' instead of a signal, > + * but that can only be tested if a PASID is set for this thread. > + */ > + ign.sa_sigaction =3D ignore_signal; > + ign.sa_flags =3D SA_SIGINFO | SA_RESTART; > + sigemptyset(&ign.sa_mask); > + sigaction(SIGBUS, &ign, &old); [Severity: Low] Does ls64_accdata_sigill() actually verify that SIGBUS with BUS_OBJERR is delivered? The comment states that the test checks for the expected SIGBUS error when st64bv0 is not enabled for the thread, matching the ABI in Documentation/arch/arm64/elf_hwcaps.rst. However, ignore_signal() only advances uc->uc_mcontext.pc without recording SIGBUS delivery or checking info->si_code =3D=3D BUS_OBJERR, and the hwcaps[] entry leaves .sigbus_fn NULL. If a kernel bug left SCTLR_EL1.EnAS0 enabled for threads without a PASID, st64bv0 would execute without raising SIGILL or SIGBUS and the test would silently pass. Either verify SIGBUS with BUS_OBJERR when HWCAP3_LS64_ACCDATA is set, or update the comment to state that only the absence of SIGILL is checked. [ ... ] > @@ -1300,6 +1342,14 @@ static const struct hwcap_data { > .sigill_fn =3D ls64_sigill, > .sigill_reliable =3D true, > }, > + { > + .name =3D "LS64_ACCDATA", > + .at_hwcap =3D AT_HWCAP3, > + .hwcap_bit =3D HWCAP3_LS64_ACCDATA, > + .cpuinfo =3D "ls64accdata", > + .sigill_fn =3D ls64_accdata_sigill, > + .sigill_reliable =3D true, > + }, > }; [Severity: Critical] In earlier commit "arm64: dynamically enable st64bv0 for SVA" from this series, can ls64_accdata_thread_switch() dereference a NULL next->mm when an exiting task is scheduled back in? Once a thread enables st64bv0 via do_el0_other() -> try_enable_st64bv0(), SCTLR_EL1_EnAS0 remains set in thread.sctlr_user across exit_mm(), which sets current->mm =3D NULL. If the exiting task sleeps or is preempted during teardown (for example in mmput() or exit_files()), __switch_to() calls ls64_accdata_thread_switch() with next->mm =3D=3D NULL: arch/arm64/kernel/process.c:ls64_accdata_thread_switch() { ... if (!(next->thread.sctlr_user & SCTLR_EL1_EnAS0)) return; pasid =3D mm_get_enqcmd_pasid(next->mm); ... } mm_get_enqcmd_pasid() unconditionally reads mm->iommu_mm, causing a deterministic kernel NULL pointer dereference panic when any local process that used st64bv0 exits. In the same commit, ls64_accdata_suspend_exit() in arch/arm64/kernel/suspend.c also calls mm_get_enqcmd_pasid(current->mm) without checking current->mm !=3D NULL, and writes the returned pasid to SYS_ACCDATA_EL1 without checking pasid !=3D IOMMU_PASID_INVALID (which can write IOMMU_PASID_INVALID if the SVA device was unbound before suspend). Clearing SCTLR_EL1_EnAS0 on exit, or checking for a NULL mm and IOMMU_PASID_INVALID before programming SYS_ACCDATA_EL1, avoids both issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203095703.6557= 96-1-arnd@kernel.org?part=3D4