From 08d2d00b291ed4eb91530050274e67a761c1901d Mon Sep 17 00:00:00 2001 From: Petr Tesarik Date: Thu, 30 Jan 2014 09:48:02 +0100 Subject: [PATCH] /dev/mem: handle out-of-bounds read/write The loff_t type may be wider than phys_addr_t (e.g. on 32-bit systems). Consequently, the file offset may be truncated in the assignment. Currently, /dev/mem wraps around, which may cause applications to read or write incorrect regions of memory by accident. Let's follow POSIX file semantics here and return 0 when reading from and -EFBIG when writing to an offset that cannot be represented by a phys_addr_t. Note that the conditional is optimized out by the compiler if loff_t has the same size as phys_addr_t. Signed-off-by: Petr Tesarik Signed-off-by: Greg Kroah-Hartman --- Reading git-format-patch failed