From: Andrew Morton <akpm@osdl.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: nickpiggin@yahoo.com.au, 76306.1226@compuserve.com,
linux-kernel@vger.kernel.org, efault@gmx.de
Subject: Re: [patch] i386: handle_BUG(): don't print garbage if debug info unavailable
Date: Tue, 11 Jul 2006 16:42:08 -0700 [thread overview]
Message-ID: <20060711164208.323dada1.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0607110959160.5623@g5.osdl.org>
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__ */
_
next prev parent reply other threads:[~2006-07-11 23:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-10 14:30 Chuck Ebbert
2006-07-11 8:27 ` Andrew Morton
2006-07-11 10:52 ` Nick Piggin
2006-07-11 17:02 ` Linus Torvalds
2006-07-11 17:58 ` Ray Lee
2006-07-11 23:42 ` Andrew Morton [this message]
2006-07-11 23:55 ` Linus Torvalds
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=20060711164208.323dada1.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=76306.1226@compuserve.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome