1. 19 Jan, 2021 40 commits
    • Greg Kroah-Hartman's avatar
    • Olaf Hering's avatar
      kbuild: enforce -Werror=return-type · 47b5fc25
      Olaf Hering authored
      commit 172aad81
      
       upstream.
      
      Catch errors which at least gcc tolerates by default:
       warning: 'return' with no value, in function returning non-void [-Wreturn-type]
      Signed-off-by: default avatarOlaf Hering <olaf@aepfle.de>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      47b5fc25
    • Dinghao Liu's avatar
      netfilter: nf_nat: Fix memleak in nf_nat_init · 1921060a
      Dinghao Liu authored
      commit 869f4fda upstream.
      
      When register_pernet_subsys() fails, nf_nat_bysource
      should be freed just like when nf_ct_extend_register()
      fails.
      
      Fixes: 1cd472bf
      
       ("netfilter: nf_nat: add nat hook register functions to nf_nat")
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Acked-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1921060a
    • Jesper Dangaard Brouer's avatar
      netfilter: conntrack: fix reading nf_conntrack_buckets · b69a79c6
      Jesper Dangaard Brouer authored
      commit f6351c3f upstream.
      
      The old way of changing the conntrack hashsize runtime was through changing
      the module param via file /sys/module/nf_conntrack/parameters/hashsize. This
      was extended to sysctl change in commit 3183ab89 ("netfilter: conntrack:
      allow increasing bucket size via sysctl too").
      
      The commit introduced second "user" variable nf_conntrack_htable_size_user
      which shadow actual variable nf_conntrack_htable_size. When hashsize is
      changed via module param this "user" variable isn't updated. This results in
      sysctl net/netfilter/nf_conntrack_buckets shows the wrong value when users
      update via the old way.
      
      This patch fix the issue by always updating "user" variable when reading the
      proc file. This will take care of changes to the actual variable without
      sysctl need to be aware.
      
      Fixes: 3183ab89
      
       ("netfilter: conntrack: allow increasing bucket size via sysctl too")
      Reported-by: default avatarYoel Caspersen <yoel@kviknet.dk>
      Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Acked-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b69a79c6
    • Geert Uytterhoeven's avatar
      ALSA: fireface: Fix integer overflow in transmit_midi_msg() · f1bf14da
      Geert Uytterhoeven authored
      commit e7c22eea upstream.
      
      As snd_ff.rx_bytes[] is unsigned int, and NSEC_PER_SEC is 1000000000L,
      the second multiplication in
      
          ff->rx_bytes[port] * 8 * NSEC_PER_SEC / 31250
      
      always overflows on 32-bit platforms, truncating the result.  Fix this
      by precalculating "NSEC_PER_SEC / 31250", which is an integer constant.
      
      Note that this assumes ff->rx_bytes[port] <= 16777.
      
      Fixes: 19174295
      
       ("ALSA: fireface: add transaction support")
      Reviewed-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/20210111130251.361335-2-geert+renesas@glider.be
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1bf14da
    • Geert Uytterhoeven's avatar
      ALSA: firewire-tascam: Fix integer overflow in midi_port_work() · ab2c8bb6
      Geert Uytterhoeven authored
      commit 9f65df9c upstream.
      
      As snd_fw_async_midi_port.consume_bytes is unsigned int, and
      NSEC_PER_SEC is 1000000000L, the second multiplication in
      
          port->consume_bytes * 8 * NSEC_PER_SEC / 31250
      
      always overflows on 32-bit platforms, truncating the result.  Fix this
      by precalculating "NSEC_PER_SEC / 31250", which is an integer constant.
      
      Note that this assumes port->consume_bytes <= 16777.
      
      Fixes: 531f4718
      
       ("ALSA: firewire-lib/firewire-tascam: localize async midi port")
      Reviewed-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/20210111130251.361335-3-geert+renesas@glider.be
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab2c8bb6
    • Mike Snitzer's avatar
      dm: eliminate potential source of excessive kernel log noise · a4cc93ec
      Mike Snitzer authored
      commit 0378c625
      
       upstream.
      
      There wasn't ever a real need to log an error in the kernel log for
      ioctls issued with insufficient permissions. Simply return an error
      and if an admin/user is sufficiently motivated they can enable DM's
      dynamic debugging to see an explanation for why the ioctls were
      disallowed.
      Reported-by: default avatarNir Soffer <nsoffer@redhat.com>
      Fixes: e980f623
      
       ("dm: don't allow ioctls to targets that don't map to whole devices")
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4cc93ec
    • j.nixdorf@avm.de's avatar
      net: sunrpc: interpret the return value of kstrtou32 correctly · f6ced16c
      j.nixdorf@avm.de authored
      commit 86b53fbf
      
       upstream.
      
      A return value of 0 means success. This is documented in lib/kstrtox.c.
      
      This was found by trying to mount an NFS share from a link-local IPv6
      address with the interface specified by its index:
      
        mount("[fe80::1%1]:/srv/nfs", "/mnt", "nfs", 0, "nolock,addr=fe80::1%1")
      
      Before this commit this failed with EINVAL and also caused the following
      message in dmesg:
      
        [...] NFS: bad IP address specified: addr=fe80::1%1
      
      The syscall using the same address based on the interface name instead
      of its index succeeds.
      
      Credits for this patch go to my colleague Christian Speich, who traced
      the origin of this bug to this line of code.
      Signed-off-by: default avatarJohannes Nixdorf <j.nixdorf@avm.de>
      Fixes: 00cfaa94
      
       ("replace strict_strto calls")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f6ced16c
    • Jann Horn's avatar
      mm, slub: consider rest of partial list if acquire_slab() fails · 21a466ae
      Jann Horn authored
      commit 8ff60eb0 upstream.
      
      acquire_slab() fails if there is contention on the freelist of the page
      (probably because some other CPU is concurrently freeing an object from
      the page).  In that case, it might make sense to look for a different page
      (since there might be more remote frees to the page from other CPUs, and
      we don't want contention on struct page).
      
      However, the current code accidentally stops looking at the partial list
      completely in that case.  Especially on kernels without CONFIG_NUMA set,
      this means that get_partial() fails and new_slab_objects() falls back to
      new_slab(), allocating new pages.  This could lead to an unnecessary
      increase in memory fragmentation.
      
      Link: https://lkml.kernel.org/r/20201228130853.1871516-1-jannh@google.com
      Fixes: 7ced3719
      
       ("slub: Acquire_slab() avoid loop")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Acked-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21a466ae
    • Mark Bloch's avatar
      RDMA/mlx5: Fix wrong free of blue flame register on error · b1f2d446
      Mark Bloch authored
      commit 1c3aa6bd upstream.
      
      If the allocation of the fast path blue flame register fails, the driver
      should free the regular blue flame register allocated a statement above,
      not the one that it just failed to allocate.
      
      Fixes: 16c1975f ("IB/mlx5: Create profile infrastructure to add and remove stages")
      Link: https://lore.kernel.org/r/20210113121703.559778-6-leon@kernel.org
      
      Reported-by: default avatarHans Petter Selasky <hanss@nvidia.com>
      Signed-off-by: default avatarMark Bloch <mbloch@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b1f2d446
    • Dinghao Liu's avatar
      RDMA/usnic: Fix memleak in find_free_vf_and_create_qp_grp · 25469b2e
      Dinghao Liu authored
      commit a306aba9 upstream.
      
      If usnic_ib_qp_grp_create() fails at the first call, dev_list
      will not be freed on error, which leads to memleak.
      
      Fixes: e3cf00d0 ("IB/usnic: Add Cisco VIC low-level hardware driver")
      Link: https://lore.kernel.org/r/20201226074248.2893-1-dinghao.liu@zju.edu.cn
      
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25469b2e
    • Jan Kara's avatar
      ext4: fix superblock checksum failure when setting password salt · 8e45768d
      Jan Kara authored
      commit dfd56c2c
      
       upstream.
      
      When setting password salt in the superblock, we forget to recompute the
      superblock checksum so it will not match until the next superblock
      modification which recomputes the checksum. Fix it.
      
      CC: Michael Halcrow <mhalcrow@google.com>
      Reported-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Fixes: 9bd8212f
      
       ("ext4 crypto: add encryption policy and password salt support")
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20201216101844.22917-8-jack@suse.cz
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e45768d
    • Trond Myklebust's avatar
      NFS: nfs_igrab_and_active must first reference the superblock · df7adeee
      Trond Myklebust authored
      commit 896567ee upstream.
      
      Before referencing the inode, we must ensure that the superblock can be
      referenced. Otherwise, we can end up with iput() calling superblock
      operations that are no longer valid or accessible.
      
      Fixes: ea7c38fe
      
       ("NFSv4: Ensure we reference the inode for return-on-close in delegreturn")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df7adeee
    • Trond Myklebust's avatar
      NFS/pNFS: Fix a leak of the layout 'plh_outstanding' counter · b2f9fbbc
      Trond Myklebust authored
      commit cb2856c5 upstream.
      
      If we exit _lgopen_prepare_attached() without setting a layout, we will
      currently leak the plh_outstanding counter.
      
      Fixes: 411ae722
      
       ("pNFS: Wait for stale layoutget calls to complete in pnfs_update_layout()")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2f9fbbc
    • Trond Myklebust's avatar
      pNFS: Mark layout for return if return-on-close was not sent · 87396ce3
      Trond Myklebust authored
      commit 67bbceed upstream.
      
      If the layout return-on-close failed because the layoutreturn was never
      sent, then we should mark the layout for return again.
      
      Fixes: 9c47b18c
      
       ("pNFS: Ensure we do clear the return-on-close layout stateid on fatal errors")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87396ce3
    • Dave Wysochanski's avatar
      NFS4: Fix use-after-free in trace_event_raw_event_nfs4_set_lock · 825e0ffa
      Dave Wysochanski authored
      commit 3d1a90ab upstream.
      
      It is only safe to call the tracepoint before rpc_put_task() because
      'data' is freed inside nfs4_lock_release (rpc_release).
      
      Fixes: 48c9579a
      
       ("Adding stateid information to tracepoints")
      Signed-off-by: default avatarDave Wysochanski <dwysocha@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      825e0ffa
    • Dan Carpenter's avatar
      ASoC: Intel: fix error code cnl_set_dsp_D0() · fd75081a
      Dan Carpenter authored
      commit f373a811 upstream.
      
      Return -ETIMEDOUT if the dsp boot times out instead of returning
      success.
      
      Fixes: cb6a5528
      
       ("ASoC: Intel: cnl: Add sst library functions for cnl platform")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
      Link: https://lore.kernel.org/r/X9NEvCzuN+IObnTN@mwanda
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd75081a
    • Jerome Brunet's avatar
      ASoC: meson: axg-tdm-interface: fix loopback · 516d9690
      Jerome Brunet authored
      commit 671ee4db upstream.
      
      When the axg-tdm-interface was introduced, the backend DAI was marked as an
      endpoint when DPCM was walking the DAPM graph to find a its BE.
      
      It is no longer the case since this
      commit 8dd26dff ("ASoC: dapm: Fix handling of custom_stop_condition on DAPM graph walks")
      Because of this, when DPCM finds a BE it does everything it needs on the
      DAIs but it won't power up the widgets between the FE and the BE if there
      is no actual endpoint after the BE.
      
      On meson-axg HWs, the loopback is a special DAI of the tdm-interface BE.
      It is only linked to the dummy codec since there no actual HW after it.
      >From the DAPM perspective, the DAI has no endpoint. Because of this, the TDM
      decoder, which is a widget between the FE and BE is not powered up.
      
      >From the user perspective, everything seems fine but no data is produced.
      
      Connecting the Loopback DAI to a dummy DAPM endpoint solves the problem.
      
      Fixes: 8dd26dff
      
       ("ASoC: dapm: Fix handling of custom_stop_condition on DAPM graph walks")
      Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
      Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
      Link: https://lore.kernel.org/r/20201217150812.3247405-1-jbrunet@baylibre.com
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      516d9690
    • Al Viro's avatar
      dump_common_audit_data(): fix racy accesses to ->d_name · fda4bb55
      Al Viro authored
      commit d36a1dd9
      
       upstream.
      
      We are not guaranteed the locking environment that would prevent
      dentry getting renamed right under us.  And it's possible for
      old long name to be freed after rename, leading to UAF here.
      
      Cc: stable@kernel.org # v2.6.2+
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fda4bb55
    • Roberto Sassu's avatar
      ima: Remove __init annotation from ima_pcrread() · de581e41
      Roberto Sassu authored
      commit 8b8c704d upstream.
      
      Commit 6cc7c266 ("ima: Call ima_calc_boot_aggregate() in
      ima_eventdigest_init()") added a call to ima_calc_boot_aggregate() so that
      the digest can be recalculated for the boot_aggregate measurement entry if
      the 'd' template field has been requested. For the 'd' field, only SHA1 and
      MD5 digests are accepted.
      
      Given that ima_eventdigest_init() does not have the __init annotation, all
      functions called should not have it. This patch removes __init from
      ima_pcrread().
      
      Cc: stable@vger.kernel.org
      Fixes:  6cc7c266
      
       ("ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init()")
      Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      de581e41
    • Arnd Bergmann's avatar
      ARM: picoxcell: fix missing interrupt-parent properties · 48d19197
      Arnd Bergmann authored
      [ Upstream commit bac71717 ]
      
      dtc points out that the interrupts for some devices are not parsable:
      
      picoxcell-pc3x2.dtsi:45.19-49.5: Warning (interrupts_property): /paxi/gem@30000: Missing interrupt-parent
      picoxcell-pc3x2.dtsi:51.21-55.5: Warning (interrupts_property): /paxi/dmac@40000: Missing interrupt-parent
      picoxcell-pc3x2.dtsi:57.21-61.5: Warning (interrupts_property): /paxi/dmac@50000: Missing interrupt-parent
      picoxcell-pc3x2.dtsi:233.21-237.5: Warning (interrupts_property): /rwid-axi/axi2pico@c0000000: Missing interrupt-parent
      
      There are two VIC instances, so it's not clear which one needs to be
      used. I found the BSP sources that reference VIC0, so use that:
      
      https://github.com/r1mikey/meta-picoxcell/blob/master/recipes-kernel/linux/linux-picochip-3.0/0001-picoxcell-support-for-Picochip-picoXcell-SoC.patch
      
      Acked-by: default avatarJamie Iles <jamie@jamieiles.com>
      Link: https://lore.kernel.org/r/20201230152010.3914962-1-arnd@kernel.org
      
      '
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      48d19197
    • Craig Tatlor's avatar
      drm/msm: Call msm_init_vram before binding the gpu · 0680689c
      Craig Tatlor authored
      [ Upstream commit d863f0c7
      
       ]
      
      vram.size is needed when binding a gpu without an iommu and is defined
      in msm_init_vram(), so run that before binding it.
      Signed-off-by: default avatarCraig Tatlor <ctatlor97@gmail.com>
      Reviewed-by: default avatarBrian Masney <masneyb@onstation.org>
      Tested-by: default avatarAlexey Minnekhanov <alexeymin@postmarketos.org>
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0680689c
    • Shawn Guo's avatar
      ACPI: scan: add stub acpi_create_platform_device() for !CONFIG_ACPI · 0635fb42
      Shawn Guo authored
      [ Upstream commit ee61cfd9
      
       ]
      
      It adds a stub acpi_create_platform_device() for !CONFIG_ACPI build, so
      that caller doesn't have to deal with !CONFIG_ACPI build issue.
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarShawn Guo <shawn.guo@linaro.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0635fb42
    • Michael Ellerman's avatar
      net: ethernet: fs_enet: Add missing MODULE_LICENSE · e6029a08
      Michael Ellerman authored
      [ Upstream commit 445c6198 ]
      
      Since commit 1d6cd392
      
       ("modpost: turn missing MODULE_LICENSE()
      into error") the ppc32_allmodconfig build fails with:
      
        ERROR: modpost: missing MODULE_LICENSE() in drivers/net/ethernet/freescale/fs_enet/mii-fec.o
        ERROR: modpost: missing MODULE_LICENSE() in drivers/net/ethernet/freescale/fs_enet/mii-bitbang.o
      
      Add the missing MODULE_LICENSEs to fix the build. Both files include a
      copyright header indicating they are GPL v2.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e6029a08
    • Arnd Bergmann's avatar
      misdn: dsp: select CONFIG_BITREVERSE · dbea1b03
      Arnd Bergmann authored
      [ Upstream commit 51049bd9
      
       ]
      
      Without this, we run into a link error
      
      arm-linux-gnueabi-ld: drivers/isdn/mISDN/dsp_audio.o: in function `dsp_audio_generate_law_tables':
      (.text+0x30c): undefined reference to `byte_rev_table'
      arm-linux-gnueabi-ld: drivers/isdn/mISDN/dsp_audio.o:(.text+0x5e4): more undefined references to `byte_rev_table' follow
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dbea1b03
    • Randy Dunlap's avatar
      arch/arc: add copy_user_page() to <asm/page.h> to fix build error on ARC · cbeb334c
      Randy Dunlap authored
      [ Upstream commit 8a48c0a3
      
       ]
      
      fs/dax.c uses copy_user_page() but ARC does not provide that interface,
      resulting in a build error.
      
      Provide copy_user_page() in <asm/page.h>.
      
      ../fs/dax.c: In function 'copy_cow_page_dax':
      ../fs/dax.c:702:2: error: implicit declaration of function 'copy_user_page'; did you mean 'copy_to_user_page'? [-Werror=implicit-function-declaration]
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: linux-snps-arc@lists.infradead.org
      Cc: Dan Williams <dan.j.williams@intel.com>
      #Acked-by: Vineet Gupta <vgupta@synopsys.com> # v1
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Jan Kara <jack@suse.cz>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: linux-nvdimm@lists.01.org
      #Reviewed-by: Ira Weiny <ira.weiny@intel.com> # v2
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cbeb334c
    • Jan Kara's avatar
      bfq: Fix computation of shallow depth · 9f8b5931
      Jan Kara authored
      [ Upstream commit 6d4d2735
      
       ]
      
      BFQ computes number of tags it allows to be allocated for each request type
      based on tag bitmap. However it uses 1 << bitmap.shift as number of
      available tags which is wrong. 'shift' is just an internal bitmap value
      containing logarithm of how many bits bitmap uses in each bitmap word.
      Thus number of tags allowed for some request types can be far to low.
      Use proper bitmap.depth which has the number of tags instead.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9f8b5931
    • Rasmus Villemoes's avatar
      ethernet: ucc_geth: fix definition and size of ucc_geth_tx_global_pram · 2095b9fc
      Rasmus Villemoes authored
      [ Upstream commit 887078de
      
       ]
      
      Table 8-53 in the QUICC Engine Reference manual shows definitions of
      fields up to a size of 192 bytes, not just 128. But in table 8-111,
      one does find the text
      
        Base Address of the Global Transmitter Parameter RAM Page. [...]
        The user needs to allocate 128 bytes for this page. The address must
        be aligned to the page size.
      
      I've checked both rev. 7 (11/2015) and rev. 9 (05/2018) of the manual;
      they both have this inconsistency (and the table numbers are the
      same).
      
      Adding a bit of debug printing, on my board the struct
      ucc_geth_tx_global_pram is allocated at offset 0x880, while
      the (opaque) ucc_geth_thread_data_tx gets allocated immediately
      afterwards, at 0x900. So whatever the engine writes into the thread
      data overlaps with the tail of the global tx pram (and devmem says
      that something does get written during a simple ping).
      
      I haven't observed any failure that could be attributed to this, but
      it seems to be the kind of thing that would be extremely hard to
      debug. So extend the struct definition so that we do allocate 192
      bytes.
      Signed-off-by: default avatarRasmus Villemoes <rasmus.villemoes@prevas.dk>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2095b9fc
    • Filipe Manana's avatar
      btrfs: fix transaction leak and crash after RO remount caused by qgroup rescan · 46bb14a3
      Filipe Manana authored
      [ Upstream commit cb13eea3
      
       ]
      
      If we remount a filesystem in RO mode while the qgroup rescan worker is
      running, we can end up having it still running after the remount is done,
      and at unmount time we may end up with an open transaction that ends up
      never getting committed. If that happens we end up with several memory
      leaks and can crash when hardware acceleration is unavailable for crc32c.
      Possibly it can lead to other nasty surprises too, due to use-after-free
      issues.
      
      The following steps explain how the problem happens.
      
      1) We have a filesystem mounted in RW mode and the qgroup rescan worker is
         running;
      
      2) We remount the filesystem in RO mode, and never stop/pause the rescan
         worker, so after the remount the rescan worker is still running. The
         important detail here is that the rescan task is still running after
         the remount operation committed any ongoing transaction through its
         call to btrfs_commit_super();
      
      3) The rescan is still running, and after the remount completed, the
         rescan worker started a transaction, after it finished iterating all
         leaves of the extent tree, to update the qgroup status item in the
         quotas tree. It does not commit the transaction, it only releases its
         handle on the transaction;
      
      4) A filesystem unmount operation starts shortly after;
      
      5) The unmount task, at close_ctree(), stops the transaction kthread,
         which had not had a chance to commit the open transaction since it was
         sleeping and the commit interval (default of 30 seconds) has not yet
         elapsed since the last time it committed a transaction;
      
      6) So after stopping the transaction kthread we still have the transaction
         used to update the qgroup status item open. At close_ctree(), when the
         filesystem is in RO mode and no transaction abort happened (or the
         filesystem is in error mode), we do not expect to have any transaction
         open, so we do not call btrfs_commit_super();
      
      7) We then proceed to destroy the work queues, free the roots and block
         groups, etc. After that we drop the last reference on the btree inode
         by calling iput() on it. Since there are dirty pages for the btree
         inode, corresponding to the COWed extent buffer for the quotas btree,
         btree_write_cache_pages() is invoked to flush those dirty pages. This
         results in creating a bio and submitting it, which makes us end up at
         btrfs_submit_metadata_bio();
      
      8) At btrfs_submit_metadata_bio() we end up at the if-then-else branch
         that calls btrfs_wq_submit_bio(), because check_async_write() returned
         a value of 1. This value of 1 is because we did not have hardware
         acceleration available for crc32c, so BTRFS_FS_CSUM_IMPL_FAST was not
         set in fs_info->flags;
      
      9) Then at btrfs_wq_submit_bio() we call btrfs_queue_work() against the
         workqueue at fs_info->workers, which was already freed before by the
         call to btrfs_stop_all_workers() at close_ctree(). This results in an
         invalid memory access due to a use-after-free, leading to a crash.
      
      When this happens, before the crash there are several warnings triggered,
      since we have reserved metadata space in a block group, the delayed refs
      reservation, etc:
      
        ------------[ cut here ]------------
        WARNING: CPU: 4 PID: 1729896 at fs/btrfs/block-group.c:125 btrfs_put_block_group+0x63/0xa0 [btrfs]
        Modules linked in: btrfs dm_snapshot dm_thin_pool (...)
        CPU: 4 PID: 1729896 Comm: umount Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        RIP: 0010:btrfs_put_block_group+0x63/0xa0 [btrfs]
        Code: f0 01 00 00 48 39 c2 75 (...)
        RSP: 0018:ffffb270826bbdd8 EFLAGS: 00010206
        RAX: 0000000000000001 RBX: ffff947ed73e4000 RCX: ffff947ebc8b29c8
        RDX: 0000000000000001 RSI: ffffffffc0b150a0 RDI: ffff947ebc8b2800
        RBP: ffff947ebc8b2800 R08: 0000000000000000 R09: 0000000000000000
        R10: 0000000000000000 R11: 0000000000000001 R12: ffff947ed73e4110
        R13: ffff947ed73e4160 R14: ffff947ebc8b2988 R15: dead000000000100
        FS:  00007f15edfea840(0000) GS:ffff9481ad600000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f37e2893320 CR3: 0000000138f68001 CR4: 00000000003706e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         btrfs_free_block_groups+0x17f/0x2f0 [btrfs]
         close_ctree+0x2ba/0x2fa [btrfs]
         generic_shutdown_super+0x6c/0x100
         kill_anon_super+0x14/0x30
         btrfs_kill_super+0x12/0x20 [btrfs]
         deactivate_locked_super+0x31/0x70
         cleanup_mnt+0x100/0x160
         task_work_run+0x68/0xb0
         exit_to_user_mode_prepare+0x1bb/0x1c0
         syscall_exit_to_user_mode+0x4b/0x260
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f15ee221ee7
        Code: ff 0b 00 f7 d8 64 89 01 48 (...)
        RSP: 002b:00007ffe9470f0f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
        RAX: 0000000000000000 RBX: 00007f15ee347264 RCX: 00007f15ee221ee7
        RDX: ffffffffffffff78 RSI: 0000000000000000 RDI: 000056169701d000
        RBP: 0000561697018a30 R08: 0000000000000000 R09: 00007f15ee2e2be0
        R10: 000056169701efe0 R11: 0000000000000246 R12: 0000000000000000
        R13: 000056169701d000 R14: 0000561697018b40 R15: 0000561697018c60
        irq event stamp: 0
        hardirqs last  enabled at (0): [<0000000000000000>] 0x0
        hardirqs last disabled at (0): [<ffffffff8bcae560>] copy_process+0x8a0/0x1d70
        softirqs last  enabled at (0): [<ffffffff8bcae560>] copy_process+0x8a0/0x1d70
        softirqs last disabled at (0): [<0000000000000000>] 0x0
        ---[ end trace dd74718fef1ed5c6 ]---
        ------------[ cut here ]------------
        WARNING: CPU: 2 PID: 1729896 at fs/btrfs/block-rsv.c:459 btrfs_release_global_block_rsv+0x70/0xc0 [btrfs]
        Modules linked in: btrfs dm_snapshot dm_thin_pool (...)
        CPU: 2 PID: 1729896 Comm: umount Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        RIP: 0010:btrfs_release_global_block_rsv+0x70/0xc0 [btrfs]
        Code: 48 83 bb b0 03 00 00 00 (...)
        RSP: 0018:ffffb270826bbdd8 EFLAGS: 00010206
        RAX: 000000000033c000 RBX: ffff947ed73e4000 RCX: 0000000000000000
        RDX: 0000000000000001 RSI: ffffffffc0b0d8c1 RDI: 00000000ffffffff
        RBP: ffff947ebc8b7000 R08: 0000000000000001 R09: 0000000000000000
        R10: 0000000000000000 R11: 0000000000000001 R12: ffff947ed73e4110
        R13: ffff947ed73e5278 R14: dead000000000122 R15: dead000000000100
        FS:  00007f15edfea840(0000) GS:ffff9481aca00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000561a79f76e20 CR3: 0000000138f68006 CR4: 00000000003706e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         btrfs_free_block_groups+0x24c/0x2f0 [btrfs]
         close_ctree+0x2ba/0x2fa [btrfs]
         generic_shutdown_super+0x6c/0x100
         kill_anon_super+0x14/0x30
         btrfs_kill_super+0x12/0x20 [btrfs]
         deactivate_locked_super+0x31/0x70
         cleanup_mnt+0x100/0x160
         task_work_run+0x68/0xb0
         exit_to_user_mode_prepare+0x1bb/0x1c0
         syscall_exit_to_user_mode+0x4b/0x260
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f15ee221ee7
        Code: ff 0b 00 f7 d8 64 89 01 (...)
        RSP: 002b:00007ffe9470f0f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
        RAX: 0000000000000000 RBX: 00007f15ee347264 RCX: 00007f15ee221ee7
        RDX: ffffffffffffff78 RSI: 0000000000000000 RDI: 000056169701d000
        RBP: 0000561697018a30 R08: 0000000000000000 R09: 00007f15ee2e2be0
        R10: 000056169701efe0 R11: 0000000000000246 R12: 0000000000000000
        R13: 000056169701d000 R14: 0000561697018b40 R15: 0000561697018c60
        irq event stamp: 0
        hardirqs last  enabled at (0): [<0000000000000000>] 0x0
        hardirqs last disabled at (0): [<ffffffff8bcae560>] copy_process+0x8a0/0x1d70
        softirqs last  enabled at (0): [<ffffffff8bcae560>] copy_process+0x8a0/0x1d70
        softirqs last disabled at (0): [<0000000000000000>] 0x0
        ---[ end trace dd74718fef1ed5c7 ]---
        ------------[ cut here ]------------
        WARNING: CPU: 2 PID: 1729896 at fs/btrfs/block-group.c:3377 btrfs_free_block_groups+0x25d/0x2f0 [btrfs]
        Modules linked in: btrfs dm_snapshot dm_thin_pool (...)
        CPU: 5 PID: 1729896 Comm: umount Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        RIP: 0010:btrfs_free_block_groups+0x25d/0x2f0 [btrfs]
        Code: ad de 49 be 22 01 00 (...)
        RSP: 0018:ffffb270826bbde8 EFLAGS: 00010206
        RAX: ffff947ebeae1d08 RBX: ffff947ed73e4000 RCX: 0000000000000000
        RDX: 0000000000000001 RSI: ffff947e9d823ae8 RDI: 0000000000000246
        RBP: ffff947ebeae1d08 R08: 0000000000000000 R09: 0000000000000000
        R10: 0000000000000000 R11: 0000000000000001 R12: ffff947ebeae1c00
        R13: ffff947ed73e5278 R14: dead000000000122 R15: dead000000000100
        FS:  00007f15edfea840(0000) GS:ffff9481ad200000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f1475d98ea8 CR3: 0000000138f68005 CR4: 00000000003706e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         close_ctree+0x2ba/0x2fa [btrfs]
         generic_shutdown_super+0x6c/0x100
         kill_anon_super+0x14/0x30
         btrfs_kill_super+0x12/0x20 [btrfs]
         deactivate_locked_super+0x31/0x70
         cleanup_mnt+0x100/0x160
         task_work_run+0x68/0xb0
         exit_to_user_mode_prepare+0x1bb/0x1c0
         syscall_exit_to_user_mode+0x4b/0x260
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f15ee221ee7
        Code: ff 0b 00 f7 d8 64 89 (...)
        RSP: 002b:00007ffe9470f0f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
        RAX: 0000000000000000 RBX: 00007f15ee347264 RCX: 00007f15ee221ee7
        RDX: ffffffffffffff78 RSI: 0000000000000000 RDI: 000056169701d000
        RBP: 0000561697018a30 R08: 0000000000000000 R09: 00007f15ee2e2be0
        R10: 000056169701efe0 R11: 0000000000000246 R12: 0000000000000000
        R13: 000056169701d000 R14: 0000561697018b40 R15: 0000561697018c60
        irq event stamp: 0
        hardirqs last  enabled at (0): [<0000000000000000>] 0x0
        hardirqs last disabled at (0): [<ffffffff8bcae560>] copy_process+0x8a0/0x1d70
        softirqs last  enabled at (0): [<ffffffff8bcae560>] copy_process+0x8a0/0x1d70
        softirqs last disabled at (0): [<0000000000000000>] 0x0
        ---[ end trace dd74718fef1ed5c8 ]---
        BTRFS info (device sdc): space_info 4 has 268238848 free, is not full
        BTRFS info (device sdc): space_info total=268435456, used=114688, pinned=0, reserved=16384, may_use=0, readonly=65536
        BTRFS info (device sdc): global_block_rsv: size 0 reserved 0
        BTRFS info (device sdc): trans_block_rsv: size 0 reserved 0
        BTRFS info (device sdc): chunk_block_rsv: size 0 reserved 0
        BTRFS info (device sdc): delayed_block_rsv: size 0 reserved 0
        BTRFS info (device sdc): delayed_refs_rsv: size 524288 reserved 0
      
      And the crash, which only happens when we do not have crc32c hardware
      acceleration, produces the following trace immediately after those
      warnings:
      
        stack segment: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC PTI
        CPU: 2 PID: 1749129 Comm: umount Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        RIP: 0010:btrfs_queue_work+0x36/0x190 [btrfs]
        Code: 54 55 53 48 89 f3 (...)
        RSP: 0018:ffffb27082443ae8 EFLAGS: 00010282
        RAX: 0000000000000004 RBX: ffff94810ee9ad90 RCX: 0000000000000000
        RDX: 0000000000000001 RSI: ffff94810ee9ad90 RDI: ffff947ed8ee75a0
        RBP: a56b6b6b6b6b6b6b R08: 0000000000000000 R09: 0000000000000000
        R10: 0000000000000007 R11: 0000000000000001 R12: ffff947fa9b435a8
        R13: ffff94810ee9ad90 R14: 0000000000000000 R15: ffff947e93dc0000
        FS:  00007f3cfe974840(0000) GS:ffff9481ac600000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f1b42995a70 CR3: 0000000127638003 CR4: 00000000003706e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         btrfs_wq_submit_bio+0xb3/0xd0 [btrfs]
         btrfs_submit_metadata_bio+0x44/0xc0 [btrfs]
         submit_one_bio+0x61/0x70 [btrfs]
         btree_write_cache_pages+0x414/0x450 [btrfs]
         ? kobject_put+0x9a/0x1d0
         ? trace_hardirqs_on+0x1b/0xf0
         ? _raw_spin_unlock_irqrestore+0x3c/0x60
         ? free_debug_processing+0x1e1/0x2b0
         do_writepages+0x43/0xe0
         ? lock_acquired+0x199/0x490
         __writeback_single_inode+0x59/0x650
         writeback_single_inode+0xaf/0x120
         write_inode_now+0x94/0xd0
         iput+0x187/0x2b0
         close_ctree+0x2c6/0x2fa [btrfs]
         generic_shutdown_super+0x6c/0x100
         kill_anon_super+0x14/0x30
         btrfs_kill_super+0x12/0x20 [btrfs]
         deactivate_locked_super+0x31/0x70
         cleanup_mnt+0x100/0x160
         task_work_run+0x68/0xb0
         exit_to_user_mode_prepare+0x1bb/0x1c0
         syscall_exit_to_user_mode+0x4b/0x260
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f3cfebabee7
        Code: ff 0b 00 f7 d8 64 89 01 (...)
        RSP: 002b:00007ffc9c9a05f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
        RAX: 0000000000000000 RBX: 00007f3cfecd1264 RCX: 00007f3cfebabee7
        RDX: ffffffffffffff78 RSI: 0000000000000000 RDI: 0000562b6b478000
        RBP: 0000562b6b473a30 R08: 0000000000000000 R09: 00007f3cfec6cbe0
        R10: 0000562b6b479fe0 R11: 0000000000000246 R12: 0000000000000000
        R13: 0000562b6b478000 R14: 0000562b6b473b40 R15: 0000562b6b473c60
        Modules linked in: btrfs dm_snapshot dm_thin_pool (...)
        ---[ end trace dd74718fef1ed5cc ]---
      
      Finally when we remove the btrfs module (rmmod btrfs), there are several
      warnings about objects that were allocated from our slabs but were never
      freed, consequence of the transaction that was never committed and got
      leaked:
      
        =============================================================================
        BUG btrfs_delayed_ref_head (Tainted: G    B   W        ): Objects remaining in btrfs_delayed_ref_head on __kmem_cache_shutdown()
        -----------------------------------------------------------------------------
      
        INFO: Slab 0x0000000094c2ae56 objects=24 used=2 fp=0x000000002bfa2521 flags=0x17fffc000010200
        CPU: 5 PID: 1729921 Comm: rmmod Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        Call Trace:
         dump_stack+0x8d/0xb5
         slab_err+0xb7/0xdc
         ? lock_acquired+0x199/0x490
         __kmem_cache_shutdown+0x1ac/0x3c0
         ? lock_release+0x20e/0x4c0
         kmem_cache_destroy+0x55/0x120
         btrfs_delayed_ref_exit+0x11/0x35 [btrfs]
         exit_btrfs_fs+0xa/0x59 [btrfs]
         __x64_sys_delete_module+0x194/0x260
         ? fpregs_assert_state_consistent+0x1e/0x40
         ? exit_to_user_mode_prepare+0x55/0x1c0
         ? trace_hardirqs_on+0x1b/0xf0
         do_syscall_64+0x33/0x80
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f693e305897
        Code: 73 01 c3 48 8b 0d f9 f5 (...)
        RSP: 002b:00007ffcf73eb508 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
        RAX: ffffffffffffffda RBX: 0000559df504f760 RCX: 00007f693e305897
        RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000559df504f7c8
        RBP: 00007ffcf73eb568 R08: 0000000000000000 R09: 0000000000000000
        R10: 00007f693e378ac0 R11: 0000000000000206 R12: 00007ffcf73eb740
        R13: 00007ffcf73ec5a6 R14: 0000559df504f2a0 R15: 0000559df504f760
        INFO: Object 0x0000000050cbdd61 @offset=12104
        INFO: Allocated in btrfs_add_delayed_tree_ref+0xbb/0x480 [btrfs] age=1894 cpu=6 pid=1729873
      	__slab_alloc.isra.0+0x109/0x1c0
      	kmem_cache_alloc+0x7bb/0x830
      	btrfs_add_delayed_tree_ref+0xbb/0x480 [btrfs]
      	btrfs_free_tree_block+0x128/0x360 [btrfs]
      	__btrfs_cow_block+0x489/0x5f0 [btrfs]
      	btrfs_cow_block+0xf7/0x220 [btrfs]
      	btrfs_search_slot+0x62a/0xc40 [btrfs]
      	btrfs_del_orphan_item+0x65/0xd0 [btrfs]
      	btrfs_find_orphan_roots+0x1bf/0x200 [btrfs]
      	open_ctree+0x125a/0x18a0 [btrfs]
      	btrfs_mount_root.cold+0x13/0xed [btrfs]
      	legacy_get_tree+0x30/0x60
      	vfs_get_tree+0x28/0xe0
      	fc_mount+0xe/0x40
      	vfs_kern_mount.part.0+0x71/0x90
      	btrfs_mount+0x13b/0x3e0 [btrfs]
        INFO: Freed in __btrfs_run_delayed_refs+0x1117/0x1290 [btrfs] age=4292 cpu=2 pid=1729526
      	kmem_cache_free+0x34c/0x3c0
      	__btrfs_run_delayed_refs+0x1117/0x1290 [btrfs]
      	btrfs_run_delayed_refs+0x81/0x210 [btrfs]
      	commit_cowonly_roots+0xfb/0x300 [btrfs]
      	btrfs_commit_transaction+0x367/0xc40 [btrfs]
      	sync_filesystem+0x74/0x90
      	generic_shutdown_super+0x22/0x100
      	kill_anon_super+0x14/0x30
      	btrfs_kill_super+0x12/0x20 [btrfs]
      	deactivate_locked_super+0x31/0x70
      	cleanup_mnt+0x100/0x160
      	task_work_run+0x68/0xb0
      	exit_to_user_mode_prepare+0x1bb/0x1c0
      	syscall_exit_to_user_mode+0x4b/0x260
      	entry_SYSCALL_64_after_hwframe+0x44/0xa9
        INFO: Object 0x0000000086e9b0ff @offset=12776
        INFO: Allocated in btrfs_add_delayed_tree_ref+0xbb/0x480 [btrfs] age=1900 cpu=6 pid=1729873
      	__slab_alloc.isra.0+0x109/0x1c0
      	kmem_cache_alloc+0x7bb/0x830
      	btrfs_add_delayed_tree_ref+0xbb/0x480 [btrfs]
      	btrfs_alloc_tree_block+0x2bf/0x360 [btrfs]
      	alloc_tree_block_no_bg_flush+0x4f/0x60 [btrfs]
      	__btrfs_cow_block+0x12d/0x5f0 [btrfs]
      	btrfs_cow_block+0xf7/0x220 [btrfs]
      	btrfs_search_slot+0x62a/0xc40 [btrfs]
      	btrfs_del_orphan_item+0x65/0xd0 [btrfs]
      	btrfs_find_orphan_roots+0x1bf/0x200 [btrfs]
      	open_ctree+0x125a/0x18a0 [btrfs]
      	btrfs_mount_root.cold+0x13/0xed [btrfs]
      	legacy_get_tree+0x30/0x60
      	vfs_get_tree+0x28/0xe0
      	fc_mount+0xe/0x40
      	vfs_kern_mount.part.0+0x71/0x90
        INFO: Freed in __btrfs_run_delayed_refs+0x1117/0x1290 [btrfs] age=3141 cpu=6 pid=1729803
      	kmem_cache_free+0x34c/0x3c0
      	__btrfs_run_delayed_refs+0x1117/0x1290 [btrfs]
      	btrfs_run_delayed_refs+0x81/0x210 [btrfs]
      	btrfs_write_dirty_block_groups+0x17d/0x3d0 [btrfs]
      	commit_cowonly_roots+0x248/0x300 [btrfs]
      	btrfs_commit_transaction+0x367/0xc40 [btrfs]
      	close_ctree+0x113/0x2fa [btrfs]
      	generic_shutdown_super+0x6c/0x100
      	kill_anon_super+0x14/0x30
      	btrfs_kill_super+0x12/0x20 [btrfs]
      	deactivate_locked_super+0x31/0x70
      	cleanup_mnt+0x100/0x160
      	task_work_run+0x68/0xb0
      	exit_to_user_mode_prepare+0x1bb/0x1c0
      	syscall_exit_to_user_mode+0x4b/0x260
      	entry_SYSCALL_64_after_hwframe+0x44/0xa9
        kmem_cache_destroy btrfs_delayed_ref_head: Slab cache still has objects
        CPU: 5 PID: 1729921 Comm: rmmod Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        Call Trace:
         dump_stack+0x8d/0xb5
         kmem_cache_destroy+0x119/0x120
         btrfs_delayed_ref_exit+0x11/0x35 [btrfs]
         exit_btrfs_fs+0xa/0x59 [btrfs]
         __x64_sys_delete_module+0x194/0x260
         ? fpregs_assert_state_consistent+0x1e/0x40
         ? exit_to_user_mode_prepare+0x55/0x1c0
         ? trace_hardirqs_on+0x1b/0xf0
         do_syscall_64+0x33/0x80
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f693e305897
        Code: 73 01 c3 48 8b 0d f9 f5 0b (...)
        RSP: 002b:00007ffcf73eb508 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
        RAX: ffffffffffffffda RBX: 0000559df504f760 RCX: 00007f693e305897
        RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000559df504f7c8
        RBP: 00007ffcf73eb568 R08: 0000000000000000 R09: 0000000000000000
        R10: 00007f693e378ac0 R11: 0000000000000206 R12: 00007ffcf73eb740
        R13: 00007ffcf73ec5a6 R14: 0000559df504f2a0 R15: 0000559df504f760
        =============================================================================
        BUG btrfs_delayed_tree_ref (Tainted: G    B   W        ): Objects remaining in btrfs_delayed_tree_ref on __kmem_cache_shutdown()
        -----------------------------------------------------------------------------
      
        INFO: Slab 0x0000000011f78dc0 objects=37 used=2 fp=0x0000000032d55d91 flags=0x17fffc000010200
        CPU: 3 PID: 1729921 Comm: rmmod Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        Call Trace:
         dump_stack+0x8d/0xb5
         slab_err+0xb7/0xdc
         ? lock_acquired+0x199/0x490
         __kmem_cache_shutdown+0x1ac/0x3c0
         ? lock_release+0x20e/0x4c0
         kmem_cache_destroy+0x55/0x120
         btrfs_delayed_ref_exit+0x1d/0x35 [btrfs]
         exit_btrfs_fs+0xa/0x59 [btrfs]
         __x64_sys_delete_module+0x194/0x260
         ? fpregs_assert_state_consistent+0x1e/0x40
         ? exit_to_user_mode_prepare+0x55/0x1c0
         ? trace_hardirqs_on+0x1b/0xf0
         do_syscall_64+0x33/0x80
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f693e305897
        Code: 73 01 c3 48 8b 0d f9 f5 (...)
        RSP: 002b:00007ffcf73eb508 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
        RAX: ffffffffffffffda RBX: 0000559df504f760 RCX: 00007f693e305897
        RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000559df504f7c8
        RBP: 00007ffcf73eb568 R08: 0000000000000000 R09: 0000000000000000
        R10: 00007f693e378ac0 R11: 0000000000000206 R12: 00007ffcf73eb740
        R13: 00007ffcf73ec5a6 R14: 0000559df504f2a0 R15: 0000559df504f760
        INFO: Object 0x000000001a340018 @offset=4408
        INFO: Allocated in btrfs_add_delayed_tree_ref+0x9e/0x480 [btrfs] age=1917 cpu=6 pid=1729873
      	__slab_alloc.isra.0+0x109/0x1c0
      	kmem_cache_alloc+0x7bb/0x830
      	btrfs_add_delayed_tree_ref+0x9e/0x480 [btrfs]
      	btrfs_free_tree_block+0x128/0x360 [btrfs]
      	__btrfs_cow_block+0x489/0x5f0 [btrfs]
      	btrfs_cow_block+0xf7/0x220 [btrfs]
      	btrfs_search_slot+0x62a/0xc40 [btrfs]
      	btrfs_del_orphan_item+0x65/0xd0 [btrfs]
      	btrfs_find_orphan_roots+0x1bf/0x200 [btrfs]
      	open_ctree+0x125a/0x18a0 [btrfs]
      	btrfs_mount_root.cold+0x13/0xed [btrfs]
      	legacy_get_tree+0x30/0x60
      	vfs_get_tree+0x28/0xe0
      	fc_mount+0xe/0x40
      	vfs_kern_mount.part.0+0x71/0x90
      	btrfs_mount+0x13b/0x3e0 [btrfs]
        INFO: Freed in __btrfs_run_delayed_refs+0x63d/0x1290 [btrfs] age=4167 cpu=4 pid=1729795
      	kmem_cache_free+0x34c/0x3c0
      	__btrfs_run_delayed_refs+0x63d/0x1290 [btrfs]
      	btrfs_run_delayed_refs+0x81/0x210 [btrfs]
      	btrfs_commit_transaction+0x60/0xc40 [btrfs]
      	create_subvol+0x56a/0x990 [btrfs]
      	btrfs_mksubvol+0x3fb/0x4a0 [btrfs]
      	__btrfs_ioctl_snap_create+0x119/0x1a0 [btrfs]
      	btrfs_ioctl_snap_create+0x58/0x80 [btrfs]
      	btrfs_ioctl+0x1a92/0x36f0 [btrfs]
      	__x64_sys_ioctl+0x83/0xb0
      	do_syscall_64+0x33/0x80
      	entry_SYSCALL_64_after_hwframe+0x44/0xa9
        INFO: Object 0x000000002b46292a @offset=13648
        INFO: Allocated in btrfs_add_delayed_tree_ref+0x9e/0x480 [btrfs] age=1923 cpu=6 pid=1729873
      	__slab_alloc.isra.0+0x109/0x1c0
      	kmem_cache_alloc+0x7bb/0x830
      	btrfs_add_delayed_tree_ref+0x9e/0x480 [btrfs]
      	btrfs_alloc_tree_block+0x2bf/0x360 [btrfs]
      	alloc_tree_block_no_bg_flush+0x4f/0x60 [btrfs]
      	__btrfs_cow_block+0x12d/0x5f0 [btrfs]
      	btrfs_cow_block+0xf7/0x220 [btrfs]
      	btrfs_search_slot+0x62a/0xc40 [btrfs]
      	btrfs_del_orphan_item+0x65/0xd0 [btrfs]
      	btrfs_find_orphan_roots+0x1bf/0x200 [btrfs]
      	open_ctree+0x125a/0x18a0 [btrfs]
      	btrfs_mount_root.cold+0x13/0xed [btrfs]
      	legacy_get_tree+0x30/0x60
      	vfs_get_tree+0x28/0xe0
      	fc_mount+0xe/0x40
      	vfs_kern_mount.part.0+0x71/0x90
        INFO: Freed in __btrfs_run_delayed_refs+0x63d/0x1290 [btrfs] age=3164 cpu=6 pid=1729803
      	kmem_cache_free+0x34c/0x3c0
      	__btrfs_run_delayed_refs+0x63d/0x1290 [btrfs]
      	btrfs_run_delayed_refs+0x81/0x210 [btrfs]
      	commit_cowonly_roots+0xfb/0x300 [btrfs]
      	btrfs_commit_transaction+0x367/0xc40 [btrfs]
      	close_ctree+0x113/0x2fa [btrfs]
      	generic_shutdown_super+0x6c/0x100
      	kill_anon_super+0x14/0x30
      	btrfs_kill_super+0x12/0x20 [btrfs]
      	deactivate_locked_super+0x31/0x70
      	cleanup_mnt+0x100/0x160
      	task_work_run+0x68/0xb0
      	exit_to_user_mode_prepare+0x1bb/0x1c0
      	syscall_exit_to_user_mode+0x4b/0x260
      	entry_SYSCALL_64_after_hwframe+0x44/0xa9
        kmem_cache_destroy btrfs_delayed_tree_ref: Slab cache still has objects
        CPU: 5 PID: 1729921 Comm: rmmod Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        Call Trace:
         dump_stack+0x8d/0xb5
         kmem_cache_destroy+0x119/0x120
         btrfs_delayed_ref_exit+0x1d/0x35 [btrfs]
         exit_btrfs_fs+0xa/0x59 [btrfs]
         __x64_sys_delete_module+0x194/0x260
         ? fpregs_assert_state_consistent+0x1e/0x40
         ? exit_to_user_mode_prepare+0x55/0x1c0
         ? trace_hardirqs_on+0x1b/0xf0
         do_syscall_64+0x33/0x80
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f693e305897
        Code: 73 01 c3 48 8b 0d f9 f5 (...)
        RSP: 002b:00007ffcf73eb508 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
        RAX: ffffffffffffffda RBX: 0000559df504f760 RCX: 00007f693e305897
        RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000559df504f7c8
        RBP: 00007ffcf73eb568 R08: 0000000000000000 R09: 0000000000000000
        R10: 00007f693e378ac0 R11: 0000000000000206 R12: 00007ffcf73eb740
        R13: 00007ffcf73ec5a6 R14: 0000559df504f2a0 R15: 0000559df504f760
        =============================================================================
        BUG btrfs_delayed_extent_op (Tainted: G    B   W        ): Objects remaining in btrfs_delayed_extent_op on __kmem_cache_shutdown()
        -----------------------------------------------------------------------------
      
        INFO: Slab 0x00000000f145ce2f objects=22 used=1 fp=0x00000000af0f92cf flags=0x17fffc000010200
        CPU: 5 PID: 1729921 Comm: rmmod Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        Call Trace:
         dump_stack+0x8d/0xb5
         slab_err+0xb7/0xdc
         ? lock_acquired+0x199/0x490
         __kmem_cache_shutdown+0x1ac/0x3c0
         ? __mutex_unlock_slowpath+0x45/0x2a0
         kmem_cache_destroy+0x55/0x120
         exit_btrfs_fs+0xa/0x59 [btrfs]
         __x64_sys_delete_module+0x194/0x260
         ? fpregs_assert_state_consistent+0x1e/0x40
         ? exit_to_user_mode_prepare+0x55/0x1c0
         ? trace_hardirqs_on+0x1b/0xf0
         do_syscall_64+0x33/0x80
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f693e305897
        Code: 73 01 c3 48 8b 0d f9 f5 (...)
        RSP: 002b:00007ffcf73eb508 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
        RAX: ffffffffffffffda RBX: 0000559df504f760 RCX: 00007f693e305897
        RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000559df504f7c8
        RBP: 00007ffcf73eb568 R08: 0000000000000000 R09: 0000000000000000
        R10: 00007f693e378ac0 R11: 0000000000000206 R12: 00007ffcf73eb740
        R13: 00007ffcf73ec5a6 R14: 0000559df504f2a0 R15: 0000559df504f760
        INFO: Object 0x000000004cf95ea8 @offset=6264
        INFO: Allocated in btrfs_alloc_tree_block+0x1e0/0x360 [btrfs] age=1931 cpu=6 pid=1729873
      	__slab_alloc.isra.0+0x109/0x1c0
      	kmem_cache_alloc+0x7bb/0x830
      	btrfs_alloc_tree_block+0x1e0/0x360 [btrfs]
      	alloc_tree_block_no_bg_flush+0x4f/0x60 [btrfs]
      	__btrfs_cow_block+0x12d/0x5f0 [btrfs]
      	btrfs_cow_block+0xf7/0x220 [btrfs]
      	btrfs_search_slot+0x62a/0xc40 [btrfs]
      	btrfs_del_orphan_item+0x65/0xd0 [btrfs]
      	btrfs_find_orphan_roots+0x1bf/0x200 [btrfs]
      	open_ctree+0x125a/0x18a0 [btrfs]
      	btrfs_mount_root.cold+0x13/0xed [btrfs]
      	legacy_get_tree+0x30/0x60
      	vfs_get_tree+0x28/0xe0
      	fc_mount+0xe/0x40
      	vfs_kern_mount.part.0+0x71/0x90
      	btrfs_mount+0x13b/0x3e0 [btrfs]
        INFO: Freed in __btrfs_run_delayed_refs+0xabd/0x1290 [btrfs] age=3173 cpu=6 pid=1729803
      	kmem_cache_free+0x34c/0x3c0
      	__btrfs_run_delayed_refs+0xabd/0x1290 [btrfs]
      	btrfs_run_delayed_refs+0x81/0x210 [btrfs]
      	commit_cowonly_roots+0xfb/0x300 [btrfs]
      	btrfs_commit_transaction+0x367/0xc40 [btrfs]
      	close_ctree+0x113/0x2fa [btrfs]
      	generic_shutdown_super+0x6c/0x100
      	kill_anon_super+0x14/0x30
      	btrfs_kill_super+0x12/0x20 [btrfs]
      	deactivate_locked_super+0x31/0x70
      	cleanup_mnt+0x100/0x160
      	task_work_run+0x68/0xb0
      	exit_to_user_mode_prepare+0x1bb/0x1c0
      	syscall_exit_to_user_mode+0x4b/0x260
      	entry_SYSCALL_64_after_hwframe+0x44/0xa9
        kmem_cache_destroy btrfs_delayed_extent_op: Slab cache still has objects
        CPU: 3 PID: 1729921 Comm: rmmod Tainted: G    B   W         5.10.0-rc4-btrfs-next-73 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        Call Trace:
         dump_stack+0x8d/0xb5
         kmem_cache_destroy+0x119/0x120
         exit_btrfs_fs+0xa/0x59 [btrfs]
         __x64_sys_delete_module+0x194/0x260
         ? fpregs_assert_state_consistent+0x1e/0x40
         ? exit_to_user_mode_prepare+0x55/0x1c0
         ? trace_hardirqs_on+0x1b/0xf0
         do_syscall_64+0x33/0x80
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f693e305897
        Code: 73 01 c3 48 8b 0d f9 (...)
        RSP: 002b:00007ffcf73eb508 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
        RAX: ffffffffffffffda RBX: 0000559df504f760 RCX: 00007f693e305897
        RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000559df504f7c8
        RBP: 00007ffcf73eb568 R08: 0000000000000000 R09: 0000000000000000
        R10: 00007f693e378ac0 R11: 0000000000000206 R12: 00007ffcf73eb740
        R13: 00007ffcf73ec5a6 R14: 0000559df504f2a0 R15: 0000559df504f760
        BTRFS: state leak: start 30408704 end 30425087 state 1 in tree 1 refs 1
      
      Fix this issue by having the remount path stop the qgroup rescan worker
      when we are remounting RO and teach the rescan worker to stop when a
      remount is in progress. If later a remount in RW mode happens, we are
      already resuming the qgroup rescan worker through the call to
      btrfs_qgroup_rescan_resume(), so we do not need to worry about that.
      Tested-by: default avatarFabian Vogt <fvogt@suse.com>
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      46bb14a3
    • Masahiro Yamada's avatar
      ARC: build: add boot_targets to PHONY · 14791a72
      Masahiro Yamada authored
      [ Upstream commit 0cfccb3c
      
       ]
      
      The top-level boot_targets (uImage and uImage.*) should be phony
      targets. They just let Kbuild descend into arch/arc/boot/ and create
      files there.
      
      If a file exists in the top directory with the same name, the boot
      image will not be created.
      
      You can confirm it by the following steps:
      
        $ export CROSS_COMPILE=<your-arc-compiler-prefix>
        $ make -s ARCH=arc defconfig all   # vmlinux will be built
        $ touch uImage.gz
        $ make ARCH=arc uImage.gz
        CALL    scripts/atomic/check-atomics.sh
        CALL    scripts/checksyscalls.sh
        CHK     include/generated/compile.h
        # arch/arc/boot/uImage.gz is not created
      
      Specify the targets as PHONY to fix this.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      14791a72
    • Masahiro Yamada's avatar
      ARC: build: add uImage.lzma to the top-level target · d0613d2e
      Masahiro Yamada authored
      [ Upstream commit f2712ec7
      
       ]
      
      arch/arc/boot/Makefile supports uImage.lzma, but you cannot do
      'make uImage.lzma' because the corresponding target is missing
      in arch/arc/Makefile. Add it.
      
      I also changed the assignment operator '+=' to ':=' since this is the
      only place where we expect this variable to be set.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d0613d2e
    • Masahiro Yamada's avatar
      ARC: build: remove non-existing bootpImage from KBUILD_IMAGE · 7d66065e
      Masahiro Yamada authored
      [ Upstream commit 98367209
      
       ]
      
      The deb-pkg builds for ARCH=arc fail.
      
        $ export CROSS_COMPILE=<your-arc-compiler-prefix>
        $ make -s ARCH=arc defconfig
        $ make ARCH=arc bindeb-pkg
        SORTTAB vmlinux
        SYSMAP  System.map
        MODPOST Module.symvers
        make KERNELRELEASE=5.10.0-rc4 ARCH=arc KBUILD_BUILD_VERSION=2 -f ./Makefile intdeb-pkg
        sh ./scripts/package/builddeb
        cp: cannot stat 'arch/arc/boot/bootpImage': No such file or directory
        make[4]: *** [scripts/Makefile.package:87: intdeb-pkg] Error 1
        make[3]: *** [Makefile:1527: intdeb-pkg] Error 2
        make[2]: *** [debian/rules:13: binary-arch] Error 2
        dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
        make[1]: *** [scripts/Makefile.package:83: bindeb-pkg] Error 2
        make: *** [Makefile:1527: bindeb-pkg] Error 2
      
      The reason is obvious; arch/arc/Makefile sets $(boot)/bootpImage as
      the default image, but there is no rule to build it.
      
      Remove the meaningless KBUILD_IMAGE assignment so it will fallback
      to the default vmlinux. With this change, you can build the deb package.
      
      I removed the 'bootpImage' target as well. At best, it provides
      'make bootpImage' as an alias of 'make vmlinux', but I do not see
      much sense in doing so.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7d66065e
    • yangerkun's avatar
      ext4: fix bug for rename with RENAME_WHITEOUT · de12ae61
      yangerkun authored
      [ Upstream commit 6b4b8e6b
      
       ]
      
      We got a "deleted inode referenced" warning cross our fsstress test. The
      bug can be reproduced easily with following steps:
      
        cd /dev/shm
        mkdir test/
        fallocate -l 128M img
        mkfs.ext4 -b 1024 img
        mount img test/
        dd if=/dev/zero of=test/foo bs=1M count=128
        mkdir test/dir/ && cd test/dir/
        for ((i=0;i<1000;i++)); do touch file$i; done # consume all block
        cd ~ && renameat2(AT_FDCWD, /dev/shm/test/dir/file1, AT_FDCWD,
          /dev/shm/test/dir/dst_file, RENAME_WHITEOUT) # ext4_add_entry in
          ext4_rename will return ENOSPC!!
        cd /dev/shm/ && umount test/ && mount img test/ && ls -li test/dir/file1
        We will get the output:
        "ls: cannot access 'test/dir/file1': Structure needs cleaning"
        and the dmesg show:
        "EXT4-fs error (device loop0): ext4_lookup:1626: inode #2049: comm ls:
        deleted inode referenced: 139"
      
      ext4_rename will create a special inode for whiteout and use this 'ino'
      to replace the source file's dir entry 'ino'. Once error happens
      latter(the error above was the ENOSPC return from ext4_add_entry in
      ext4_rename since all space has been consumed), the cleanup do drop the
      nlink for whiteout, but forget to restore 'ino' with source file. This
      will trigger the bug describle as above.
      Signed-off-by: default avataryangerkun <yangerkun@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: stable@vger.kernel.org
      Fixes: cd808dec ("ext4: support RENAME_WHITEOUT")
      Link: https://lore.kernel.org/r/20210105062857.3566-1-yangerkun@huawei.com
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      de12ae61
    • Leon Schuermann's avatar
      r8152: Add Lenovo Powered USB-C Travel Hub · e04f28c7
      Leon Schuermann authored
      commit cb82a549
      
       upstream.
      
      This USB-C Hub (17ef:721e) based on the Realtek RTL8153B chip used to
      use the cdc_ether driver. However, using this driver, with the system
      suspended the device constantly sends pause-frames as soon as the
      receive buffer fills up. This causes issues with other devices, where
      some Ethernet switches stop forwarding packets altogether.
      
      Using the Realtek driver (r8152) fixes this issue. Pause frames are no
      longer sent while the host system is suspended.
      Signed-off-by: default avatarLeon Schuermann <leon@is.currently.online>
      Tested-by: default avatarLeon Schuermann <leon@is.currently.online>
      Link: https://lore.kernel.org/r/20210111190312.12589-2-leon@is.currently.online
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e04f28c7
    • Mikulas Patocka's avatar
      dm integrity: fix the maximum number of arguments · dd712c8f
      Mikulas Patocka authored
      commit 17ffc193 upstream.
      
      Advance the maximum number of arguments from 9 to 15 to account for
      all potential feature flags that may be supplied.
      
      Linux 4.19 added "meta_device"
      (356d9d52) and "recalculate"
      (a3fcf725) flags.
      
      Commit 468dfca3 added
      "sectors_per_bit" and "bitmap_flush_interval".
      
      Commit 84597a44 added
      "allow_discards".
      
      And the commit d537858a
      
       added
      "fix_padding".
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd712c8f
    • Akilesh Kailash's avatar
      dm snapshot: flush merged data before committing metadata · aef593d2
      Akilesh Kailash authored
      commit fcc42338
      
       upstream.
      
      If the origin device has a volatile write-back cache and the following
      events occur:
      
      1: After finishing merge operation of one set of exceptions,
         merge_callback() is invoked.
      2: Update the metadata in COW device tracking the merge completion.
         This update to COW device is flushed cleanly.
      3: System crashes and the origin device's cache where the recent
         merge was completed has not been flushed.
      
      During the next cycle when we read the metadata from the COW device,
      we will skip reading those metadata whose merge was completed in
      step (1). This will lead to data loss/corruption.
      
      To address this, flush the origin device post merge IO before
      updating the metadata.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAkilesh Kailash <akailash@google.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aef593d2
    • Miaohe Lin's avatar
      mm/hugetlb: fix potential missing huge page size info · bba1a0da
      Miaohe Lin authored
      commit 0eb98f15 upstream.
      
      The huge page size is encoded for VM_FAULT_HWPOISON errors only.  So if
      we return VM_FAULT_HWPOISON, huge page size would just be ignored.
      
      Link: https://lkml.kernel.org/r/20210107123449.38481-1-linmiaohe@huawei.com
      Fixes: aa50d3a7
      
       ("Encode huge page size for VM_FAULT_HWPOISON errors")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bba1a0da
    • Dexuan Cui's avatar
      ACPI: scan: Harden acpi_device_add() against device ID overflows · 56d772d8
      Dexuan Cui authored
      commit a58015d6 upstream.
      
      Linux VM on Hyper-V crashes with the latest mainline:
      
      [    4.069624] detected buffer overflow in strcpy
      [    4.077733] kernel BUG at lib/string.c:1149!
      ..
      [    4.085819] RIP: 0010:fortify_panic+0xf/0x11
      ...
      [    4.085819] Call Trace:
      [    4.085819]  acpi_device_add.cold.15+0xf2/0xfb
      [    4.085819]  acpi_add_single_object+0x2a6/0x690
      [    4.085819]  acpi_bus_check_add+0xc6/0x280
      [    4.085819]  acpi_ns_walk_namespace+0xda/0x1aa
      [    4.085819]  acpi_walk_namespace+0x9a/0xc2
      [    4.085819]  acpi_bus_scan+0x78/0x90
      [    4.085819]  acpi_scan_init+0xfa/0x248
      [    4.085819]  acpi_init+0x2c1/0x321
      [    4.085819]  do_one_initcall+0x44/0x1d0
      [    4.085819]  kernel_init_freeable+0x1ab/0x1f4
      
      This is because of the recent buffer overflow detection in the
      commit 6a39e62a ("lib: string.h: detect intra-object overflow in
      fortified string functions")
      
      Here acpi_device_bus_id->bus_id can only hold 14 characters, while the
      the acpi_device_hid(device) returns a 22-char string
      "HYPER_V_GEN_COUNTER_V1".
      
      Per ACPI Spec v6.2, Section 6.1.5 _HID (Hardware ID), if the ID is a
      string, it must be of the form AAA#### or NNNN####, i.e. 7 chars or 8
      chars.
      
      The field bus_id in struct acpi_device_bus_id was originally defined as
      char bus_id[9], and later was enlarged to char bus_id[15] in 2007 in the
      commit bb095854
      
       ("ACPI: use more understandable bus_id for ACPI
      devices")
      
      Fix the issue by changing the field bus_id to const char *, and use
      kstrdup_const() to initialize it.
      Signed-off-by: default avatarDexuan Cui <decui@microsoft.com>
      Tested-By: default avatarJethro Beekman <jethro@fortanix.com>
      [ rjw: Subject change, whitespace adjustment ]
      Cc: All applicable <stable@vger.kernel.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      56d772d8
    • Alexander Lobakin's avatar
      MIPS: relocatable: fix possible boot hangup with KASLR enabled · 0e488a17
      Alexander Lobakin authored
      commit 69e97683 upstream.
      
      LLVM-built Linux triggered a boot hangup with KASLR enabled.
      
      arch/mips/kernel/relocate.c:get_random_boot() uses linux_banner,
      which is a string constant, as a random seed, but accesses it
      as an array of unsigned long (in rotate_xor()).
      When the address of linux_banner is not aligned to sizeof(long),
      such access emits unaligned access exception and hangs the kernel.
      
      Use PTR_ALIGN() to align input address to sizeof(long) and also
      align down the input length to prevent possible access-beyond-end.
      
      Fixes: 405bc8fd
      
       ("MIPS: Kernel: Implement KASLR using CONFIG_RELOCATABLE")
      Cc: stable@vger.kernel.org # 4.7+
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Tested-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e488a17
    • Paul Cercueil's avatar
      MIPS: boot: Fix unaligned access with CONFIG_MIPS_RAW_APPENDED_DTB · cb735b01
      Paul Cercueil authored
      commit 4d4f9c1a upstream.
      
      The compressed payload is not necesarily 4-byte aligned, at least when
      compiling with Clang. In that case, the 4-byte value appended to the
      compressed payload that corresponds to the uncompressed kernel image
      size must be read using get_unaligned_le32().
      
      This fixes Clang-built kernels not booting on MIPS (tested on a Ingenic
      JZ4770 board).
      
      Fixes: b8f54f2c
      
       ("MIPS: ZBOOT: copy appended dtb to the end of the kernel")
      Cc: <stable@vger.kernel.org> # v4.7
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb735b01