1. 26 Sep, 2019 20 commits
  2. 24 Sep, 2019 20 commits
    • Linus Torvalds's avatar
      Merge branch 'i2c/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · 351c8a09
      Linus Torvalds authored
      Pull i2c updates from Wolfram Sang:
      
       - new driver for ICY, an Amiga Zorro card :)
      
       - axxia driver gained slave mode support, NXP driver gained ACPI
      
       - the slave EEPROM backend gained 16 bit address support
      
       - and lots of regular driver updates and reworks
      
      * 'i2c/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (52 commits)
        i2c: tegra: Move suspend handling to NOIRQ phase
        i2c: imx: ACPI support for NXP i2c controller
        i2c: uniphier(-f): remove all dev_dbg()
        i2c: uniphier(-f): use devm_platform_ioremap_resource()
        i2c: slave-eeprom: Add comment about address handling
        i2c: exynos5: Remove IRQF_ONESHOT
        i2c: stm32f7: Make structure stm32f7_i2c_algo constant
        i2c: cht-wc: drop check because i2c_unregister_device() is NULL safe
        i2c-eeprom_slave: Add support for more eeprom models
        i2c: fsi: Add of_put_node() before break
        i2c: synquacer: Make synquacer_i2c_ops constant
        i2c: hix5hd2: Remove IRQF_ONESHOT
        i2c: i801: Use iTCO version 6 in Cannon Lake PCH and beyond
        watchdog: iTCO: Add support for Cannon Lake PCH iTCO
        i2c: iproc: Make bcm_iproc_i2c_quirks constant
        i2c: iproc: Add full name of devicetree node to adapter name
        i2c: piix4: Add ACPI support
        i2c: piix4: Fix probing of reserved ports on AMD Family 16h Model 30h
        i2c: ocores: use request_any_context_irq() to register IRQ handler
        i2c: designware: Fix optional reset error handling
        ...
      351c8a09
    • Linus Torvalds's avatar
      Merge tag 'sound-fix-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 3cf7487c
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "A few small remaining wrap-up for this merge window.
      
        Most of patches are device-specific (HD-audio and USB-audio quirks,
        FireWire, pcm316a, fsl, rsnd, Atmel, and TI fixes), while there is a
        simple fix (actually two commits) for ASoC core"
      
      * tag 'sound-fix-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ALSA: usb-audio: Add DSD support for EVGA NU Audio
        ALSA: hda - Add laptop imic fixup for ASUS M9V laptop
        ASoC: ti: fix SND_SOC_DM365_VOICE_CODEC dependencies
        ASoC: pcm3168a: The codec does not support S32_LE
        ASoC: core: use list_del_init and move it back to soc_cleanup_component
        ALSA: hda/realtek - PCI quirk for Medion E4254
        ALSA: hda - Apply AMD controller workaround for Raven platform
        ASoC: rsnd: do error check after rsnd_channel_normalization()
        ASoC: atmel_ssc_dai: Remove wrong spinlock usage
        ASoC: core: delete component->card_list in soc_remove_component only
        ASoC: fsl_sai: Fix noise when using EDMA
        ALSA: usb-audio: Add Hiby device family to quirks for native DSD support
        ALSA: hda/realtek - Fix alienware headset mic
        ALSA: dice: fix wrong packet parameter for Alesis iO26
      3cf7487c
    • Linus Torvalds's avatar
      Merge tag 'for-5.4/io_uring-2019-09-24' of git://git.kernel.dk/linux-block · b6cb84b4
      Linus Torvalds authored
      Pull more io_uring updates from Jens Axboe:
       "A collection of later fixes and additions, that weren't quite ready
        for pushing out with the initial pull request.
      
        This contains:
      
         - Fix potential use-after-free of shadow requests (Jackie)
      
         - Fix potential OOM crash in request allocation (Jackie)
      
         - kmalloc+memcpy -> kmemdup cleanup (Jackie)
      
         - Fix poll crash regression (me)
      
         - Fix SQ thread not being nice and giving up CPU for !PREEMPT (me)
      
         - Add support for timeouts, making it easier to do epoll_wait()
           conversions, for instance (me)
      
         - Ensure io_uring works without f_ops->read_iter() and
           f_ops->write_iter() (me)"
      
      * tag 'for-5.4/io_uring-2019-09-24' of git://git.kernel.dk/linux-block:
        io_uring: correctly handle non ->{read,write}_iter() file_operations
        io_uring: IORING_OP_TIMEOUT support
        io_uring: use cond_resched() in sqthread
        io_uring: fix potential crash issue due to io_get_req failure
        io_uring: ensure poll commands clear ->sqe
        io_uring: fix use-after-free of shadow_req
        io_uring: use kmemdup instead of kmalloc and memcpy
      b6cb84b4
    • Linus Torvalds's avatar
      Merge tag 'for-5.4/post-2019-09-24' of git://git.kernel.dk/linux-block · 2e959dd8
      Linus Torvalds authored
      Pull more block updates from Jens Axboe:
       "Some later additions that weren't quite done for the first pull
        request, and also a few fixes that have arrived since.
      
        This contains:
      
         - Kill silly pktcdvd warning on attempting to register a non-scsi
           passthrough device (me)
      
         - Use symbolic constants for the block t10 protection types, and
           switch to handling it in core rather than in the drivers (Max)
      
         - libahci platform missing node put fix (Nishka)
      
         - Small series of fixes for BFQ (Paolo)
      
         - Fix possible nbd crash (Xiubo)"
      
      * tag 'for-5.4/post-2019-09-24' of git://git.kernel.dk/linux-block:
        block: drop device references in bsg_queue_rq()
        block: t10-pi: fix -Wswitch warning
        pktcdvd: remove warning on attempting to register non-passthrough dev
        ata: libahci_platform: Add of_node_put() before loop exit
        nbd: fix possible page fault for nbd disk
        nbd: rename the runtime flags as NBD_RT_ prefixed
        block, bfq: push up injection only after setting service time
        block, bfq: increase update frequency of inject limit
        block, bfq: reduce upper bound for inject limit to max_rq_in_driver+1
        block, bfq: update inject limit only after injection occurred
        block: centralize PI remapping logic to the block layer
        block: use symbolic constants for t10_pi type
      2e959dd8
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · 9c9fa97a
      Linus Torvalds authored
      Merge updates from Andrew Morton:
      
       - a few hot fixes
      
       - ocfs2 updates
      
       - almost all of -mm (slab-generic, slab, slub, kmemleak, kasan,
         cleanups, debug, pagecache, memcg, gup, pagemap, memory-hotplug,
         sparsemem, vmalloc, initialization, z3fold, compaction, mempolicy,
         oom-kill, hugetlb, migration, thp, mmap, madvise, shmem, zswap,
         zsmalloc)
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (132 commits)
        mm/zsmalloc.c: fix a -Wunused-function warning
        zswap: do not map same object twice
        zswap: use movable memory if zpool support allocate movable memory
        zpool: add malloc_support_movable to zpool_driver
        shmem: fix obsolete comment in shmem_getpage_gfp()
        mm/madvise: reduce code duplication in error handling paths
        mm: mmap: increase sockets maximum memory size pgoff for 32bits
        mm/mmap.c: refine find_vma_prev() with rb_last()
        riscv: make mmap allocation top-down by default
        mips: use generic mmap top-down layout and brk randomization
        mips: replace arch specific way to determine 32bit task with generic version
        mips: adjust brk randomization offset to fit generic version
        mips: use STACK_TOP when computing mmap base address
        mips: properly account for stack randomization and stack guard gap
        arm: use generic mmap top-down layout and brk randomization
        arm: use STACK_TOP when computing mmap base address
        arm: properly account for stack randomization and stack guard gap
        arm64, mm: make randomization selected by generic topdown mmap layout
        arm64, mm: move generic mmap layout functions to mm
        arm64: consider stack randomization for mmap base only when necessary
        ...
      9c9fa97a
    • Qian Cai's avatar
      mm/zsmalloc.c: fix a -Wunused-function warning · 2b38d01b
      Qian Cai authored
      set_zspage_inuse() was introduced in the commit 4f42047b ("zsmalloc:
      use accessor") but all the users of it were removed later by the commits,
      
      bdb0af7c ("zsmalloc: factor page chain functionality out")
      3783689a ("zsmalloc: introduce zspage structure")
      
      so the function can be safely removed now.
      
      Link: http://lkml.kernel.org/r/1568658408-19374-1-git-send-email-cai@lca.pwSigned-off-by: default avatarQian Cai <cai@lca.pw>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2b38d01b
    • Vitaly Wool's avatar
      zswap: do not map same object twice · 068619e3
      Vitaly Wool authored
      zswap_writeback_entry() maps a handle to read swpentry first, and
      then in the most common case it would map the same handle again.
      This is ok when zbud is the backend since its mapping callback is
      plain and simple, but it slows things down for z3fold.
      
      Since there's hardly a point in unmapping a handle _that_ fast as
      zswap_writeback_entry() does when it reads swpentry, the
      suggestion is to keep the handle mapped till the end.
      
      Link: http://lkml.kernel.org/r/20190916004640.b453167d3556c4093af4cf7d@gmail.comSigned-off-by: default avatarVitaly Wool <vitalywool@gmail.com>
      Reviewed-by: default avatarDan Streetman <ddstreet@ieee.org>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
      Cc: Seth Jennings <sjenning@redhat.com>
      Cc: Vitaly Wool <vitalywool@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      068619e3
    • Hui Zhu's avatar
      zswap: use movable memory if zpool support allocate movable memory · d2fcd82b
      Hui Zhu authored
      This is the third version that was updated according to the comments from
      Sergey Senozhatsky https://lkml.org/lkml/2019/5/29/73 and Shakeel Butt
      https://lkml.org/lkml/2019/6/4/973
      
      zswap compresses swap pages into a dynamically allocated RAM-based memory
      pool.  The memory pool should be zbud, z3fold or zsmalloc.  All of them
      will allocate unmovable pages.  It will increase the number of unmovable
      page blocks that will bad for anti-fragment.
      
      zsmalloc support page migration if request movable page:
              handle = zs_malloc(zram->mem_pool, comp_len,
                      GFP_NOIO | __GFP_HIGHMEM |
                      __GFP_MOVABLE);
      
      And commit "zpool: Add malloc_support_movable to zpool_driver" add
      zpool_malloc_support_movable check malloc_support_movable to make sure if
      a zpool support allocate movable memory.
      
      This commit let zswap allocate block with gfp
      __GFP_HIGHMEM | __GFP_MOVABLE if zpool support allocate movable memory.
      
      Following part is test log in a pc that has 8G memory and 2G swap.
      
      Without this commit:
      ~# echo lz4 > /sys/module/zswap/parameters/compressor
      ~# echo zsmalloc > /sys/module/zswap/parameters/zpool
      ~# echo 1 > /sys/module/zswap/parameters/enabled
      ~# swapon /swapfile
      ~# cd /home/teawater/kernel/vm-scalability/
      /home/teawater/kernel/vm-scalability# export unit_size=$((9 * 1024 * 1024 * 1024))
      /home/teawater/kernel/vm-scalability# ./case-anon-w-seq
      2717908992 bytes / 4826062 usecs = 549973 KB/s
      2717908992 bytes / 4864201 usecs = 545661 KB/s
      2717908992 bytes / 4867015 usecs = 545346 KB/s
      2717908992 bytes / 4915485 usecs = 539968 KB/s
      397853 usecs to free memory
      357820 usecs to free memory
      421333 usecs to free memory
      420454 usecs to free memory
      /home/teawater/kernel/vm-scalability# cat /proc/pagetypeinfo
      Page block order: 9
      Pages per block:  512
      
      Free pages count per migrate type at order       0      1      2      3      4      5      6      7      8      9     10
      Node    0, zone      DMA, type    Unmovable      1      1      1      0      2      1      1      0      1      0      0
      Node    0, zone      DMA, type      Movable      0      0      0      0      0      0      0      0      0      1      3
      Node    0, zone      DMA, type  Reclaimable      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone      DMA, type   HighAtomic      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone      DMA, type          CMA      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone      DMA, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone    DMA32, type    Unmovable      6      5      8      6      6      5      4      1      1      1      0
      Node    0, zone    DMA32, type      Movable     25     20     20     19     22     15     14     11     11      5    767
      Node    0, zone    DMA32, type  Reclaimable      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone    DMA32, type   HighAtomic      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone    DMA32, type          CMA      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone    DMA32, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone   Normal, type    Unmovable   4753   5588   5159   4613   3712   2520   1448    594    188     11      0
      Node    0, zone   Normal, type      Movable     16      3    457   2648   2143   1435    860    459    223    224    296
      Node    0, zone   Normal, type  Reclaimable      0      0     44     38     11      2      0      0      0      0      0
      Node    0, zone   Normal, type   HighAtomic      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone   Normal, type          CMA      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone   Normal, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
      
      Number of blocks type     Unmovable      Movable  Reclaimable   HighAtomic          CMA      Isolate
      Node 0, zone      DMA            1            7            0            0            0            0
      Node 0, zone    DMA32            4         1652            0            0            0            0
      Node 0, zone   Normal          931         1485           15            0            0            0
      
      With this commit:
      ~# echo lz4 > /sys/module/zswap/parameters/compressor
      ~# echo zsmalloc > /sys/module/zswap/parameters/zpool
      ~# echo 1 > /sys/module/zswap/parameters/enabled
      ~# swapon /swapfile
      ~# cd /home/teawater/kernel/vm-scalability/
      /home/teawater/kernel/vm-scalability# export unit_size=$((9 * 1024 * 1024 * 1024))
      /home/teawater/kernel/vm-scalability# ./case-anon-w-seq
      2717908992 bytes / 4689240 usecs = 566020 KB/s
      2717908992 bytes / 4760605 usecs = 557535 KB/s
      2717908992 bytes / 4803621 usecs = 552543 KB/s
      2717908992 bytes / 5069828 usecs = 523530 KB/s
      431546 usecs to free memory
      383397 usecs to free memory
      456454 usecs to free memory
      224487 usecs to free memory
      /home/teawater/kernel/vm-scalability# cat /proc/pagetypeinfo
      Page block order: 9
      Pages per block:  512
      
      Free pages count per migrate type at order       0      1      2      3      4      5      6      7      8      9     10
      Node    0, zone      DMA, type    Unmovable      1      1      1      0      2      1      1      0      1      0      0
      Node    0, zone      DMA, type      Movable      0      0      0      0      0      0      0      0      0      1      3
      Node    0, zone      DMA, type  Reclaimable      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone      DMA, type   HighAtomic      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone      DMA, type          CMA      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone      DMA, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone    DMA32, type    Unmovable     10      8     10      9     10      4      3      2      3      0      0
      Node    0, zone    DMA32, type      Movable     18     12     14     16     16     11      9      5      5      6    775
      Node    0, zone    DMA32, type  Reclaimable      0      0      0      0      0      0      0      0      0      0      1
      Node    0, zone    DMA32, type   HighAtomic      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone    DMA32, type          CMA      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone    DMA32, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone   Normal, type    Unmovable   2669   1236    452    118     37     14      4      1      2      3      0
      Node    0, zone   Normal, type      Movable   3850   6086   5274   4327   3510   2494   1520    934    438    220    470
      Node    0, zone   Normal, type  Reclaimable     56     93    155    124     47     31     17      7      3      0      0
      Node    0, zone   Normal, type   HighAtomic      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone   Normal, type          CMA      0      0      0      0      0      0      0      0      0      0      0
      Node    0, zone   Normal, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
      
      Number of blocks type     Unmovable      Movable  Reclaimable   HighAtomic          CMA      Isolate
      Node 0, zone      DMA            1            7            0            0            0            0
      Node 0, zone    DMA32            4         1650            2            0            0            0
      Node 0, zone   Normal           79         2326           26            0            0            0
      
      You can see that the number of unmovable page blocks is decreased
      when the kernel has this commit.
      
      Link: http://lkml.kernel.org/r/20190605100630.13293-2-teawaterz@linux.alibaba.comSigned-off-by: default avatarHui Zhu <teawaterz@linux.alibaba.com>
      Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
      Cc: Dan Streetman <ddstreet@ieee.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Nitin Gupta <ngupta@vflare.org>
      Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
      Cc: Seth Jennings <sjenning@redhat.com>
      Cc: Vitaly Wool <vitalywool@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d2fcd82b
    • Hui Zhu's avatar
      zpool: add malloc_support_movable to zpool_driver · c165f25d
      Hui Zhu authored
      As a zpool_driver, zsmalloc can allocate movable memory because it support
      migate pages.  But zbud and z3fold cannot allocate movable memory.
      
      Add malloc_support_movable to zpool_driver.  If a zpool_driver support
      allocate movable memory, set it to true.  And add
      zpool_malloc_support_movable check malloc_support_movable to make sure if
      a zpool support allocate movable memory.
      
      Link: http://lkml.kernel.org/r/20190605100630.13293-1-teawaterz@linux.alibaba.comSigned-off-by: default avatarHui Zhu <teawaterz@linux.alibaba.com>
      Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
      Cc: Dan Streetman <ddstreet@ieee.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Nitin Gupta <ngupta@vflare.org>
      Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
      Cc: Seth Jennings <sjenning@redhat.com>
      Cc: Vitaly Wool <vitalywool@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c165f25d
    • Miles Chen's avatar
      shmem: fix obsolete comment in shmem_getpage_gfp() · 28eb3c80
      Miles Chen authored
      Replace "fault_mm" with "vmf" in code comment because commit cfda0526
      ("userfaultfd: shmem: add userfaultfd hook for shared memory faults") has
      changed the prototpye of shmem_getpage_gfp() - pass vmf instead of
      fault_mm to the function.
      
      Before:
      static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
      		struct page **pagep, enum sgp_type sgp,
      		gfp_t gfp, struct mm_struct *fault_mm, int *fault_type);
      After:
      static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
      		struct page **pagep, enum sgp_type sgp,
      		gfp_t gfp, struct vm_area_struct *vma,
      		struct vm_fault *vmf, vm_fault_t *fault_type);
      
      Link: http://lkml.kernel.org/r/20190816100204.9781-1-miles.chen@mediatek.comSigned-off-by: default avatarMiles Chen <miles.chen@mediatek.com>
      Cc: Hugh Dickins <hughd@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      28eb3c80
    • Mike Rapoport's avatar
      mm/madvise: reduce code duplication in error handling paths · f3bc0dba
      Mike Rapoport authored
      madvise_behavior() converts -ENOMEM to -EAGAIN in several places using
      identical code.
      
      Move that code to a common error handling path.
      
      No functional changes.
      
      Link: http://lkml.kernel.org/r/1564640896-1210-1-git-send-email-rppt@linux.ibm.comSigned-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Acked-by: default avatarPankaj Gupta <pagupta@redhat.com>
      Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f3bc0dba
    • Ivan Khoronzhuk's avatar
      mm: mmap: increase sockets maximum memory size pgoff for 32bits · 76f34950
      Ivan Khoronzhuk authored
      The AF_XDP sockets umem mapping interface uses XDP_UMEM_PGOFF_FILL_RING
      and XDP_UMEM_PGOFF_COMPLETION_RING offsets.  These offsets are
      established already and are part of the configuration interface.
      
      But for 32-bit systems, using AF_XDP socket configuration, these values
      are too large to pass the maximum allowed file size verification.  The
      offsets can be tuned off, but instead of changing the existing
      interface, let's extend the max allowed file size for sockets.
      
      No one has been using this until this patch with 32 bits as without
      this fix af_xdp sockets can't be used at all, so it unblocks af_xdp
      socket usage for 32bit systems.
      
      All list of mmap cbs for sockets was verified for side effects and all
      of them contain dummy cb - sock_no_mmap() at this moment, except the
      following:
      
      xsk_mmap() - it's what this fix is needed for.
      tcp_mmap() - doesn't have obvious issues with pgoff - no any references on it.
      packet_mmap() - return -EINVAL if it's even set.
      
      Link: http://lkml.kernel.org/r/20190812124326.32146-1-ivan.khoronzhuk@linaro.orgSigned-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Björn Töpel <bjorn.topel@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Magnus Karlsson <magnus.karlsson@intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Miller <davem@davemloft.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      76f34950
    • Wei Yang's avatar
      mm/mmap.c: refine find_vma_prev() with rb_last() · 73848a97
      Wei Yang authored
      When addr is out of range of the whole rb_tree, pprev will point to the
      right-most node.  rb_tree facility already provides a helper function,
      rb_last(), to do this task.  We can leverage this instead of
      reimplementing it.
      
      This patch refines find_vma_prev() with rb_last() to make it a little
      nicer to read.
      
      [akpm@linux-foundation.org: little cleanup, per Vlastimil]
      Link: http://lkml.kernel.org/r/20190809001928.4950-1-richardw.yang@linux.intel.comSigned-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      73848a97
    • Alexandre Ghiti's avatar
      riscv: make mmap allocation top-down by default · 54c95a11
      Alexandre Ghiti authored
      In order to avoid wasting user address space by using bottom-up mmap
      allocation scheme, prefer top-down scheme when possible.
      
      Before:
      root@qemuriscv64:~# cat /proc/self/maps
      00010000-00016000 r-xp 00000000 fe:00 6389       /bin/cat.coreutils
      00016000-00017000 r--p 00005000 fe:00 6389       /bin/cat.coreutils
      00017000-00018000 rw-p 00006000 fe:00 6389       /bin/cat.coreutils
      00018000-00039000 rw-p 00000000 00:00 0          [heap]
      1555556000-155556d000 r-xp 00000000 fe:00 7193   /lib/ld-2.28.so
      155556d000-155556e000 r--p 00016000 fe:00 7193   /lib/ld-2.28.so
      155556e000-155556f000 rw-p 00017000 fe:00 7193   /lib/ld-2.28.so
      155556f000-1555570000 rw-p 00000000 00:00 0
      1555570000-1555572000 r-xp 00000000 00:00 0      [vdso]
      1555574000-1555576000 rw-p 00000000 00:00 0
      1555576000-1555674000 r-xp 00000000 fe:00 7187   /lib/libc-2.28.so
      1555674000-1555678000 r--p 000fd000 fe:00 7187   /lib/libc-2.28.so
      1555678000-155567a000 rw-p 00101000 fe:00 7187   /lib/libc-2.28.so
      155567a000-15556a0000 rw-p 00000000 00:00 0
      3fffb90000-3fffbb1000 rw-p 00000000 00:00 0      [stack]
      
      After:
      root@qemuriscv64:~# cat /proc/self/maps
      00010000-00016000 r-xp 00000000 fe:00 6389       /bin/cat.coreutils
      00016000-00017000 r--p 00005000 fe:00 6389       /bin/cat.coreutils
      00017000-00018000 rw-p 00006000 fe:00 6389       /bin/cat.coreutils
      2de81000-2dea2000 rw-p 00000000 00:00 0          [heap]
      3ff7eb6000-3ff7ed8000 rw-p 00000000 00:00 0
      3ff7ed8000-3ff7fd6000 r-xp 00000000 fe:00 7187   /lib/libc-2.28.so
      3ff7fd6000-3ff7fda000 r--p 000fd000 fe:00 7187   /lib/libc-2.28.so
      3ff7fda000-3ff7fdc000 rw-p 00101000 fe:00 7187   /lib/libc-2.28.so
      3ff7fdc000-3ff7fe2000 rw-p 00000000 00:00 0
      3ff7fe4000-3ff7fe6000 r-xp 00000000 00:00 0      [vdso]
      3ff7fe6000-3ff7ffd000 r-xp 00000000 fe:00 7193   /lib/ld-2.28.so
      3ff7ffd000-3ff7ffe000 r--p 00016000 fe:00 7193   /lib/ld-2.28.so
      3ff7ffe000-3ff7fff000 rw-p 00017000 fe:00 7193   /lib/ld-2.28.so
      3ff7fff000-3ff8000000 rw-p 00000000 00:00 0
      3fff888000-3fff8a9000 rw-p 00000000 00:00 0      [stack]
      
      [alex@ghiti.fr: v6]
        Link: http://lkml.kernel.org/r/20190808061756.19712-15-alex@ghiti.fr
      Link: http://lkml.kernel.org/r/20190730055113.23635-15-alex@ghiti.frSigned-off-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Acked-by: Paul Walmsley <paul.walmsley@sifive.com>	[arch/riscv]
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Palmer Dabbelt <palmer@sifive.com>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      54c95a11
    • Alexandre Ghiti's avatar
      mips: use generic mmap top-down layout and brk randomization · 9035bd29
      Alexandre Ghiti authored
      mips uses a top-down layout by default that exactly fits the generic
      functions, so get rid of arch specific code and use the generic version by
      selecting ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT.
      
      As ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT selects ARCH_HAS_ELF_RANDOMIZE,
      use the generic version of arch_randomize_brk since it also fits.  Note
      that this commit also removes the possibility for mips to have elf
      randomization and no MMU: without MMU, the security added by randomization
      is worth nothing.
      
      Link: http://lkml.kernel.org/r/20190730055113.23635-14-alex@ghiti.frSigned-off-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Acked-by: default avatarPaul Burton <paul.burton@mips.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Palmer Dabbelt <palmer@sifive.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9035bd29
    • Alexandre Ghiti's avatar
      mips: replace arch specific way to determine 32bit task with generic version · 09036468
      Alexandre Ghiti authored
      Mips uses TASK_IS_32BIT_ADDR to determine if a task is 32bit, but this
      define is mips specific and other arches do not have it: instead, use
      !IS_ENABLED(CONFIG_64BIT) || is_compat_task() condition.
      
      Link: http://lkml.kernel.org/r/20190730055113.23635-13-alex@ghiti.frSigned-off-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Acked-by: default avatarPaul Burton <paul.burton@mips.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Palmer Dabbelt <palmer@sifive.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      09036468
    • Alexandre Ghiti's avatar
      mips: adjust brk randomization offset to fit generic version · e548599f
      Alexandre Ghiti authored
      This commit simply bumps up to 32MB and 1GB the random offset of brk,
      compared to 8MB and 256MB, for 32bit and 64bit respectively.
      
      Link: http://lkml.kernel.org/r/20190730055113.23635-12-alex@ghiti.frSuggested-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Acked-by: default avatarPaul Burton <paul.burton@mips.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Palmer Dabbelt <palmer@sifive.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e548599f
    • Alexandre Ghiti's avatar
      mips: use STACK_TOP when computing mmap base address · b5fb8617
      Alexandre Ghiti authored
      mmap base address must be computed wrt stack top address, using TASK_SIZE
      is wrong since STACK_TOP and TASK_SIZE are not equivalent.
      
      Link: http://lkml.kernel.org/r/20190730055113.23635-11-alex@ghiti.frSigned-off-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarPaul Burton <paul.burton@mips.com>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Palmer Dabbelt <palmer@sifive.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b5fb8617
    • Alexandre Ghiti's avatar
      mips: properly account for stack randomization and stack guard gap · b1f61b5b
      Alexandre Ghiti authored
      This commit takes care of stack randomization and stack guard gap when
      computing mmap base address and checks if the task asked for
      randomization.  This fixes the problem uncovered and not fixed for arm
      here: https://lkml.kernel.org/r/20170622200033.25714-1-riel@redhat.com
      
      Link: http://lkml.kernel.org/r/20190730055113.23635-10-alex@ghiti.frSigned-off-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarPaul Burton <paul.burton@mips.com>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Palmer Dabbelt <palmer@sifive.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b1f61b5b
    • Alexandre Ghiti's avatar
      arm: use generic mmap top-down layout and brk randomization · dba79c3d
      Alexandre Ghiti authored
      arm uses a top-down mmap layout by default that exactly fits the generic
      functions, so get rid of arch specific code and use the generic version by
      selecting ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT.
      
      As ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT selects ARCH_HAS_ELF_RANDOMIZE,
      use the generic version of arch_randomize_brk since it also fits.  Note
      that this commit also removes the possibility for arm to have elf
      randomization and no MMU: without MMU, the security added by randomization
      is worth nothing.
      
      Note that it is safe to remove STACK_RND_MASK since it matches the default
      value.
      
      Link: http://lkml.kernel.org/r/20190730055113.23635-9-alex@ghiti.frSigned-off-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Palmer Dabbelt <palmer@sifive.com>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dba79c3d