]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
arm64: mmap: Ensure file offset is treated as unsigned
authorBoyang Zhou <zhouby_cn@126.com>
Mon, 29 Apr 2019 14:27:19 +0000 (15:27 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838576
commit f08cae2f28db24d95be5204046b60618d8de4ddc upstream.

The file offset argument to the arm64 sys_mmap() implementation is
scaled from bytes to pages by shifting right by PAGE_SHIFT.
Unfortunately, the offset is passed in as a signed 'off_t' type and
therefore large offsets (i.e. with the top bit set) are incorrectly
sign-extended by the shift. This has been observed to cause false mmap()
failures when mapping GPU doorbells on an arm64 server part.

Change the type of the file offset argument to sys_mmap() from 'off_t'
to 'unsigned long' so that the shifting scales the value as expected.

Cc: <stable@vger.kernel.org>
Signed-off-by: Boyang Zhou <zhouby_cn@126.com>
[will: rewrote commit message]
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/arm64/kernel/sys.c

index 26fe8ea93ea2b18d7f87e45203bfd9633cdfe5bc..17f4740cd0a83323fe0da309cacb369b3202da7b 100644 (file)
@@ -29,7 +29,7 @@
 
 asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
                         unsigned long prot, unsigned long flags,
-                        unsigned long fd, off_t off)
+                        unsigned long fd, unsigned long off)
 {
        if (offset_in_page(off) != 0)
                return -EINVAL;