1. 26 5月, 2019 12 次提交
  2. 22 5月, 2019 28 次提交
    • D
      libnvdimm/namespace: Fix label tracking error · 866f0111
      Dan Williams 提交于
      commit c4703ce11c23423d4b46e3d59aef7979814fd608 upstream.
      
      Users have reported intermittent occurrences of DIMM initialization
      failures due to duplicate allocations of address capacity detected in
      the labels, or errors of the form below, both have the same root cause.
      
          nd namespace1.4: failed to track label: 0
          WARNING: CPU: 17 PID: 1381 at drivers/nvdimm/label.c:863
      
          RIP: 0010:__pmem_label_update+0x56c/0x590 [libnvdimm]
          Call Trace:
           ? nd_pmem_namespace_label_update+0xd6/0x160 [libnvdimm]
           nd_pmem_namespace_label_update+0xd6/0x160 [libnvdimm]
           uuid_store+0x17e/0x190 [libnvdimm]
           kernfs_fop_write+0xf0/0x1a0
           vfs_write+0xb7/0x1b0
           ksys_write+0x57/0xd0
           do_syscall_64+0x60/0x210
      
      Unfortunately those reports were typically with a busy parallel
      namespace creation / destruction loop making it difficult to see the
      components of the bug. However, Jane provided a simple reproducer using
      the work-in-progress sub-section implementation.
      
      When ndctl is reconfiguring a namespace it may take an existing defunct
      / disabled namespace and reconfigure it with a new uuid and other
      parameters. Critically namespace_update_uuid() takes existing address
      resources and renames them for the new namespace to use / reconfigure as
      it sees fit. The bug is that this rename only happens in the resource
      tracking tree. Existing labels with the old uuid are not reaped leading
      to a scenario where multiple active labels reference the same span of
      address range.
      
      Teach namespace_update_uuid() to flag any references to the old uuid for
      reaping at the next label update attempt.
      
      Cc: <stable@vger.kernel.org>
      Fixes: bf9bccc1 ("libnvdimm: pmem label sets and namespace instantiation")
      Link: https://github.com/pmem/ndctl/issues/91Reported-by: NJane Chu <jane.chu@oracle.com>
      Reported-by: NJeff Moyer <jmoyer@redhat.com>
      Reported-by: NErwin Tsaur <erwin.tsaur@oracle.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      866f0111
    • A
      tty: Don't force RISCV SBI console as preferred console · c907ce3f
      Anup Patel 提交于
      commit f91253a3d005796404ae0e578b3394459b5f9b71 upstream.
      
      The Linux kernel will auto-disables all boot consoles whenever it
      gets a preferred real console.
      
      Currently on RISC-V systems, if we have a real console which is not
      RISCV SBI console then boot consoles (such as earlycon=sbi) are not
      auto-disabled when a real console (ttyS0 or ttySIF0) is available.
      This results in duplicate prints at boot-time after kernel starts
      using real console (i.e. ttyS0 or ttySIF0) if "earlycon=" kernel
      parameter was passed by bootloader.
      
      The reason for above issue is that RISCV SBI console always adds
      itself as preferred console which is causing other real consoles
      to be not used as preferred console.
      
      Ideally "console=" kernel parameter passed by bootloaders should
      be the one selecting a preferred real console.
      
      This patch fixes above issue by not forcing RISCV SBI console as
      preferred console.
      
      Fixes: afa6b1cc ("tty: New RISC-V SBI console driver")
      Cc: stable@vger.kernel.org
      Signed-off-by: NAnup Patel <anup.patel@wdc.com>
      Reviewed-by: NAtish Patra <atish.patra@wdc.com>
      Signed-off-by: NPalmer Dabbelt <palmer@sifive.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c907ce3f
    • K
      ipmi:ssif: compare block number correctly for multi-part return messages · f6de0a3b
      Kamlakant Patel 提交于
      commit 55be8658c7e2feb11a5b5b33ee031791dbd23a69 upstream.
      
      According to ipmi spec, block number is a number that is incremented,
      starting with 0, for each new block of message data returned using the
      middle transaction.
      
      Here, the 'blocknum' is data[0] which always starts from zero(0) and
      'ssif_info->multi_pos' starts from 1.
      So, we need to add +1 to blocknum while comparing with multi_pos.
      
      Fixes: 7d6380cd40f79 ("ipmi:ssif: Fix handling of multi-part return messages").
      Reported-by: NKiran Kolukuluru <kirank@ami.com>
      Signed-off-by: NKamlakant Patel <kamlakantp@marvell.com>
      Message-Id: <1556106615-18722-1-git-send-email-kamlakantp@marvell.com>
      [Also added a debug log if the block numbers don't match.]
      Signed-off-by: NCorey Minyard <cminyard@mvista.com>
      Cc: stable@vger.kernel.org # 4.4
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f6de0a3b
    • C
      bcache: never set KEY_PTRS of journal key to 0 in journal_reclaim() · 88681649
      Coly Li 提交于
      commit 1bee2addc0c8470c8aaa65ef0599eeae96dd88bc upstream.
      
      In journal_reclaim() ja->cur_idx of each cache will be update to
      reclaim available journal buckets. Variable 'int n' is used to count how
      many cache is successfully reclaimed, then n is set to c->journal.key
      by SET_KEY_PTRS(). Later in journal_write_unlocked(), a for_each_cache()
      loop will write the jset data onto each cache.
      
      The problem is, if all jouranl buckets on each cache is full, the
      following code in journal_reclaim(),
      
      529 for_each_cache(ca, c, iter) {
      530       struct journal_device *ja = &ca->journal;
      531       unsigned int next = (ja->cur_idx + 1) % ca->sb.njournal_buckets;
      532
      533       /* No space available on this device */
      534       if (next == ja->discard_idx)
      535               continue;
      536
      537       ja->cur_idx = next;
      538       k->ptr[n++] = MAKE_PTR(0,
      539                         bucket_to_sector(c, ca->sb.d[ja->cur_idx]),
      540                         ca->sb.nr_this_dev);
      541 }
      542
      543 bkey_init(k);
      544 SET_KEY_PTRS(k, n);
      
      If there is no available bucket to reclaim, the if() condition at line
      534 will always true, and n remains 0. Then at line 544, SET_KEY_PTRS()
      will set KEY_PTRS field of c->journal.key to 0.
      
      Setting KEY_PTRS field of c->journal.key to 0 is wrong. Because in
      journal_write_unlocked() the journal data is written in following loop,
      
      649	for (i = 0; i < KEY_PTRS(k); i++) {
      650-671		submit journal data to cache device
      672	}
      
      If KEY_PTRS field is set to 0 in jouranl_reclaim(), the journal data
      won't be written to cache device here. If system crahed or rebooted
      before bkeys of the lost journal entries written into btree nodes, data
      corruption will be reported during bcache reload after rebooting the
      system.
      
      Indeed there is only one cache in a cache set, there is no need to set
      KEY_PTRS field in journal_reclaim() at all. But in order to keep the
      for_each_cache() logic consistent for now, this patch fixes the above
      problem by not setting 0 KEY_PTRS of journal key, if there is no bucket
      available to reclaim.
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      88681649
    • L
      bcache: fix a race between cache register and cacheset unregister · ecfc882f
      Liang Chen 提交于
      commit a4b732a248d12cbdb46999daf0bf288c011335eb upstream.
      
      There is a race between cache device register and cache set unregister.
      For an already registered cache device, register_bcache will call
      bch_is_open to iterate through all cachesets and check every cache
      there. The race occurs if cache_set_free executes at the same time and
      clears the caches right before ca is dereferenced in bch_is_open_cache.
      To close the race, let's make sure the clean up work is protected by
      the bch_register_lock as well.
      
      This issue can be reproduced as follows,
      while true; do echo /dev/XXX> /sys/fs/bcache/register ; done&
      while true; do echo 1> /sys/block/XXX/bcache/set/unregister ; done &
      
      and results in the following oops,
      
      [  +0.000053] BUG: unable to handle kernel NULL pointer dereference at 0000000000000998
      [  +0.000457] #PF error: [normal kernel read fault]
      [  +0.000464] PGD 800000003ca9d067 P4D 800000003ca9d067 PUD 3ca9c067 PMD 0
      [  +0.000388] Oops: 0000 [#1] SMP PTI
      [  +0.000269] CPU: 1 PID: 3266 Comm: bash Not tainted 5.0.0+ #6
      [  +0.000346] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.fc28 04/01/2014
      [  +0.000472] RIP: 0010:register_bcache+0x1829/0x1990 [bcache]
      [  +0.000344] Code: b0 48 83 e8 50 48 81 fa e0 e1 10 c0 0f 84 a9 00 00 00 48 89 c6 48 89 ca 0f b7 ba 54 04 00 00 4c 8b 82 60 0c 00 00 85 ff 74 2f <49> 3b a8 98 09 00 00 74 4e 44 8d 47 ff 31 ff 49 c1 e0 03 eb 0d
      [  +0.000839] RSP: 0018:ffff92ee804cbd88 EFLAGS: 00010202
      [  +0.000328] RAX: ffffffffc010e190 RBX: ffff918b5c6b5000 RCX: ffff918b7d8e0000
      [  +0.000399] RDX: ffff918b7d8e0000 RSI: ffffffffc010e190 RDI: 0000000000000001
      [  +0.000398] RBP: ffff918b7d318340 R08: 0000000000000000 R09: ffffffffb9bd2d7a
      [  +0.000385] R10: ffff918b7eb253c0 R11: ffffb95980f51200 R12: ffffffffc010e1a0
      [  +0.000411] R13: fffffffffffffff2 R14: 000000000000000b R15: ffff918b7e232620
      [  +0.000384] FS:  00007f955bec2740(0000) GS:ffff918b7eb00000(0000) knlGS:0000000000000000
      [  +0.000420] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  +0.000801] CR2: 0000000000000998 CR3: 000000003cad6000 CR4: 00000000001406e0
      [  +0.000837] Call Trace:
      [  +0.000682]  ? _cond_resched+0x10/0x20
      [  +0.000691]  ? __kmalloc+0x131/0x1b0
      [  +0.000710]  kernfs_fop_write+0xfa/0x170
      [  +0.000733]  __vfs_write+0x2e/0x190
      [  +0.000688]  ? inode_security+0x10/0x30
      [  +0.000698]  ? selinux_file_permission+0xd2/0x120
      [  +0.000752]  ? security_file_permission+0x2b/0x100
      [  +0.000753]  vfs_write+0xa8/0x1a0
      [  +0.000676]  ksys_write+0x4d/0xb0
      [  +0.000699]  do_syscall_64+0x3a/0xf0
      [  +0.000692]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      Signed-off-by: NLiang Chen <liangchen.linux@gmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NColy Li <colyli@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecfc882f
    • S
      tty/vt: fix write/write race in ioctl(KDSKBSENT) handler · 0fd2df64
      Sergei Trofimovich 提交于
      commit 46ca3f735f345c9d87383dd3a09fa5d43870770e upstream.
      
      The bug manifests as an attempt to access deallocated memory:
      
          BUG: unable to handle kernel paging request at ffff9c8735448000
          #PF error: [PROT] [WRITE]
          PGD 288a05067 P4D 288a05067 PUD 288a07067 PMD 7f60c2063 PTE 80000007f5448161
          Oops: 0003 [#1] PREEMPT SMP
          CPU: 6 PID: 388 Comm: loadkeys Tainted: G         C        5.0.0-rc6-00153-g5ded5871030e #91
          Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./H77M-D3H, BIOS F12 11/14/2013
          RIP: 0010:__memmove+0x81/0x1a0
          Code: 4c 89 4f 10 4c 89 47 18 48 8d 7f 20 73 d4 48 83 c2 20 e9 a2 00 00 00 66 90 48 89 d1 4c 8b 5c 16 f8 4c 8d 54 17 f8 48 c1 e9 03 <f3> 48 a5 4d 89 1a e9 0c 01 00 00 0f 1f 40 00 48 89 d1 4c 8b 1e 49
          RSP: 0018:ffffa1b9002d7d08 EFLAGS: 00010203
          RAX: ffff9c873541af43 RBX: ffff9c873541af43 RCX: 00000c6f105cd6bf
          RDX: 0000637882e986b6 RSI: ffff9c8735447ffb RDI: ffff9c8735447ffb
          RBP: ffff9c8739cd3800 R08: ffff9c873b802f00 R09: 00000000fffff73b
          R10: ffffffffb82b35f1 R11: 00505b1b004d5b1b R12: 0000000000000000
          R13: ffff9c873541af3d R14: 000000000000000b R15: 000000000000000c
          FS:  00007f450c390580(0000) GS:ffff9c873f180000(0000) knlGS:0000000000000000
          CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
          CR2: ffff9c8735448000 CR3: 00000007e213c002 CR4: 00000000000606e0
          Call Trace:
           vt_do_kdgkb_ioctl+0x34d/0x440
           vt_ioctl+0xba3/0x1190
           ? __bpf_prog_run32+0x39/0x60
           ? mem_cgroup_commit_charge+0x7b/0x4e0
           tty_ioctl+0x23f/0x920
           ? preempt_count_sub+0x98/0xe0
           ? __seccomp_filter+0x67/0x600
           do_vfs_ioctl+0xa2/0x6a0
           ? syscall_trace_enter+0x192/0x2d0
           ksys_ioctl+0x3a/0x70
           __x64_sys_ioctl+0x16/0x20
           do_syscall_64+0x54/0xe0
           entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      The bug manifests on systemd systems with multiple vtcon devices:
        # cat /sys/devices/virtual/vtconsole/vtcon0/name
        (S) dummy device
        # cat /sys/devices/virtual/vtconsole/vtcon1/name
        (M) frame buffer device
      
      There systemd runs 'loadkeys' tool in tapallel for each vtcon
      instance. This causes two parallel ioctl(KDSKBSENT) calls to
      race into adding the same entry into 'func_table' array at:
      
          drivers/tty/vt/keyboard.c:vt_do_kdgkb_ioctl()
      
      The function has no locking around writes to 'func_table'.
      
      The simplest reproducer is to have initrams with the following
      init on a 8-CPU machine x86_64:
      
          #!/bin/sh
      
          loadkeys -q windowkeys ru4 &
          loadkeys -q windowkeys ru4 &
          loadkeys -q windowkeys ru4 &
          loadkeys -q windowkeys ru4 &
      
          loadkeys -q windowkeys ru4 &
          loadkeys -q windowkeys ru4 &
          loadkeys -q windowkeys ru4 &
          loadkeys -q windowkeys ru4 &
          wait
      
      The change adds lock on write path only. Reads are still racy.
      
      CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      CC: Jiri Slaby <jslaby@suse.com>
      Link: https://lkml.org/lkml/2019/2/17/256Signed-off-by: NSergei Trofimovich <slyfox@gentoo.org>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0fd2df64
    • Y
      tty: vt.c: Fix TIOCL_BLANKSCREEN console blanking if blankinterval == 0 · d90824ec
      Yifeng Li 提交于
      commit 75ddbc1fb11efac87b611d48e9802f6fe2bb2163 upstream.
      
      Previously, in the userspace, it was possible to use the "setterm" command
      from util-linux to blank the VT console by default, using the following
      command.
      
      According to the man page,
      
      > The force option keeps the screen blank even if a key is pressed.
      
      It was implemented by calling TIOCL_BLANKSCREEN.
      
      	case BLANKSCREEN:
      		ioctlarg = TIOCL_BLANKSCREEN;
      		if (ioctl(STDIN_FILENO, TIOCLINUX, &ioctlarg))
      			warn(_("cannot force blank"));
      		break;
      
      However, after Linux 4.12, this command ceased to work anymore, which is
      unexpected. By inspecting the kernel source, it shows that the issue was
      triggered by the side-effect from commit a4199f5e ("tty: Disable
      default console blanking interval").
      
      The console blanking is implemented by function do_blank_screen() in vt.c:
      "blank_state" will be initialized to "blank_normal_wait" in con_init() if
      AND ONLY IF ("blankinterval" > 0). If "blankinterval" is 0, "blank_state"
      will be "blank_off" (== 0), and a call to do_blank_screen() will always
      abort, even if a forced blanking is required from the user by calling
      TIOCL_BLANKSCREEN, the console won't be blanked.
      
      This behavior is unexpected from a user's point-of-view, since it's not
      mentioned in any documentation. The setterm man page suggests it will
      always work, and the kernel comments in uapi/linux/tiocl.h says
      
      > /* keep screen blank even if a key is pressed */
      > #define TIOCL_BLANKSCREEN 14
      
      To fix it, we simply remove the "blank_state != blank_off" check, as
      pointed out by Nicolas Pitre, this check doesn't logically make sense
      and it's safe to remove.
      Suggested-by: NNicolas Pitre <nicolas.pitre@linaro.org>
      Fixes: a4199f5e ("tty: Disable default console blanking interval")
      Signed-off-by: NYifeng Li <tomli@tomli.me>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d90824ec
    • A
      mtd: spi-nor: intel-spi: Avoid crossing 4K address boundary on read/write · 6a01793e
      Alexander Sverdlin 提交于
      commit 2b75ebeea6f4937d4d05ec4982c471cef9a29b7f upstream.
      
      It was observed that reads crossing 4K address boundary are failing.
      
      This limitation is mentioned in Intel documents:
      
      Intel(R) 9 Series Chipset Family Platform Controller Hub (PCH) Datasheet:
      
      "5.26.3 Flash Access
      Program Register Access:
      * Program Register Accesses are not allowed to cross a 4 KB boundary..."
      
      Enhanced Serial Peripheral Interface (eSPI)
      Interface Base Specification (for Client and Server Platforms):
      
      "5.1.4 Address
      For other memory transactions, the address may start or end at any byte
      boundary. However, the address and payload length combination must not
      cross the naturally aligned address boundary of the corresponding Maximum
      Payload Size. It must not cross a 4 KB address boundary."
      
      Avoid this by splitting an operation crossing the boundary into two
      operations.
      
      Fixes: 8afda8b2 ("spi-nor: Add support for Intel SPI serial flash controller")
      Cc: stable@vger.kernel.org
      Reported-by: NRomain Porte <romain.porte@nokia.com>
      Tested-by: NPascal Fabreges <pascal.fabreges@nokia.com>
      Signed-off-by: NAlexander Sverdlin <alexander.sverdlin@nokia.com>
      Reviewed-by: NTudor Ambarus <tudor.ambarus@microchip.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a01793e
    • R
      ACPI: PM: Set enable_for_wake for wakeup GPEs during suspend-to-idle · 770e46b3
      Rajat Jain 提交于
      commit 2f844b61db8297a1f7a06adf2eb5c43381f2c183 upstream.
      
      I noticed that recently multiple systems (chromebooks) couldn't wake
      from S0ix using LID or Keyboard after updating to a newer kernel. I
      bisected and it turned up commit f941d3e41da7 ("ACPI: EC / PM: Disable
      non-wakeup GPEs for suspend-to-idle"). I checked that the issue got
      fixed if that commit was reverted.
      
      I debugged and found that although PNP0C0D:00 (representing the LID)
      is wake capable and should wakeup the system per the code in
      acpi_wakeup_gpe_init() and in drivers/acpi/button.c:
      
      localhost /sys # cat /proc/acpi/wakeup
      Device  S-state   Status   Sysfs node
      LID0      S4    *enabled   platform:PNP0C0D:00
      CREC      S5    *disabled  platform:GOOG0004:00
                      *disabled  platform:cros-ec-dev.1.auto
                      *disabled  platform:cros-ec-accel.0
                      *disabled  platform:cros-ec-accel.1
                      *disabled  platform:cros-ec-gyro.0
                      *disabled  platform:cros-ec-ring.0
                      *disabled  platform:cros-usbpd-charger.2.auto
                      *disabled  platform:cros-usbpd-logger.3.auto
      D015      S3    *enabled   i2c:i2c-ELAN0000:00
      PENH      S3    *enabled   platform:PRP0001:00
      XHCI      S3    *enabled   pci:0000:00:14.0
      GLAN      S4    *disabled
      WIFI      S3    *disabled  pci:0000:00:14.3
      localhost /sys #
      
      On debugging, I found that its corresponding GPE is not being enabled.
      The particular GPE's "gpe_register_info->enable_for_wake" does not
      have any bits set when acpi_enable_all_wakeup_gpes() comes around to
      use it. I looked at code and could not find any other code path that
      should set the bits in "enable_for_wake" bitmask for the wake enabled
      devices for s2idle.  [I do see that it happens for S3 in
      acpi_sleep_prepare()].
      
      Thus I used the same call to enable the GPEs for wake enabled devices,
      and verified that this fixes the regression I was seeing on multiple
      of my devices.
      
      [ rjw: The problem is that commit f941d3e41da7 ("ACPI: EC / PM:
        Disable non-wakeup GPEs for suspend-to-idle") forgot to add
        the acpi_enable_wakeup_devices() call for s2idle along with
        acpi_enable_all_wakeup_gpes(). ]
      
      Fixes: f941d3e41da7 ("ACPI: EC / PM: Disable non-wakeup GPEs for suspend-to-idle")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=203579Signed-off-by: NRajat Jain <rajatja@google.com>
      [ rjw: Subject & changelog ]
      Cc: 5.0+ <stable@vger.kernel.org> # 5.0+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      770e46b3
    • D
      mm/huge_memory: fix vmf_insert_pfn_{pmd, pud}() crash, handle unaligned addresses · 58db3813
      Dan Williams 提交于
      commit fce86ff5802bac3a7b19db171aa1949ef9caac31 upstream.
      
      Starting with c6f3c5ee40c1 ("mm/huge_memory.c: fix modifying of page
      protection by insert_pfn_pmd()") vmf_insert_pfn_pmd() internally calls
      pmdp_set_access_flags().  That helper enforces a pmd aligned @address
      argument via VM_BUG_ON() assertion.
      
      Update the implementation to take a 'struct vm_fault' argument directly
      and apply the address alignment fixup internally to fix crash signatures
      like:
      
          kernel BUG at arch/x86/mm/pgtable.c:515!
          invalid opcode: 0000 [#1] SMP NOPTI
          CPU: 51 PID: 43713 Comm: java Tainted: G           OE     4.19.35 #1
          [..]
          RIP: 0010:pmdp_set_access_flags+0x48/0x50
          [..]
          Call Trace:
           vmf_insert_pfn_pmd+0x198/0x350
           dax_iomap_fault+0xe82/0x1190
           ext4_dax_huge_fault+0x103/0x1f0
           ? __switch_to_asm+0x40/0x70
           __handle_mm_fault+0x3f6/0x1370
           ? __switch_to_asm+0x34/0x70
           ? __switch_to_asm+0x40/0x70
           handle_mm_fault+0xda/0x200
           __do_page_fault+0x249/0x4f0
           do_page_fault+0x32/0x110
           ? page_fault+0x8/0x30
           page_fault+0x1e/0x30
      
      Link: http://lkml.kernel.org/r/155741946350.372037.11148198430068238140.stgit@dwillia2-desk3.amr.corp.intel.com
      Fixes: c6f3c5ee40c1 ("mm/huge_memory.c: fix modifying of page protection by insert_pfn_pmd()")
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Reported-by: NPiotr Balcer <piotr.balcer@intel.com>
      Tested-by: NYan Ma <yan.ma@intel.com>
      Tested-by: NPankaj Gupta <pagupta@redhat.com>
      Reviewed-by: NMatthew Wilcox <willy@infradead.org>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Reviewed-by: NAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Chandan Rajendra <chandan@linux.ibm.com>
      Cc: Souptick Joarder <jrdr.linux@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58db3813
    • O
      crypto: ccree - handle tee fips error during power management resume · 681f3695
      Ofir Drang 提交于
      commit 7138377ce10455b7183c6dde4b2c51b33f464c45 upstream.
      
      in order to support cryptocell tee fips error that may occurs while
      cryptocell ree is suspended, an cc_tee_handle_fips_error  call added
      to the cc_pm_resume function.
      Signed-off-by: NOfir Drang <ofir.drang@arm.com>
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      681f3695
    • O
      crypto: ccree - add function to handle cryptocell tee fips error · 4fb3d87e
      Ofir Drang 提交于
      commit 897ab2316910a66bb048f1c9cefa25e6a592dcd7 upstream.
      
      Adds function that checks if cryptocell tee fips error occurred
      and in such case triggers system error through kernel panic.
      Change fips function to use this new routine.
      Signed-off-by: NOfir Drang <ofir.drang@arm.com>
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fb3d87e
    • O
      crypto: ccree - HOST_POWER_DOWN_EN should be the last CC access during suspend · 65f5c14a
      Ofir Drang 提交于
      commit 3499efbeed39d114873267683b9e776bcb34b058 upstream.
      
      During power management suspend the driver need to prepare the device
      for the power down operation and as a last indication write to the
      HOST_POWER_DOWN_EN register which signals to the hardware that
      The ccree is ready for power down.
      Signed-off-by: NOfir Drang <ofir.drang@arm.com>
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      65f5c14a
    • O
      crypto: ccree - pm resume first enable the source clk · 1a4fc3d2
      Ofir Drang 提交于
      commit 7766dd774d80463cec7b81d90c8672af91de2da1 upstream.
      
      On power management resume function first enable the device clk source
      to allow access to the device registers.
      Signed-off-by: NOfir Drang <ofir.drang@arm.com>
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1a4fc3d2
    • G
      crypto: ccree - don't map AEAD key and IV on stack · 120ab825
      Gilad Ben-Yossef 提交于
      commit e8662a6a5f8f7f2cadc0edb934aef622d96ac3ee upstream.
      
      The AEAD authenc key and IVs might be passed to us on stack. Copy it to
      a slab buffer before mapping to gurantee proper DMA mapping.
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      120ab825
    • G
      crypto: ccree - use correct internal state sizes for export · ca687cdb
      Gilad Ben-Yossef 提交于
      commit f3df82b468f00cca241d96ee3697c9a5e7fb6bd0 upstream.
      
      We were computing the size of the import buffer based on the digest size
      but the 318 and 224 byte variants use 512 and 256 bytes internal state
      sizes respectfully, thus causing the import buffer to overrun.
      
      Fix it by using the right sizes.
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca687cdb
    • G
      crypto: ccree - don't map MAC key on stack · 766121a0
      Gilad Ben-Yossef 提交于
      commit 874e163759f27e0a9988c5d1f4605e3f25564fd2 upstream.
      
      The MAC hash key might be passed to us on stack. Copy it to
      a slab buffer before mapping to gurantee proper DMA mapping.
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      766121a0
    • G
      crypto: ccree - fix mem leak on error path · 7560c0ad
      Gilad Ben-Yossef 提交于
      commit d574b707c873d6ef1a2a155f8cfcfecd821e9a2e upstream.
      
      Fix a memory leak on the error path of IV generation code.
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7560c0ad
    • G
      crypto: ccree - remove special handling of chained sg · 642de1c0
      Gilad Ben-Yossef 提交于
      commit c4b22bf51b815fb61a35a27fc847a88bc28ebb63 upstream.
      
      We were handling chained scattergather lists with specialized code
      needlessly as the regular sg APIs handle them just fine. The code
      handling this also had an (unused) code path with a use-before-init
      error, flagged by Coverity.
      
      Remove all special handling of chained sg and leave their handling
      to the regular sg APIs.
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      642de1c0
    • R
      mmc: core: Fix tag set memory leak · 003cf675
      Raul E Rangel 提交于
      commit 43d8dabb4074cf7f3b1404bfbaeba5aa6f3e5cfc upstream.
      
      The tag set is allocated in mmc_init_queue but never freed. This results
      in a memory leak. This change makes sure we free the tag set when the
      queue is also freed.
      Signed-off-by: NRaul E Rangel <rrangel@chromium.org>
      Reviewed-by: NJens Axboe <axboe@kernel.dk>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      Fixes: 81196976 ("mmc: block: Add blk-mq support")
      Cc: stable@vger.kernel.org
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      003cf675
    • Z
      crypto: rockchip - update IV buffer to contain the next IV · b7d2adfd
      Zhang Zhijie 提交于
      commit f0cfd57b43fec65761ca61d3892b983a71515f23 upstream.
      
      The Kernel Crypto API request output the next IV data to
      IV buffer for CBC implementation. So the last block data of
      ciphertext should be copid into assigned IV buffer.
      Reported-by: NEric Biggers <ebiggers@google.com>
      Fixes: 433cd2c6 ("crypto: rockchip - add crypto driver for rk3288")
      Cc: <stable@vger.kernel.org> # v4.5+
      Signed-off-by: NZhang Zhijie <zhangzj@rock-chips.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7d2adfd
    • D
      crypto: vmx - fix copy-paste error in CTR mode · 66f5de68
      Daniel Axtens 提交于
      commit dcf7b48212c0fab7df69e84fab22d6cb7c8c0fb9 upstream.
      
      The original assembly imported from OpenSSL has two copy-paste
      errors in handling CTR mode. When dealing with a 2 or 3 block tail,
      the code branches to the CBC decryption exit path, rather than to
      the CTR exit path.
      
      This leads to corruption of the IV, which leads to subsequent blocks
      being corrupted.
      
      This can be detected with libkcapi test suite, which is available at
      https://github.com/smuellerDD/libkcapiReported-by: NOndrej Mosnáček <omosnacek@gmail.com>
      Fixes: 5c380d62 ("crypto: vmx - Add support for VMS instructions by ASM")
      Cc: stable@vger.kernel.org
      Signed-off-by: NDaniel Axtens <dja@axtens.net>
      Tested-by: NMichael Ellerman <mpe@ellerman.id.au>
      Tested-by: NOndrej Mosnacek <omosnacek@gmail.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      66f5de68
    • S
      crypto: ccp - Do not free psp_master when PLATFORM_INIT fails · 07d677ae
      Singh, Brijesh 提交于
      commit f5a2aeb8b254c764772729a6e48d4e0c914bb56a upstream.
      
      Currently, we free the psp_master if the PLATFORM_INIT fails during the
      SEV FW probe. If psp_master is freed then driver does not invoke the PSP
      FW. As per SEV FW spec, there are several commands (PLATFORM_RESET,
      PLATFORM_STATUS, GET_ID etc) which can be executed in the UNINIT state
      We should not free the psp_master when PLATFORM_INIT fails.
      
      Fixes: 200664d5 ("crypto: ccp: Add SEV support")
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Gary Hook <gary.hook@amd.com>
      Cc: stable@vger.kernel.org # 4.19.y
      Signed-off-by: NBrijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      07d677ae
    • C
      crypto: crypto4xx - fix cfb and ofb "overran dst buffer" issues · 7a32ad34
      Christian Lamparter 提交于
      commit 7e92e1717e3eaf6b322c252947c696b3059f05be upstream.
      
      Currently, crypto4xx CFB and OFB AES ciphers are
      failing testmgr's test vectors.
      
      |cfb-aes-ppc4xx encryption overran dst buffer on test vector 3, cfg="in-place"
      |ofb-aes-ppc4xx encryption overran dst buffer on test vector 1, cfg="in-place"
      
      This is because of a very subtile "bug" in the hardware that
      gets indirectly mentioned in 18.1.3.5 Encryption/Decryption
      of the hardware spec:
      
      the OFB and CFB modes for AES are listed there as operation
      modes for >>> "Block ciphers" <<<. Which kind of makes sense,
      but we would like them to be considered as stream ciphers just
      like the CTR mode.
      
      To workaround this issue and stop the hardware from causing
      "overran dst buffer" on crypttexts that are not a multiple
      of 16 (AES_BLOCK_SIZE), we force the driver to use the scatter
      buffers as the go-between.
      
      As a bonus this patch also kills redundant pd_uinfo->num_gd
      and pd_uinfo->num_sd setters since the value has already been
      set before.
      
      Cc: stable@vger.kernel.org
      Fixes: f2a13e7c ("crypto: crypto4xx - enable AES RFC3686, ECB, CFB and OFB offloads")
      Signed-off-by: NChristian Lamparter <chunkeey@gmail.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7a32ad34
    • C
      crypto: crypto4xx - fix ctr-aes missing output IV · c1ec6bea
      Christian Lamparter 提交于
      commit 25baaf8e2c93197d063b372ef7b62f2767c7ac0b upstream.
      
      Commit 8efd972ef96a ("crypto: testmgr - support checking skcipher output IV")
      caused the crypto4xx driver to produce the following error:
      
      | ctr-aes-ppc4xx encryption test failed (wrong output IV)
      | on test vector 0, cfg="in-place"
      
      This patch fixes this by reworking the crypto4xx_setkey_aes()
      function to:
      
       - not save the iv for ECB (as per 18.2.38 CRYP0_SA_CMD_0:
         "This bit mut be cleared for DES ECB mode or AES ECB mode,
         when no IV is used.")
      
       - instruct the hardware to save the generated IV for all
         other modes of operations that have IV and then supply
         it back to the callee in pretty much the same way as we
         do it for cbc-aes already.
      
       - make it clear that the DIR_(IN|OUT)BOUND is the important
         bit that tells the hardware to encrypt or decrypt the data.
         (this is cosmetic - but it hopefully prevents me from
          getting confused again).
      
       - don't load any bogus hash when we don't use any hash
         operation to begin with.
      
      Cc: stable@vger.kernel.org
      Fixes: f2a13e7c ("crypto: crypto4xx - enable AES RFC3686, ECB, CFB and OFB offloads")
      Signed-off-by: NChristian Lamparter <chunkeey@gmail.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c1ec6bea
    • H
      power: supply: axp288_fuel_gauge: Add ACEPC T8 and T11 mini PCs to the blacklist · 592127e9
      Hans de Goede 提交于
      commit 9274c78305e12c5f461bec15f49c38e0f32ca705 upstream.
      
      The ACEPC T8 and T11 Cherry Trail Z8350 mini PCs use an AXP288 and as PCs,
      rather then portables, they does not have a battery. Still for some
      reason the AXP288 not only thinks there is a battery, it actually
      thinks it is discharging while the PC is running, slowly going to
      0% full, causing userspace to shutdown the system due to the battery
      being critically low after a while.
      
      This commit adds the ACEPC T8 and T11 to the axp288 fuel-gauge driver
      blacklist, so that we stop reporting bogus battery readings on this device.
      
      BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1690852
      Cc: stable@vger.kernel.org
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      592127e9
    • G
      power: supply: axp288_charger: Fix unchecked return value · 26eb5e7f
      Gustavo A. R. Silva 提交于
      commit c3422ad5f84a66739ec6a37251ca27638c85b6be upstream.
      
      Currently there is no check on platform_get_irq() return value
      in case it fails, hence never actually reporting any errors and
      causing unexpected behavior when using such value as argument
      for function regmap_irq_get_virq().
      
      Fix this by adding a proper check, a message reporting any errors
      and returning *pirq*
      
      Addresses-Coverity-ID: 1443940 ("Improper use of negative value")
      Fixes: 843735b7 ("power: axp288_charger: axp288 charger driver")
      Cc: stable@vger.kernel.org
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Reviewed-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26eb5e7f
    • C
      mmc: sdhci-of-arasan: Add DTS property to disable DCMDs. · 6eaeee1e
      Christoph Muellner 提交于
      commit 7bda9482e7ed4d27d83c1f9cb5cbe3b34ddac3e8 upstream.
      
      Direct commands (DCMDs) are an optional feature of eMMC 5.1's command
      queue engine (CQE). The Arasan eMMC 5.1 controller uses the CQHCI,
      which exposes a control register bit to enable the feature.
      The current implementation sets this bit unconditionally.
      
      This patch allows to suppress the feature activation,
      by specifying the property disable-cqe-dcmd.
      Signed-off-by: NChristoph Muellner <christoph.muellner@theobroma-systems.com>
      Signed-off-by: NPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      Fixes: 84362d79 ("mmc: sdhci-of-arasan: Add CQHCI support for arasan,sdhci-5.1")
      Cc: stable@vger.kernel.org
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6eaeee1e