diff options
| author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
|---|---|---|
| committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
| commit | 185a257f2f73bcd89050ad02da5bedbc28fc43fa (patch) | |
| tree | 5e32586114534ed3f2165614cba3d578f5d87307 /include/linux/uaccess.h | |
| parent | 3f1a9aaeffd8d1cbc5ab9776c45cbd66af1c9699 (diff) | |
| parent | a77c64c1a641950626181b4857abb701d8f38ccc (diff) | |
Merge branch 'master' into gfs2
Diffstat (limited to 'include/linux/uaccess.h')
| -rw-r--r-- | include/linux/uaccess.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 391e7ed1eb3f..a48d7f11c7be 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h | |||
| @@ -19,4 +19,26 @@ static inline unsigned long __copy_from_user_nocache(void *to, | |||
| 19 | 19 | ||
| 20 | #endif /* ARCH_HAS_NOCACHE_UACCESS */ | 20 | #endif /* ARCH_HAS_NOCACHE_UACCESS */ |
| 21 | 21 | ||
| 22 | /** | ||
| 23 | * probe_kernel_address(): safely attempt to read from a location | ||
| 24 | * @addr: address to read from - its type is type typeof(retval)* | ||
| 25 | * @retval: read into this variable | ||
| 26 | * | ||
| 27 | * Safely read from address @addr into variable @revtal. If a kernel fault | ||
| 28 | * happens, handle that and return -EFAULT. | ||
| 29 | * We ensure that the __get_user() is executed in atomic context so that | ||
| 30 | * do_page_fault() doesn't attempt to take mmap_sem. This makes | ||
| 31 | * probe_kernel_address() suitable for use within regions where the caller | ||
| 32 | * already holds mmap_sem, or other locks which nest inside mmap_sem. | ||
| 33 | */ | ||
| 34 | #define probe_kernel_address(addr, retval) \ | ||
| 35 | ({ \ | ||
| 36 | long ret; \ | ||
| 37 | \ | ||
| 38 | inc_preempt_count(); \ | ||
| 39 | ret = __get_user(retval, addr); \ | ||
| 40 | dec_preempt_count(); \ | ||
| 41 | ret; \ | ||
| 42 | }) | ||
| 43 | |||
| 22 | #endif /* __LINUX_UACCESS_H__ */ | 44 | #endif /* __LINUX_UACCESS_H__ */ |
