Skip to content

Commit 110dea3

Browse files
arndbgregkh
authored andcommitted
m68k: fix access_ok for coldfire
commit 2650903 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>
1 parent cdb9644 commit 110dea3

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

arch/m68k/include/asm/uaccess.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
#include <asm/extable.h>
1313

1414
/* We let the MMU do all checking */
15-
static inline int access_ok(const void __user *addr,
15+
static inline int access_ok(const void __user *ptr,
1616
unsigned long size)
1717
{
18-
/*
19-
* XXX: for !CONFIG_CPU_HAS_ADDRESS_SPACES this really needs to check
20-
* for TASK_SIZE!
21-
*/
22-
return 1;
18+
unsigned long limit = TASK_SIZE;
19+
unsigned long addr = (unsigned long)ptr;
20+
21+
if (IS_ENABLED(CONFIG_CPU_HAS_ADDRESS_SPACES) ||
22+
!IS_ENABLED(CONFIG_MMU))
23+
return 1;
24+
25+
return (size <= limit) && (addr <= (limit - size));
2326
}
2427

2528
/*

0 commit comments

Comments
 (0)