A couple hardened usercopy changes:
- drop now unneeded is_vmalloc_or_module() check; Laura Abbott - use enum instead of literals for stack frame API; Sahara -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Kees Cook <kees@outflux.net> iQIcBAABCgAGBQJZB39WAAoJEIly9N/cbcAmVJ8QALC0teqysiyml1CuxruXoXNj wPfwOJMypdXTYtL70ZKqi6Mboqrg01HTBeSNZjoNDvpHtsePlPVLjgDZ9ehcgokb nTQ23zJguV0nOLn32yKSJ1KupuxGMzW9RtrjOWH6w8nixff42vCHANY8+j5/Nx4R L4uLEPhA2ay35ddMeJMaNE8MAw7YS/C4enWu15CDbAjv++bVPoKwvqUchBoIPRx5 ZNjEUlAdnsv8IfccUea0Xz8CrBshe0kN4SGQvPqvaff2Orsk2FDHoK5wk6MaNN8L Dx2yZI5vxPbe6JYVEhvUxxGevuhmouTXf3UxBShOaggc4++/nuJ75S/nDIBosGrs EzWkRGn2JLr0+mKTCrjhbxBocstOsEIW6XSfEE2Sx4bBdj4LkcGoR/cCmTC8vjoL 82VaUnCVWyhwRgkowi4yJzE6iG5yQ8r6NpAPZsfYkgeOLFQ9uAy6pSceFRa1w38q vrysB+e0Dof6HRCd3UvbvGo94+ev4yc8niS70nFsVGhntRQYgPxKPRrzW+HdyWVp zA49P0FJgZu8a5jAbHwgv/J7ff2pfeM+ZhEX5XqR2EaMjAqLFI5QPJTFheSfjz6q 2Nbpbnq8PuIR4f1dgp3xbC1a2Lj8mzq+ek+SLMGAskMK+su8Niw38JQT/WGncqWy H134mG6dbjGH2HhGOQjD =zkvy -----END PGP SIGNATURE----- Merge tag 'usercopy-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux Pull hardened usercopy updates from Kees Cook: "A couple hardened usercopy changes: - drop now unneeded is_vmalloc_or_module() check (Laura Abbott) - use enum instead of literals for stack frame API (Sahara)" * tag 'usercopy-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: mm/usercopy: Drop extra is_vmalloc_or_module() check usercopy: Move enum for arch_within_stack_frames()
This commit is contained in:
commit
5958cc49ed
3 changed files with 20 additions and 24 deletions
|
@ -170,9 +170,9 @@ static inline unsigned long current_stack_pointer(void)
|
|||
* entirely contained by a single stack frame.
|
||||
*
|
||||
* Returns:
|
||||
* 1 if within a frame
|
||||
* -1 if placed across a frame boundary (or outside stack)
|
||||
* 0 unable to determine (no frame pointers, etc)
|
||||
* GOOD_FRAME if within a frame
|
||||
* BAD_STACK if placed across a frame boundary (or outside stack)
|
||||
* NOT_STACK unable to determine (no frame pointers, etc)
|
||||
*/
|
||||
static inline int arch_within_stack_frames(const void * const stack,
|
||||
const void * const stackend,
|
||||
|
@ -199,13 +199,14 @@ static inline int arch_within_stack_frames(const void * const stack,
|
|||
* the copy as invalid.
|
||||
*/
|
||||
if (obj + len <= frame)
|
||||
return obj >= oldframe + 2 * sizeof(void *) ? 1 : -1;
|
||||
return obj >= oldframe + 2 * sizeof(void *) ?
|
||||
GOOD_FRAME : BAD_STACK;
|
||||
oldframe = frame;
|
||||
frame = *(const void * const *)frame;
|
||||
}
|
||||
return -1;
|
||||
return BAD_STACK;
|
||||
#else
|
||||
return 0;
|
||||
return NOT_STACK;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,18 @@
|
|||
#endif
|
||||
|
||||
#include <linux/bitops.h>
|
||||
|
||||
/*
|
||||
* For per-arch arch_within_stack_frames() implementations, defined in
|
||||
* asm/thread_info.h.
|
||||
*/
|
||||
enum {
|
||||
BAD_STACK = -1,
|
||||
NOT_STACK = 0,
|
||||
GOOD_FRAME,
|
||||
GOOD_STACK,
|
||||
};
|
||||
|
||||
#include <asm/thread_info.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
|
|
@ -19,15 +19,9 @@
|
|||
#include <linux/sched.h>
|
||||
#include <linux/sched/task.h>
|
||||
#include <linux/sched/task_stack.h>
|
||||
#include <linux/thread_info.h>
|
||||
#include <asm/sections.h>
|
||||
|
||||
enum {
|
||||
BAD_STACK = -1,
|
||||
NOT_STACK = 0,
|
||||
GOOD_FRAME,
|
||||
GOOD_STACK,
|
||||
};
|
||||
|
||||
/*
|
||||
* Checks if a given pointer and length is contained by the current
|
||||
* stack frame (if possible).
|
||||
|
@ -206,17 +200,6 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n,
|
|||
{
|
||||
struct page *page;
|
||||
|
||||
/*
|
||||
* Some architectures (arm64) return true for virt_addr_valid() on
|
||||
* vmalloced addresses. Work around this by checking for vmalloc
|
||||
* first.
|
||||
*
|
||||
* We also need to check for module addresses explicitly since we
|
||||
* may copy static data from modules to userspace
|
||||
*/
|
||||
if (is_vmalloc_or_module_addr(ptr))
|
||||
return NULL;
|
||||
|
||||
if (!virt_addr_valid(ptr))
|
||||
return NULL;
|
||||
|
||||
|
|
Loading…
Reference in a new issue