All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Burton <paul.burton@imgtec.com>
To: <linux-mips@linux-mips.org>, Ralf Baechle <ralf@linux-mips.org>,
	<trivial@kernel.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Subject: [PATCH 08/11] MIPS: math-emu: Correct user fault_addr type
Date: Wed, 23 Aug 2017 11:17:51 -0700	[thread overview]
Message-ID: <20170823181754.24044-9-paul.burton@imgtec.com> (raw)
In-Reply-To: <20170823181754.24044-1-paul.burton@imgtec.com>

The fault_addr argument to fpu_emulator_cop1Handler(), fpux_emu() and
cop1Emulate() has up until now been declared as:

  void *__user *fault_addr

This is essentially a pointer in user memory which points to a pointer
to void. This is not the intent for our code, which is actually
operating on a pointer to a pointer to void where the pointer to void is
pointing at user memory. ie. the pointer is in kernel memory & points to
user memory.

This mismatch produces a lot of sparse warnings that look like this:

arch/mips/math-emu/cp1emu.c:1485:45:
   warning: incorrect type in assignment (different address spaces)
      expected void *[noderef] <asn:1><noident>
      got unsigned int [noderef] [usertype] <asn:1>*[assigned] va

Fix these by modifying the declaration of the fault_addr argument to:

  void __user **fault_addr

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
---

 arch/mips/include/asm/fpu_emulator.h | 2 +-
 arch/mips/math-emu/cp1emu.c          | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/fpu_emulator.h b/arch/mips/include/asm/fpu_emulator.h
index c05369e0b8d6..8e50fa3623e3 100644
--- a/arch/mips/include/asm/fpu_emulator.h
+++ b/arch/mips/include/asm/fpu_emulator.h
@@ -62,7 +62,7 @@ do {									\
 
 extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
 				    struct mips_fpu_struct *ctx, int has_fpu,
-				    void *__user *fault_addr);
+				    void __user **fault_addr);
 void force_fcr31_sig(unsigned long fcr31, void __user *fault_addr,
 		     struct task_struct *tsk);
 int process_fpemu_return(int sig, void __user *fault_addr,
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index f08a7b4facb9..24d873a03327 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -58,7 +58,7 @@ static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
 	mips_instruction);
 
 static int fpux_emu(struct pt_regs *,
-	struct mips_fpu_struct *, mips_instruction, void *__user *);
+	struct mips_fpu_struct *, mips_instruction, void __user **);
 
 /* Control registers */
 
@@ -973,7 +973,7 @@ static inline void cop1_ctc(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
  */
 
 static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
-		struct mm_decoded_insn dec_insn, void *__user *fault_addr)
+		struct mm_decoded_insn dec_insn, void __user **fault_addr)
 {
 	unsigned long contpc = xcp->cp0_epc + dec_insn.pc_inc;
 	unsigned int cond, cbit, bit0;
@@ -1460,7 +1460,7 @@ DEF3OP(nmadd, dp, ieee754dp_mul, ieee754dp_add, ieee754dp_neg);
 DEF3OP(nmsub, dp, ieee754dp_mul, ieee754dp_sub, ieee754dp_neg);
 
 static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
-	mips_instruction ir, void *__user *fault_addr)
+	mips_instruction ir, void __user **fault_addr)
 {
 	unsigned rcsr = 0;	/* resulting csr */
 
@@ -2553,7 +2553,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
  * For simplicity we always terminate upon an ISA mode switch.
  */
 int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
-	int has_fpu, void *__user *fault_addr)
+	int has_fpu, void __user **fault_addr)
 {
 	unsigned long oldepc, prevepc;
 	struct mm_decoded_insn dec_insn;
-- 
2.14.1

WARNING: multiple messages have this Message-ID (diff)
From: Paul Burton <paul.burton@imgtec.com>
To: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>,
	trivial@kernel.org
Cc: Paul Burton <paul.burton@imgtec.com>
Subject: [PATCH 08/11] MIPS: math-emu: Correct user fault_addr type
Date: Wed, 23 Aug 2017 11:17:51 -0700	[thread overview]
Message-ID: <20170823181754.24044-9-paul.burton@imgtec.com> (raw)
Message-ID: <20170823181751.-cZ6-J1aC_8wUs8Bcd-KGZsn3oI4dciOGQ9abzqcjtA@z> (raw)
In-Reply-To: <20170823181754.24044-1-paul.burton@imgtec.com>

The fault_addr argument to fpu_emulator_cop1Handler(), fpux_emu() and
cop1Emulate() has up until now been declared as:

  void *__user *fault_addr

This is essentially a pointer in user memory which points to a pointer
to void. This is not the intent for our code, which is actually
operating on a pointer to a pointer to void where the pointer to void is
pointing at user memory. ie. the pointer is in kernel memory & points to
user memory.

This mismatch produces a lot of sparse warnings that look like this:

arch/mips/math-emu/cp1emu.c:1485:45:
   warning: incorrect type in assignment (different address spaces)
      expected void *[noderef] <asn:1><noident>
      got unsigned int [noderef] [usertype] <asn:1>*[assigned] va

Fix these by modifying the declaration of the fault_addr argument to:

  void __user **fault_addr

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
---

 arch/mips/include/asm/fpu_emulator.h | 2 +-
 arch/mips/math-emu/cp1emu.c          | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/fpu_emulator.h b/arch/mips/include/asm/fpu_emulator.h
index c05369e0b8d6..8e50fa3623e3 100644
--- a/arch/mips/include/asm/fpu_emulator.h
+++ b/arch/mips/include/asm/fpu_emulator.h
@@ -62,7 +62,7 @@ do {									\
 
 extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
 				    struct mips_fpu_struct *ctx, int has_fpu,
-				    void *__user *fault_addr);
+				    void __user **fault_addr);
 void force_fcr31_sig(unsigned long fcr31, void __user *fault_addr,
 		     struct task_struct *tsk);
 int process_fpemu_return(int sig, void __user *fault_addr,
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index f08a7b4facb9..24d873a03327 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -58,7 +58,7 @@ static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
 	mips_instruction);
 
 static int fpux_emu(struct pt_regs *,
-	struct mips_fpu_struct *, mips_instruction, void *__user *);
+	struct mips_fpu_struct *, mips_instruction, void __user **);
 
 /* Control registers */
 
@@ -973,7 +973,7 @@ static inline void cop1_ctc(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
  */
 
 static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
-		struct mm_decoded_insn dec_insn, void *__user *fault_addr)
+		struct mm_decoded_insn dec_insn, void __user **fault_addr)
 {
 	unsigned long contpc = xcp->cp0_epc + dec_insn.pc_inc;
 	unsigned int cond, cbit, bit0;
@@ -1460,7 +1460,7 @@ DEF3OP(nmadd, dp, ieee754dp_mul, ieee754dp_add, ieee754dp_neg);
 DEF3OP(nmsub, dp, ieee754dp_mul, ieee754dp_sub, ieee754dp_neg);
 
 static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
-	mips_instruction ir, void *__user *fault_addr)
+	mips_instruction ir, void __user **fault_addr)
 {
 	unsigned rcsr = 0;	/* resulting csr */
 
@@ -2553,7 +2553,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
  * For simplicity we always terminate upon an ISA mode switch.
  */
 int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
-	int has_fpu, void *__user *fault_addr)
+	int has_fpu, void __user **fault_addr)
 {
 	unsigned long oldepc, prevepc;
 	struct mm_decoded_insn dec_insn;
-- 
2.14.1

  parent reply	other threads:[~2017-08-23 18:21 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 18:17 [PATCH 00/11] MIPS: Fix various sparse warnings Paul Burton
2017-08-23 18:17 ` Paul Burton
2017-08-23 18:17 ` [PATCH 01/11] MIPS: generic: Include asm/bootinfo.h for plat_fdt_relocated() Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` [PATCH 02/11] MIPS: generic: Include asm/time.h for get_c0_*_int() Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` [PATCH 03/11] MIPS: Include asm/setup.h for cpu_cache_init() Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` [PATCH 04/11] MIPS: Include linux/cpu.h for arch_cpu_idle() Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` [PATCH 05/11] MIPS: Include asm/delay.h for __{,n,u}delay() Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` [PATCH 06/11] MIPS: Include elf-randomize.h for arch_mmap_rnd() & arch_randomize_brk() Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` [PATCH 07/11] MIPS: Include linux/initrd.h for free_initrd_mem() Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` Paul Burton [this message]
2017-08-23 18:17   ` [PATCH 08/11] MIPS: math-emu: Correct user fault_addr type Paul Burton
2017-08-23 18:17 ` [PATCH 09/11] MIPS: Remove __invalidate_kernel_vmap_range Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` [PATCH 10/11] MIPS: Remove plat_timer_setup() Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-23 18:17 ` [PATCH 11/11] MIPS: Declare various variables & functions static Paul Burton
2017-08-23 18:17   ` Paul Burton
2017-08-29 10:07   ` Marcin Nowakowski
2017-08-29 10:07     ` Marcin Nowakowski
     [not found]   ` <787b1a5b-2e77-41cc-235f-6dfd882b225a@imgtec.com>
2017-08-29 16:44     ` Paul Burton
2017-08-29 16:44       ` Paul Burton
2017-08-29 16:46       ` Ralf Baechle
2017-08-25 21:20 ` [PATCH 00/11] MIPS: Fix various sparse warnings Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170823181754.24044-9-paul.burton@imgtec.com \
    --to=paul.burton@imgtec.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=trivial@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.