Skip to content

[PW_SID:967715] riscv: misaligned: fix misaligned accesses handling in put/get_user()#456

Closed
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__for-nextfrom
pw967715
Closed

[PW_SID:967715] riscv: misaligned: fix misaligned accesses handling in put/get_user()#456
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__for-nextfrom
pw967715

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 967715 applied to workflow__riscv__for-next

Name: riscv: misaligned: fix misaligned accesses handling in put/get_user()
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=967715
Version: 1

The specification of prctl() for GET_UNALIGN_CTL states that the value is
returned in an unsigned int * address passed as an unsigned long. Change
the type to match that and avoid an unaligned access as well.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Doing misaligned access to userspace memory would make a trap on
platform where it is emulated. Latest fixes removed the kernel
capability to do unaligned accesses to userspace memory safely since
interrupts are kept disabled at all time during that. Thus doing so
would crash the kernel.

Such behavior was detected with GET_UNALIGN_CTL() that was doing
a put_user() with an unsigned long* address that should have been an
unsigned int*. Reenabling kernel misaligned access emulation is a bit
risky and it would also degrade performances. Rather than doing that,
we will try to avoid any misaligned accessed by using copy_from/to_user()
which does not do any misaligned accesses. This can be done only for
!CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS and thus allows to only generate
a bit more code for this config.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 636.13 seconds
Result: ERROR
Output:

Redirect to /build/tmp.MzDmYodPzU and /build/tmp.jCMFvnXwVX
Tree base:
cf099833ed4da ("Adding CI files")
Building the whole tree with the patch
error:
ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_getrandom' failed: symbol not defined
llvm-nm: error: arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg: No such file or directory
/build/tmp760r51ku/arch/riscv/kernel/compat_signal.c:220:28: error: use of undeclared identifier 'compat__vdso_rt_sigreturn_offset'
ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_getrandom' failed: symbol not defined
llvm-objcopy: error: 'arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg': No such file or directory



real	10m29.777s
user	405m2.492s
sys	75m28.360s

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1246.78 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.70 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.70 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 66.99 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
kdoc
Desc: Detects for kdoc errors
Duration: 0.86 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/2] riscv: process: use unsigned int instead of unsigned long for put_user()"
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 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 635.44 seconds
Result: ERROR
Output:

Redirect to /build/tmp.Ktez4SyVV9 and /build/tmp.L4cwdUKkeb
Tree base:
e947d8375258d ("riscv: process: use unsigned int instead of unsigned long for put_user()")
Building the whole tree with the patch
error:
ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_getrandom' failed: symbol not defined
llvm-nm: error: arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg: No such file or directory
ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_getrandom' failed: symbol not defined
llvm-objcopy: error: 'arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg': No such file or directory
/build/tmpulvdb9b2/arch/riscv/kernel/compat_signal.c:220:28: error: use of undeclared identifier 'compat__vdso_rt_sigreturn_offset'



real	10m29.100s
user	405m28.202s
sys	75m36.731s

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2436.11 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.12 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.43 seconds
Result: WARNING
Output:

CHECK: Alignment should match open parenthesis
#40: FILE: arch/riscv/include/asm/uaccess.h:173:
+unsigned long __must_check __asm_copy_to_user(void __user *to,
+	const void *from, unsigned long n);

CHECK: Alignment should match open parenthesis
#42: FILE: arch/riscv/include/asm/uaccess.h:175:
+unsigned long __must_check __asm_copy_from_user(void *to,
+	const void __user *from, unsigned long n);

total: 0 errors, 0 warnings, 2 checks, 48 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 fe46e11c1bf0 ("riscv: uaccess: do not do misaligned accesses in get/put_user()") 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, 0 warnings, 2 checks, 48 lines checked
CHECK: Alignment should match open parenthesis


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 67.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
kdoc
Desc: Detects for kdoc errors
Duration: 0.98 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
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/2] riscv: uaccess: do not do misaligned accesses in get/put_user()"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw967715 branch June 2, 2025 21:18
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