summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2022-02-15 17:59:41 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-28 09:59:56 +0200
commit547e4a8415d403c0af8810cd1a1fd5f7e152cd97 (patch)
treedf8077811cea3ba4e8a2d918c79904252a7489bd
parente047a3860fe3fbb10130f52d792d210cb25e582a (diff)
downloadlinux-stable-547e4a8415d403c0af8810cd1a1fd5f7e152cd97.tar.gz
linux-stable-547e4a8415d403c0af8810cd1a1fd5f7e152cd97.tar.bz2
linux-stable-547e4a8415d403c0af8810cd1a1fd5f7e152cd97.zip
m68k: fix access_ok for coldfire
commit 26509034bef198525d5936c116cbd0c3fa491c0b upstream. While most m68k platforms use separate address spaces for user and kernel space, at least coldfire does not, and the other ones have a TASK_SIZE that is less than the entire 4GB address range. Using the default implementation of __access_ok() stops coldfire user space from trivially accessing kernel memory. Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/m68k/include/asm/uaccess.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/arch/m68k/include/asm/uaccess.h b/arch/m68k/include/asm/uaccess.h
index ba670523885c..60b786eb2254 100644
--- a/arch/m68k/include/asm/uaccess.h
+++ b/arch/m68k/include/asm/uaccess.h
@@ -12,14 +12,17 @@
#include <asm/extable.h>
/* We let the MMU do all checking */
-static inline int access_ok(const void __user *addr,
+static inline int access_ok(const void __user *ptr,
unsigned long size)
{
- /*
- * XXX: for !CONFIG_CPU_HAS_ADDRESS_SPACES this really needs to check
- * for TASK_SIZE!
- */
- return 1;
+ unsigned long limit = TASK_SIZE;
+ unsigned long addr = (unsigned long)ptr;
+
+ if (IS_ENABLED(CONFIG_CPU_HAS_ADDRESS_SPACES) ||
+ !IS_ENABLED(CONFIG_MMU))
+ return 1;
+
+ return (size <= limit) && (addr <= (limit - size));
}
/*