[RFC PATCH V3 33/43] rv64ilp32_abi: mm/auxvec: Adapt mm->saved_auxv[] to Elf64

guoren
2025-03-25T12:24:39Z

Unable to handle kernel paging request at virtual address 60723de0
Oops [#1]
Modules linked in:
CPU: 0 UID: 0 PID: 1 Comm: init Not tainted 6.13.0-rc4-00031-g01dc3ca797b3-dirty #161
Hardware name: riscv-virtio,qemu (DT)
epc : percpu_counter_add_batch+0x38/0xc4
ra : filemap_map_pages+0x3ec/0x54c
epc : ffffffffbc4ea02e ra : ffffffffbc1722e4 sp : ffffffffc1c4fc60
gp : ffffffffbd6d3918 tp : ffffffffc1c50000 t0 : 0000000000000000
t1 : 000000003fffefff t2 : 0000000000000000 s0 : ffffffffc1c4fca0
s1 : 0000000000000022 a0 : ffffffffc25c8250 a1 : 0000000000000003
a2 : 0000000000000020 a3 : 000000003fffefff a4 : 000000000b1c2000
a5 : 0000000060723de0 a6 : ffffffffbffff000 a7 : 000000003fffffff
s2 : ffffffffc25c8250 s3 : ffffffffc246e240 s4 : ffffffffc2138240
s5 : ffffffffbd70c4d0 s6 : 0000000000000003 s7 : 0000000000000000
s8 : ffffffff9a02d780 s9 : 0000000000000100 s10: ffffffffc1c4fda8
s11: 0000000000000003 t3 : 0000000000000000 t4 : 00000000000004f7
t5 : 0000000000000000 t6 : 0000000000000001
status: 0000000200000100 badaddr: 0000000060723de0 cause: 000000000000000d
[<bc4ea02e>] percpu_counter_add_batch+0x38/0xc4
[<bc1722e4>] filemap_map_pages+0x3ec/0x54c
[<bc1adc86>] handle_mm_fault+0xb6c/0xe9c
[<bc01bb3e>] handle_page_fault+0xd0/0x418
[<bca3e264>] do_page_fault+0x20/0x3a
[<bca4882c>] _new_vmalloc_restore_context_a0+0xb0/0xbc
Code: 8a93 4baa 511c 171b 0027 873b 00ea 4318 2481 9fb9 (aa03) 0007

Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
---
include/linux/mm_types.h | 4 ++++
kernel/sys.c | 8 ++++++++
2 files changed, 12 insertions(+)

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index da3ba1a79ad5..0d436b0217fd 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -962,7 +962,11 @@ struct mm_struct {
unsigned long start_brk, brk, start_stack;
unsigned long arg_start, arg_end, env_start, env_end;

+#ifdef CONFIG_64BIT
+ unsigned long long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
+#else
unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
+#endif

struct percpu_counter rss_stat[NR_MM_COUNTERS];

diff --git a/kernel/sys.c b/kernel/sys.c
index cb366ff8703a..81c0d94ff50d 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2008,7 +2008,11 @@ static int validate_prctl_map_addr(struct prctl_mm_map *prctl_map)
static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data_size)
{
struct prctl_mm_map prctl_map = { .exe_fd = (u32)-1, };
+#ifdef CONFIG_64BIT
+ unsigned long long user_auxv[AT_VECTOR_SIZE];
+#else
unsigned long user_auxv[AT_VECTOR_SIZE];
+#endif
struct mm_struct *mm = current->mm;
int error;

@@ -2122,7 +2126,11 @@ static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr,
* up to the caller to provide sane values here, otherwise userspace
* tools which use this vector might be unhappy.
*/
+#ifdef CONFIG_64BIT
+ unsigned long long user_auxv[AT_VECTOR_SIZE] = {};
+#else
unsigned long user_auxv[AT_VECTOR_SIZE] = {};
+#endif

if (len > sizeof(user_auxv))
return -EINVAL;
--
2.40.1