Skip to contentSkip to conversation

bail out in mathemu if __copy_to_user fails

PATCH In review Jesper Juhl 2 participants 3 messages Nov 1, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bail out in mathemu if __copy_to_user fails

I believe we should check the return value of
__copy_to_user in math-emu/fpu_entry.c and bail out of save_i387_soft() if it fails.
This patch does that.

This also kills the warning :
arch/i386/math-emu/fpu_entry.c:745: warning: ignoring return value of `__copy_to_user', declared with attribute warn_unused_result

---

arch/i386/math-emu/fpu_entry.c +2 -1
index d93f16e..ddf8fa3 100644
@@ -742,7 +742,8 @@ #ifdef PECULIAR_486
   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;
#1 lore raw
Quoted 7 lines · On Thu, 2 Nov 2006 00:03:16 +0100 Jesper Juhl wrote:

I believe we should check the return value of
__copy_to_user in math-emu/fpu_entry.c and bail out of save_i387_soft() if it fails.
This patch does that.

This also kills the warning :
arch/i386/math-emu/fpu_entry.c:745: warning: ignoring return value of `__copy_to_user', declared with attribute warn_unused_result

http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.19-rc4/2.6.19-rc4-mm1/broken-out/x86_64-mm-i386-mathemu-must-check.patch

Quoted 8 lines

---

arch/i386/math-emu/fpu_entry.c +0 -0
index d93f16e..ddf8fa3 100644

arch/i386/math-emu/fpu_entry.c #ifdef PECULIAR_486 · line 749

Quoted 9 lines
arch/i386/math-emu/fpu_entry.c +2 -1
@@ -742,7 +742,8 @@ #ifdef PECULIAR_486
   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;

---
~Randy

#2 lore raw
Quoted 7 lines · Randy Dunlap
Quoted 5 lines · On Thu, 2 Nov 2006 00:03:16 +0100 Jesper Juhl wrote:

I believe we should check the return value of
__copy_to_user in math-emu/fpu_entry.c and bail out of save_i387_soft() if it fails.
This patch does that.

Quoted 6 lines
Quoted 2 lines

This also kills the warning :
arch/i386/math-emu/fpu_entry.c:745: warning: ignoring return value of `__copy_to_user', declared with attribute warn_unused_result

http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.19-rc4/2.6.19-rc4-mm1/broken-out/x86_64-mm-i386-mathemu-must-check.patch

Ohh. I was not aware of that patch. Let's apply yours, it's so much more thorough than mine :-)

Thank you for pointing it out.

Quoted 23 lines
Quoted 9 lines

---

arch/i386/math-emu/fpu_entry.c +0 -0
index d93f16e..ddf8fa3 100644

arch/i386/math-emu/fpu_entry.c #ifdef PECULIAR_486 · line 749

Quoted 9 lines
arch/i386/math-emu/fpu_entry.c +2 -1
@@ -742,7 +742,8 @@ #ifdef PECULIAR_486
   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;

---
~Randy

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html