Skip to content

[PW_SID:1059743] riscv: kfence: Handle the spurious fault after kfence_unprotect()#1526

Closed
linux-riscv-bot wants to merge 3 commits into
workflow__riscv__fixesfrom
pw1059743
Closed

[PW_SID:1059743] riscv: kfence: Handle the spurious fault after kfence_unprotect()#1526
linux-riscv-bot wants to merge 3 commits into
workflow__riscv__fixesfrom
pw1059743

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1059743 applied to workflow__riscv__fixes

Name: riscv: kfence: Handle the spurious fault after kfence_unprotect()
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1059743
Version: 1

In preparation of a future patch using this mechanism for non-vmalloc
mappings, rename new_vmalloc into new_valid_map_cpus to avoid misleading
readers.

No functional change intended.

Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
In preparation of a future patch using the same mechanism for
non-vmalloc addresses, extract the mark_new_valid_map() helper from
flush_cache_vmap().

No functional change intended.

Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
In kfence_protect_page(), which kfence_unprotect() calls, we cannot send
IPIs to other CPUs to ask them to flush TLB. This may lead to those CPUs
spuriously faulting on a recently allocated kfence object despite it
being valid, leading to false positive use-after-free reports.

Fix this by calling mark_new_valid_map() so that the page fault handling
code path notices the spurious fault and flushes TLB then retries the
access.

Update the comment in handle_exception to indicate that
new_valid_map_cpus_check also handles kfence_unprotect() spurious
faults.

Note that kfence_protect() has the same stale TLB entries problem, but
that leads to false negatives, which is fine with kfence.

Cc: <stable@vger.kernel.org>
Reported-by: Yanko Kaneti <yaneti@declera.com>
Fixes: b3431a8 ("riscv: Fix IPIs usage in kfence_protect_page()")
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 137.15 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1665.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2389.84 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.39 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.15 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.07 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
kdoc
Desc: Detects for kdoc errors
Duration: 0.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
module-param
Desc: Detect module_param changes
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/3] riscv: mm: Rename new_vmalloc into new_valid_map_cpus"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 136.55 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1664.35 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2386.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.78 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.73 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.58 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.35 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
kdoc
Desc: Detects for kdoc errors
Duration: 0.89 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/3] riscv: mm: Extract helper mark_new_valid_map()"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 136.13 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1137.48 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1652.81 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.84 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 28.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.01 seconds
Result: WARNING
Output:

WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report
#24: 
Reported-by: Yanko Kaneti <yaneti@declera.com>
Fixes: b3431a8bb336 ("riscv: Fix IPIs usage in kfence_protect_page()")

CHECK: Consider using #include <linux/cacheflush.h> instead of <asm/cacheflush.h>
#41: FILE: arch/riscv/include/asm/kfence.h:9:
+#include <asm/cacheflush.h>

total: 0 errors, 1 warnings, 1 checks, 33 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit b74ba04bc4f3 ("riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 1 checks, 33 lines checked
CHECK: Consider using #include <linux/cacheflush.h> instead of <asm/cacheflush.h>
WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.99 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
kdoc
Desc: Detects for kdoc errors
Duration: 0.85 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/3] riscv: kfence: Call mark_new_valid_map() for kfence_unprotect()"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw1059743 branch March 10, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants