lkml.org 
[lkml]   [2006]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [patch] i386: handle_BUG(): don't print garbage if debug info unavailable
Linus Torvalds <torvalds@osdl.org> wrote:
>
> That said, I think it's wrong to use "__get_user()", which can hang on the
> MM semaphore if something is bogus. We should probably mark us as being
> "in_atomic()" to make sure that the page fault handler, if it is entered,
> will not try to get the semaphore or page anything in.

This?


--- a/include/linux/uaccess.h~add-probe_kernel_address
+++ a/include/linux/uaccess.h
@@ -19,4 +19,26 @@ static inline unsigned long __copy_from_

#endif /* ARCH_HAS_NOCACHE_UACCESS */

+/**
+ * probe_kernel_address(): safely attempt to read from a location
+ * @addr: address to read from - its type is type typeof(retval)*
+ * @retval: read into this variable
+ *
+ * Safely read from address @addr into variable @revtal. If a kernel fault
+ * happens, handle that and return -EFAULT.
+ * We ensure that the __get_user() is executed in atomic context so that
+ * do_page_fault() doesn't attempt to take mmap_sem. This makes
+ * probe_kernel_address() suitable for use within regions where the caller
+ * already holds mmap_sem, or other locks which nest inside mmap_sem.
+ */
+#define probe_kernel_address(addr, retval) \
+ ({ \
+ long ret; \
+ \
+ inc_preempt_count(); \
+ ret = __get_user(retval, addr); \
+ dec_preempt_count(); \
+ ret; \
+ })
+
#endif /* __LINUX_UACCESS_H__ */
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-07-12 01:41    [W:0.037 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site