[PATCH 1/2] um: fix sparse warnings from regset refactor
Benjamin Berg
benjamin at sipsolutions.net
Thu Oct 31 07:20:16 PDT 2024
From: Benjamin Berg <benjamin.berg at intel.com>
Some variables were not tagged with __user and another was not marked as
static even though it should be.
Reported-by: kernel test robot <lkp at intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202410280655.gOlEFwdG-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202410281821.WSPsAwq7-lkp@intel.com/
Fixes: 3f17fed21491 ("um: switch to regset API and depend on XSTATE")
Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
---
arch/x86/um/ptrace.c | 2 +-
arch/x86/um/signal.c | 13 ++++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/x86/um/ptrace.c b/arch/x86/um/ptrace.c
index 54d924bc45ce..57c504fd5626 100644
--- a/arch/x86/um/ptrace.c
+++ b/arch/x86/um/ptrace.c
@@ -242,7 +242,7 @@ static struct user_regset uml_regsets[] __ro_after_init = {
/* TODO: Add TLS regset for 32bit */
};
-const struct user_regset_view user_uml_view = {
+static const struct user_regset_view user_uml_view = {
#ifdef CONFIG_X86_32
.name = "i386", .e_machine = EM_386,
#else
diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c
index 94b2b2bbae31..797c4e4e57f3 100644
--- a/arch/x86/um/signal.c
+++ b/arch/x86/um/signal.c
@@ -82,9 +82,10 @@ static int copy_sc_from_user(struct pt_regs *regs,
#undef GETREG
#ifdef CONFIG_X86_32
- from_fp64 = ((void *)sc.fpstate) + offsetof(struct _fpstate_32, _fxsr_env);
+ from_fp64 = ((void __user *)sc.fpstate) +
+ offsetof(struct _fpstate_32, _fxsr_env);
#else
- from_fp64 = (void *)sc.fpstate;
+ from_fp64 = (void __user *)sc.fpstate;
#endif
err = copy_from_user(regs->regs.fp, from_fp64, host_fp_size);
@@ -97,7 +98,7 @@ static int copy_sc_from_user(struct pt_regs *regs,
task_user_regset_view(current),
REGSET_FP_LEGACY, 0,
sizeof(struct user_i387_struct),
- (void *)sc.fpstate);
+ (void __user *)sc.fpstate);
if (err < 0)
return err;
#endif
@@ -173,7 +174,8 @@ static int copy_sc_to_user(struct sigcontext __user *to,
BUILD_BUG_ON(offsetof(struct _xstate, xstate_hdr) !=
offsetof(struct _xstate_64, xstate_hdr) +
offsetof(struct _fpstate_32, _fxsr_env));
- to_fp64 = (void *)to_fp + offsetof(struct _fpstate_32, _fxsr_env);
+ to_fp64 = (void __user *)to_fp +
+ offsetof(struct _fpstate_32, _fxsr_env);
#else
to_fp64 = to_fp;
#endif /* CONFIG_X86_32 */
@@ -198,7 +200,8 @@ static int copy_sc_to_user(struct sigcontext __user *to,
__put_user(host_fp_size, &to_fp64->fpstate.sw_reserved.xstate_size);
__put_user(FP_XSTATE_MAGIC1, &to_fp64->fpstate.sw_reserved.magic1);
- __put_user(FP_XSTATE_MAGIC2, (int *)((void *)to_fp64 + host_fp_size));
+ __put_user(FP_XSTATE_MAGIC2,
+ (int __user *)((void __user *)to_fp64 + host_fp_size));
return 0;
}
--
2.47.0
More information about the linux-um
mailing list