drivers: char: mem: Fix wraparound check to allow mappings up to the end
authorJulius Werner <jwerner@chromium.org>
Fri, 2 Jun 2017 22:36:39 +0000 (15:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jun 2017 13:06:04 +0000 (15:06 +0200)
commit9ff4a1a36a587b0343a02518dbc1d5bf4c0c99e8
treedaeca9404c8e1bd545b49fc78d86095b0e8a574a
parent106c77e82572921fa53483235a55adb7cb9452c0
drivers: char: mem: Fix wraparound check to allow mappings up to the end

commit 32829da54d9368103a2f03269a5120aa9ee4d5da upstream.

A recent fix to /dev/mem prevents mappings from wrapping around the end
of physical address space. However, the check was written in a way that
also prevents a mapping reaching just up to the end of physical address
space, which may be a valid use case (especially on 32-bit systems).
This patch fixes it by checking the last mapped address (instead of the
first address behind that) for overflow.

Fixes: b299cde245 ("drivers: char: mem: Check for address space wraparound with mmap()")
Reported-by: Nico Huber <nico.h@gmx.de>
Signed-off-by: Julius Werner <jwerner@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/mem.c