mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: domen@coderock.org
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, domen@coderock.org, yrgrknmxpzlk@gawab.com
Subject: [patch 10/12] arch/i386/math-emu/* - compile warning cleanup
Date: Sat, 05 Mar 2005 16:35:38 +0100	[thread overview]
Message-ID: <20050305153539.2800D1F204@trashy.coderock.org> (raw)


compile warning cleanup - handle copy_to/from_user error 
returns

Signed-off-by: Stephen Biggs <yrgrknmxpzlk@gawab.com>
Signed-off-by: Domen Puncer <domen@coderock.org>
---


 kj-domen/arch/i386/math-emu/fpu_entry.c  |    3 +
 kj-domen/arch/i386/math-emu/reg_ld_str.c |   52 +++++++++++++++++++++++++------
 2 files changed, 44 insertions(+), 11 deletions(-)

diff -puN arch/i386/math-emu/fpu_entry.c~return_code-arch_i386_math-emu arch/i386/math-emu/fpu_entry.c
--- kj/arch/i386/math-emu/fpu_entry.c~return_code-arch_i386_math-emu	2005-03-05 16:13:04.000000000 +0100
+++ kj-domen/arch/i386/math-emu/fpu_entry.c	2005-03-05 16:13:04.000000000 +0100
@@ -742,7 +742,8 @@ int save_i387_soft(void *s387, struct _f
   S387->fcs &= ~0xf8000000;
   S387->fos |= 0xffff0000;
 #endif /* PECULIAR_486 */
-  __copy_to_user(d, &S387->cwd, 7*4);
+  if (__copy_to_user(d, &S387->cwd, 7*4))
+    return -1;
   RE_ENTRANT_CHECK_ON;
 
   d += 7*4;
diff -puN arch/i386/math-emu/reg_ld_str.c~return_code-arch_i386_math-emu arch/i386/math-emu/reg_ld_str.c
--- kj/arch/i386/math-emu/reg_ld_str.c~return_code-arch_i386_math-emu	2005-03-05 16:13:04.000000000 +0100
+++ kj-domen/arch/i386/math-emu/reg_ld_str.c	2005-03-05 16:13:04.000000000 +0100
@@ -89,12 +89,17 @@ int FPU_tagof(FPU_REG *ptr)
 int FPU_load_extended(long double __user *s, int stnr)
 {
   FPU_REG *sti_ptr = &st(stnr);
+  int user_copy_err;
 
   RE_ENTRANT_CHECK_OFF;
   FPU_verify_area(VERIFY_READ, s, 10);
-  __copy_from_user(sti_ptr, s, 10);
+  user_copy_err = __copy_from_user(sti_ptr, s, 10);
   RE_ENTRANT_CHECK_ON;
 
+  if (user_copy_err) {
+	EXCEPTION(EX_INTERNAL);
+	return TAG_Special;
+  }
   return FPU_tagof(sti_ptr);
 }
 
@@ -240,13 +245,19 @@ int FPU_load_int64(long long __user *_s)
 {
   long long s;
   int sign;
+  int user_copy_err;
   FPU_REG *st0_ptr = &st(0);
 
   RE_ENTRANT_CHECK_OFF;
   FPU_verify_area(VERIFY_READ, _s, 8);
-  copy_from_user(&s,_s,8);
+  user_copy_err = copy_from_user(&s,_s,8);
   RE_ENTRANT_CHECK_ON;
 
+  if (user_copy_err) {
+	EXCEPTION(EX_INTERNAL);
+	return TAG_Special;
+  }
+
   if (s == 0)
     {
       reg_copy(&CONST_Z, st0_ptr);
@@ -859,6 +870,7 @@ int FPU_store_int64(FPU_REG *st0_ptr, u_
   FPU_REG t;
   long long tll;
   int precision_loss;
+  int user_copy_err;
 
   if ( st0_tag == TAG_Empty )
     {
@@ -907,9 +919,14 @@ int FPU_store_int64(FPU_REG *st0_ptr, u_
 
   RE_ENTRANT_CHECK_OFF;
   FPU_verify_area(VERIFY_WRITE,d,8);
-  copy_to_user(d, &tll, 8);
+  user_copy_err = copy_to_user(d, &tll, 8);
   RE_ENTRANT_CHECK_ON;
 
+  if (user_copy_err) {
+	EXCEPTION(EX_INTERNAL);
+	return 0;
+  }
+
   return 1;
 }
 
@@ -1271,15 +1288,21 @@ void frstor(fpu_addr_modes addr_modes, u
   int i, regnr;
   u_char __user *s = fldenv(addr_modes, data_address);
   int offset = (top & 7) * 10, other = 80 - offset;
+  int user_copy_err;
 
   /* Copy all registers in stack order. */
   RE_ENTRANT_CHECK_OFF;
   FPU_verify_area(VERIFY_READ,s,80);
-  __copy_from_user(register_base+offset, s, other);
-  if ( offset )
-    __copy_from_user(register_base, s+other, offset);
+  user_copy_err = __copy_from_user(register_base+offset, s, other);
+  if (!user_copy_err && offset)
+    user_copy_err = __copy_from_user(register_base, s+other, offset);
   RE_ENTRANT_CHECK_ON;
 
+  if (user_copy_err) {
+	EXCEPTION(EX_INTERNAL);
+	return;
+  }
+
   for ( i = 0; i < 8; i++ )
     {
       regnr = (i+top) & 7;
@@ -1325,6 +1348,7 @@ u_char __user *fstenv(fpu_addr_modes add
     }
   else
     {
+      int user_copy_err;
       RE_ENTRANT_CHECK_OFF;
       FPU_verify_area(VERIFY_WRITE, d, 7*4);
 #ifdef PECULIAR_486
@@ -1336,8 +1360,12 @@ u_char __user *fstenv(fpu_addr_modes add
       I387.soft.fcs &= ~0xf8000000;
       I387.soft.fos |= 0xffff0000;
 #endif /* PECULIAR_486 */
-      __copy_to_user(d, &control_word, 7*4);
+      user_copy_err = __copy_to_user(d, &control_word, 7*4);
       RE_ENTRANT_CHECK_ON;
+
+      if (user_copy_err)
+	EXCEPTION(EX_INTERNAL);
+
       d += 0x1c;
     }
   
@@ -1352,6 +1380,7 @@ void fsave(fpu_addr_modes addr_modes, u_
 {
   u_char __user *d;
   int offset = (top & 7) * 10, other = 80 - offset;
+  int user_copy_err;
 
   d = fstenv(addr_modes, data_address);
 
@@ -1359,11 +1388,14 @@ void fsave(fpu_addr_modes addr_modes, u_
   FPU_verify_area(VERIFY_WRITE,d,80);
 
   /* Copy all registers in stack order. */
-  __copy_to_user(d, register_base+offset, other);
-  if ( offset )
-    __copy_to_user(d+other, register_base, offset);
+  user_copy_err = __copy_to_user(d, register_base+offset, other);
+  if (!user_copy_err && offset)
+    user_copy_err = __copy_to_user(d+other, register_base, offset);
   RE_ENTRANT_CHECK_ON;
 
+  if (user_copy_err)
+	EXCEPTION(EX_INTERNAL);
+
   finit();
 }
 
_

             reply	other threads:[~2005-03-05 15:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-05 15:35 domen [this message]
2005-03-07  0:48 ` Andrew Morton

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=20050305153539.2800D1F204@trashy.coderock.org \
    --to=domen@coderock.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yrgrknmxpzlk@gawab.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®