public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* IS_ERR Threshold Value
@ 2006-06-28 20:57 Erik Frederiksen
  2006-06-28 21:08 ` Randy.Dunlap
  2006-06-28 22:41 ` Nathan Scott
  0 siblings, 2 replies; 21+ messages in thread
From: Erik Frederiksen @ 2006-06-28 20:57 UTC (permalink / raw)
  To: linux-kernel


from include/asm-mips/errno.h
#define EDQUOT      1133    /* Quota exceeded */

I noticed that the errno value for EDQUOT on MIPS is considerably larger
than all others.  This can lead to a situation where functions using
ERR_PTR() to return error codes in pointers cannot return this error
code without IS_ERR() thinking that the pointer is valid.  In my case,
it caused an alignment exception in the XFS open call when quota has
been exceeded in the linux-mips 2.6.14 kernel.  I think that the XFS
code has changed enough that this bug isn't in newer versions, though I
haven't done a thorough investigation.  

I've supplied a patch that addresses this situation by changing the
threshold used by IS_ERR if EMAXERRNO is defined and greater than 1000. 
Perhaps permanently raising the threshold value to something >1133 is
sufficient.

Looking forward to your feedback.  

Erik Frederiksen
Firmware Design Engineer Co-op
PMC-Sierra Saskatoon




diff -Nau [ab]/include/linux/err.h
--- a/include/linux/err.h       2005-10-30 13:14:22.000000000 -0600
+++ b/include/linux/err.h       2006-06-28 10:38:43.000000000 -0600
@@ -12,8 +12,23 @@
  *
  * This should be a per-architecture thing, to allow different
  * error and pointer decisions.
+ *
+ * Updated by Erik Frederiksen (erik_frederiksen@pmc-sierra.com)
+ * errno values on MIPS go up to 1133 for EDQUOT.  The threshold
+ * is adjusted so that returning large errnos in a pointer
+ * does not result in a valid pointer according to IS_ERR.
  */
-#define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L)
+
+#define ERR_PTR_THRESHOLD 1000
+#define IS_ERR_VALUE(x) \
+       unlikely((x) > (unsigned long)-(long)ERR_PTR_THRESHOLD )
+#ifdef EMAXERRNO
+# if EMAXERRNO >= ERR_PTR_THRESHOLD
+#  undef IS_ERR_VALUE
+#  define IS_ERR_VALUE(x) \
+       unlikely((x) >= (unsigned long)-(long)EMAXERRNO )
+# endif
+#endif
  
 static inline void *ERR_PTR(long error)
 {



^ permalink raw reply	[flat|nested] 21+ messages in thread
[parent not found: <6sPiW-295-5@gated-at.bofh.it>]

end of thread, other threads:[~2006-10-18 23:35 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-28 20:57 IS_ERR Threshold Value Erik Frederiksen
2006-06-28 21:08 ` Randy.Dunlap
2006-06-28 22:39   ` H. Peter Anvin
2006-06-29 18:10   ` Ralf Baechle
2006-07-01 18:44     ` Randy.Dunlap
2006-07-01 22:23       ` H. Peter Anvin
2006-07-02 16:15         ` Ralf Baechle
2006-07-02 17:40           ` H. Peter Anvin
2006-07-02 18:22           ` Randy.Dunlap
2006-07-02 18:27         ` [PATCH] consistently use MAX_ERRNO in __syscall_return Randy.Dunlap
2006-07-03  7:39           ` Andrew Morton
2006-07-03 15:03             ` H. Peter Anvin
2006-07-03 15:42               ` Randy.Dunlap
2006-07-03 16:09                 ` H. Peter Anvin
2006-10-16 19:31     ` IS_ERR Threshold Value Andreas Mohr
2006-10-18 12:47       ` Jan Engelhardt
2006-06-28 22:41 ` Nathan Scott
2006-06-28 23:13   ` Erik Frederiksen
2006-06-28 23:22     ` Randy.Dunlap
2006-06-28 23:23     ` Nathan Scott
     [not found] <6sPiW-295-5@gated-at.bofh.it>
     [not found] ` <6sPsw-2y4-19@gated-at.bofh.it>
     [not found]   ` <6t9hu-6l6-11@gated-at.bofh.it>
     [not found]     ` <76GtI-T6-21@gated-at.bofh.it>
     [not found]       ` <77jbT-1y3-29@gated-at.bofh.it>
2006-10-18 23:29         ` Bodo Eggert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox