* [PATCH] riscv: mmap(): use unsigned offset type in riscv_sys_mmap
@ 2025-07-07 11:34 liu.xuemei1
2025-07-08 3:38 ` Nutty Liu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: liu.xuemei1 @ 2025-07-07 11:34 UTC (permalink / raw)
To: paul.walmsley; +Cc: palmer, aou, alex, liu.xuemei1, linux-riscv, linux-kernel
From: Jessica Liu <liu.xuemei1@zte.com.cn>
The variable type of offset should be consistent with the relevant
interfaces of mmap which described in commit 295f10061af0 ("syscalls:
mmap(): use unsigned offset type consistently). Otherwise, a user input
with the top bit set would result in a negative page offset rather than a
large one.
Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
---
arch/riscv/kernel/sys_riscv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
index d77afe05578f..795b2e815ac9 100644
--- a/arch/riscv/kernel/sys_riscv.c
+++ b/arch/riscv/kernel/sys_riscv.c
@@ -10,7 +10,7 @@
static long riscv_sys_mmap(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags,
- unsigned long fd, off_t offset,
+ unsigned long fd, unsigned long offset,
unsigned long page_shift_offset)
{
if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: mmap(): use unsigned offset type in riscv_sys_mmap
2025-07-07 11:34 [PATCH] riscv: mmap(): use unsigned offset type in riscv_sys_mmap liu.xuemei1
@ 2025-07-08 3:38 ` Nutty Liu
2025-07-08 9:07 ` Alexandre Ghiti
2025-07-09 5:28 ` Han Gao (Revy)
2 siblings, 0 replies; 4+ messages in thread
From: Nutty Liu @ 2025-07-08 3:38 UTC (permalink / raw)
To: liu.xuemei1, paul.walmsley; +Cc: palmer, aou, alex, linux-riscv, linux-kernel
On 7/7/2025 7:34 PM, liu.xuemei1@zte.com.cn wrote:
> From: Jessica Liu <liu.xuemei1@zte.com.cn>
>
> The variable type of offset should be consistent with the relevant
> interfaces of mmap which described in commit 295f10061af0 ("syscalls:
> mmap(): use unsigned offset type consistently). Otherwise, a user input
> with the top bit set would result in a negative page offset rather than a
> large one.
>
> Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Thanks,
Nutty
> ---
> arch/riscv/kernel/sys_riscv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
> index d77afe05578f..795b2e815ac9 100644
> --- a/arch/riscv/kernel/sys_riscv.c
> +++ b/arch/riscv/kernel/sys_riscv.c
> @@ -10,7 +10,7 @@
>
> static long riscv_sys_mmap(unsigned long addr, unsigned long len,
> unsigned long prot, unsigned long flags,
> - unsigned long fd, off_t offset,
> + unsigned long fd, unsigned long offset,
> unsigned long page_shift_offset)
> {
> if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: mmap(): use unsigned offset type in riscv_sys_mmap
2025-07-07 11:34 [PATCH] riscv: mmap(): use unsigned offset type in riscv_sys_mmap liu.xuemei1
2025-07-08 3:38 ` Nutty Liu
@ 2025-07-08 9:07 ` Alexandre Ghiti
2025-07-09 5:28 ` Han Gao (Revy)
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Ghiti @ 2025-07-08 9:07 UTC (permalink / raw)
To: liu.xuemei1, paul.walmsley; +Cc: palmer, aou, linux-riscv, linux-kernel
Hi Jessica,
On 7/7/25 13:34, liu.xuemei1@zte.com.cn wrote:
> From: Jessica Liu <liu.xuemei1@zte.com.cn>
>
> The variable type of offset should be consistent with the relevant
> interfaces of mmap which described in commit 295f10061af0 ("syscalls:
> mmap(): use unsigned offset type consistently). Otherwise, a user input
> with the top bit set would result in a negative page offset rather than a
> large one.
>
> Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
> ---
> arch/riscv/kernel/sys_riscv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
> index d77afe05578f..795b2e815ac9 100644
> --- a/arch/riscv/kernel/sys_riscv.c
> +++ b/arch/riscv/kernel/sys_riscv.c
> @@ -10,7 +10,7 @@
>
> static long riscv_sys_mmap(unsigned long addr, unsigned long len,
> unsigned long prot, unsigned long flags,
> - unsigned long fd, off_t offset,
> + unsigned long fd, unsigned long offset,
> unsigned long page_shift_offset)
> {
> if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Thanks,
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: mmap(): use unsigned offset type in riscv_sys_mmap
2025-07-07 11:34 [PATCH] riscv: mmap(): use unsigned offset type in riscv_sys_mmap liu.xuemei1
2025-07-08 3:38 ` Nutty Liu
2025-07-08 9:07 ` Alexandre Ghiti
@ 2025-07-09 5:28 ` Han Gao (Revy)
2 siblings, 0 replies; 4+ messages in thread
From: Han Gao (Revy) @ 2025-07-09 5:28 UTC (permalink / raw)
To: liu.xuemei1; +Cc: paul.walmsley, palmer, aou, alex, linux-riscv, linux-kernel
> On Jul 7, 2025, at 19:34, liu.xuemei1@zte.com.cn wrote:
>
> From: Jessica Liu <liu.xuemei1@zte.com.cn>
>
> The variable type of offset should be consistent with the relevant
> interfaces of mmap which described in commit 295f10061af0 ("syscalls:
> mmap(): use unsigned offset type consistently). Otherwise, a user input
> with the top bit set would result in a negative page offset rather than a
> large one.
>
> Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
Tested-by: Han Gao <rabenda.cn@gmail.com>
> ---
> arch/riscv/kernel/sys_riscv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
> index d77afe05578f..795b2e815ac9 100644
> --- a/arch/riscv/kernel/sys_riscv.c
> +++ b/arch/riscv/kernel/sys_riscv.c
> @@ -10,7 +10,7 @@
>
> static long riscv_sys_mmap(unsigned long addr, unsigned long len,
> unsigned long prot, unsigned long flags,
> - unsigned long fd, off_t offset,
> + unsigned long fd, unsigned long offset,
> unsigned long page_shift_offset)
> {
> if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
> --
> 2.25.1
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-09 5:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07 11:34 [PATCH] riscv: mmap(): use unsigned offset type in riscv_sys_mmap liu.xuemei1
2025-07-08 3:38 ` Nutty Liu
2025-07-08 9:07 ` Alexandre Ghiti
2025-07-09 5:28 ` Han Gao (Revy)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).