1. 13 Oct, 2018 19 commits
  2. 10 Oct, 2018 21 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.9.132 · 3622426c
      Greg Kroah-Hartman authored
      3622426c
    • Mike Snitzer's avatar
      dm thin metadata: fix __udivdi3 undefined on 32-bit · 28e68914
      Mike Snitzer authored
      commit 013ad043 upstream.
      
      sector_div() is only viable for use with sector_t.
      dm_block_t is typedef'd to uint64_t -- so use div_u64() instead.
      
      Fixes: 3ab91828 ("dm thin metadata: try to avoid ever aborting transactions")
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28e68914
    • Ashish Samant's avatar
      ocfs2: fix locking for res->tracking and dlm->tracking_list · 29b4641c
      Ashish Samant authored
      commit cbe355f5 upstream.
      
      In dlm_init_lockres() we access and modify res->tracking and
      dlm->tracking_list without holding dlm->track_lock.  This can cause list
      corruptions and can end up in kernel panic.
      
      Fix this by locking res->tracking and dlm->tracking_list with
      dlm->track_lock instead of dlm->spinlock.
      
      Link: http://lkml.kernel.org/r/1529951192-4686-1-git-send-email-ashish.samant@oracle.comSigned-off-by: default avatarAshish Samant <ashish.samant@oracle.com>
      Reviewed-by: default avatarChangwei Ge <ge.changwei@h3c.com>
      Acked-by: default avatarJoseph Qi <jiangqi903@gmail.com>
      Acked-by: default avatarJun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <ge.changwei@h3c.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      29b4641c
    • Jann Horn's avatar
      proc: restrict kernel stack dumps to root · 3c5dc3f3
      Jann Horn authored
      commit f8a00cef upstream.
      
      Currently, you can use /proc/self/task/*/stack to cause a stack walk on
      a task you control while it is running on another CPU.  That means that
      the stack can change under the stack walker.  The stack walker does
      have guards against going completely off the rails and into random
      kernel memory, but it can interpret random data from your kernel stack
      as instruction pointers and stack pointers.  This can cause exposure of
      kernel stack contents to userspace.
      
      Restrict the ability to inspect kernel stacks of arbitrary tasks to root
      in order to prevent a local attacker from exploiting racy stack unwinding
      to leak kernel task stack contents.  See the added comment for a longer
      rationale.
      
      There don't seem to be any users of this userspace API that can't
      gracefully bail out if reading from the file fails.  Therefore, I believe
      that this change is unlikely to break things.  In the case that this patch
      does end up needing a revert, the next-best solution might be to fake a
      single-entry stack based on wchan.
      
      Link: http://lkml.kernel.org/r/20180927153316.200286-1-jannh@google.com
      Fixes: 2ec220e2 ("proc: add /proc/*/stack")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Ken Chen <kenchen@google.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Laura Abbott <labbott@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "H . Peter Anvin" <hpa@zytor.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3c5dc3f3
    • Ricardo Ribalda Delgado's avatar
      gpiolib: Free the last requested descriptor · e88ca677
      Ricardo Ribalda Delgado authored
      commit 19a4fbff upstream.
      
      The current code only frees N-1 gpios if an error occurs during
      gpiod_set_transitory, gpiod_direction_output or gpiod_direction_input.
      Leading to gpios that cannot be used by userspace nor other drivers.
      
      Cc: Timur Tabi <timur@codeaurora.org>
      Cc: stable@vger.kernel.org
      Fixes: ab3dbcf7 ("gpioib: do not free unrequested descriptors)
      Reported-by: default avatarJan Lorenzen <jl@newtec.dk>
      Reported-by: default avatarJim Paris <jim@jtan.com>
      Signed-off-by: default avatarRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e88ca677
    • Leonard Crestez's avatar
      crypto: mxs-dcp - Fix wait logic on chan threads · d49c7bb7
      Leonard Crestez authored
      commit d80771c0 upstream.
      
      When compiling with CONFIG_DEBUG_ATOMIC_SLEEP=y the mxs-dcp driver
      prints warnings such as:
      
      WARNING: CPU: 0 PID: 120 at kernel/sched/core.c:7736 __might_sleep+0x98/0x9c
      do not call blocking ops when !TASK_RUNNING; state=1 set at [<8081978c>] dcp_chan_thread_sha+0x3c/0x2ec
      
      The problem is that blocking ops will manipulate current->state
      themselves so it is not allowed to call them between
      set_current_state(TASK_INTERRUPTIBLE) and schedule().
      
      Fix this by converting the per-chan mutex to a spinlock (it only
      protects tiny list ops anyway) and rearranging the wait logic so that
      callbacks are called current->state as TASK_RUNNING. Those callbacks
      will indeed call blocking ops themselves so this is required.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarLeonard Crestez <leonard.crestez@nxp.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d49c7bb7
    • Waiman Long's avatar
      crypto: qat - Fix KASAN stack-out-of-bounds bug in adf_probe() · 2ba794f9
      Waiman Long authored
      commit ba439a6c upstream.
      
      The following KASAN warning was printed when booting a 64-bit kernel
      on some systems with Intel CPUs:
      
      [   44.512826] ==================================================================
      [   44.520165] BUG: KASAN: stack-out-of-bounds in find_first_bit+0xb0/0xc0
      [   44.526786] Read of size 8 at addr ffff88041e02fc50 by task kworker/0:2/124
      
      [   44.535253] CPU: 0 PID: 124 Comm: kworker/0:2 Tainted: G               X --------- ---  4.18.0-12.el8.x86_64+debug #1
      [   44.545858] Hardware name: Intel Corporation PURLEY/PURLEY, BIOS BKVDTRL1.86B.0005.D08.1712070559 12/07/2017
      [   44.555682] Workqueue: events work_for_cpu_fn
      [   44.560043] Call Trace:
      [   44.562502]  dump_stack+0x9a/0xe9
      [   44.565832]  print_address_description+0x65/0x22e
      [   44.570683]  ? find_first_bit+0xb0/0xc0
      [   44.570689]  kasan_report.cold.6+0x92/0x19f
      [   44.578726]  find_first_bit+0xb0/0xc0
      [   44.578737]  adf_probe+0x9eb/0x19a0 [qat_c62x]
      [   44.578751]  ? adf_remove+0x110/0x110 [qat_c62x]
      [   44.591490]  ? mark_held_locks+0xc8/0x140
      [   44.591498]  ? _raw_spin_unlock+0x30/0x30
      [   44.591505]  ? trace_hardirqs_on_caller+0x381/0x570
      [   44.604418]  ? adf_remove+0x110/0x110 [qat_c62x]
      [   44.604427]  local_pci_probe+0xd4/0x180
      [   44.604432]  ? pci_device_shutdown+0x110/0x110
      [   44.617386]  work_for_cpu_fn+0x51/0xa0
      [   44.621145]  process_one_work+0x8fe/0x16e0
      [   44.625263]  ? pwq_dec_nr_in_flight+0x2d0/0x2d0
      [   44.629799]  ? lock_acquire+0x14c/0x400
      [   44.633645]  ? move_linked_works+0x12e/0x2a0
      [   44.637928]  worker_thread+0x536/0xb50
      [   44.641690]  ? __kthread_parkme+0xb6/0x180
      [   44.645796]  ? process_one_work+0x16e0/0x16e0
      [   44.650160]  kthread+0x30c/0x3d0
      [   44.653400]  ? kthread_create_worker_on_cpu+0xc0/0xc0
      [   44.658457]  ret_from_fork+0x3a/0x50
      
      [   44.663557] The buggy address belongs to the page:
      [   44.668350] page:ffffea0010780bc0 count:0 mapcount:0 mapping:0000000000000000 index:0x0
      [   44.676356] flags: 0x17ffffc0000000()
      [   44.680023] raw: 0017ffffc0000000 ffffea0010780bc8 ffffea0010780bc8 0000000000000000
      [   44.687769] raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
      [   44.695510] page dumped because: kasan: bad access detected
      
      [   44.702578] Memory state around the buggy address:
      [   44.707372]  ffff88041e02fb00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [   44.714593]  ffff88041e02fb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [   44.721810] >ffff88041e02fc00: 00 00 00 00 00 00 f1 f1 f1 f1 04 f2 f2 f2 f2 f2
      [   44.729028]                                                  ^
      [   44.734864]  ffff88041e02fc80: f2 f2 00 00 00 00 f3 f3 f3 f3 00 00 00 00 00 00
      [   44.742082]  ffff88041e02fd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [   44.749299] ==================================================================
      
      Looking into the code:
      
        int ret, bar_mask;
          :
        for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask,
      
      It is casting a 32-bit integer pointer to a 64-bit unsigned long
      pointer. There are two problems here. First, the 32-bit pointer address
      may not be 64-bit aligned. Secondly, it is accessing an extra 4 bytes.
      
      This is fixed by changing the bar_mask type to unsigned long.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ba794f9
    • Kai-Heng Feng's avatar
      ALSA: hda/realtek - Cannot adjust speaker's volume on Dell XPS 27 7760 · 685a8f97
      Kai-Heng Feng authored
      commit 709ae62e upstream.
      
      The issue is the same as commit dd9aa335 ("ALSA: hda/realtek - Can't
      adjust speaker's volume on a Dell AIO"), the output requires to connect
      to a node with Amp-out capability.
      
      Applying the same fixup ALC298_FIXUP_SPK_VOLUME can fix the issue.
      
      BugLink: https://bugs.launchpad.net/bugs/1775068Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      685a8f97
    • Aurelien Aptel's avatar
      smb2: fix missing files in root share directory listing · 57539911
      Aurelien Aptel authored
      commit 0595751f upstream.
      
      When mounting a Windows share that is the root of a drive (eg. C$)
      the server does not return . and .. directory entries. This results in
      the smb2 code path erroneously skipping the 2 first entries.
      
      Pseudo-code of the readdir() code path:
      
      cifs_readdir(struct file, struct dir_context)
          initiate_cifs_search            <-- if no reponse cached yet
              server->ops->query_dir_first
      
          dir_emit_dots
              dir_emit                    <-- adds "." and ".." if we're at pos=0
      
          find_cifs_entry
              initiate_cifs_search        <-- if pos < start of current response
                                               (restart search)
              server->ops->query_dir_next <-- if pos > end of current response
                                               (fetch next search res)
      
          for(...)                        <-- loops over cur response entries
                                                starting at pos
              cifs_filldir                <-- skip . and .., emit entry
                  cifs_fill_dirent
                  dir_emit
      	pos++
      
      A) dir_emit_dots() always adds . & ..
         and sets the current dir pos to 2 (0 and 1 are done).
      
      Therefore we always want the index_to_find to be 2 regardless of if
      the response has . and ..
      
      B) smb1 code initializes index_of_last_entry with a +2 offset
      
        in cifssmb.c CIFSFindFirst():
      		psrch_inf->index_of_last_entry = 2 /* skip . and .. */ +
      			psrch_inf->entries_in_buffer;
      
      Later in find_cifs_entry() we want to find the next dir entry at pos=2
      as a result of (A)
      
      	first_entry_in_buffer = cfile->srch_inf.index_of_last_entry -
      					cfile->srch_inf.entries_in_buffer;
      
      This var is the dir pos that the first entry in the buffer will
      have therefore it must be 2 in the first call.
      
      If we don't offset index_of_last_entry by 2 (like in (B)),
      first_entry_in_buffer=0 but we were instructed to get pos=2 so this
      code in find_cifs_entry() skips the 2 first which is ok for non-root
      shares, as it skips . and .. from the response but is not ok for root
      shares where the 2 first are actual files
      
      		pos_in_buf = index_to_find - first_entry_in_buffer;
                      // pos_in_buf=2
      		// we skip 2 first response entries :(
      		for (i = 0; (i < (pos_in_buf)) && (cur_ent != NULL); i++) {
      			/* go entry by entry figuring out which is first */
      			cur_ent = nxt_dir_entry(cur_ent, end_of_smb,
      						cfile->srch_inf.info_level);
      		}
      
      C) cifs_filldir() skips . and .. so we can safely ignore them for now.
      
      Sample program:
      
      int main(int argc, char **argv)
      {
      	const char *path = argc >= 2 ? argv[1] : ".";
      	DIR *dh;
      	struct dirent *de;
      
      	printf("listing path <%s>\n", path);
      	dh = opendir(path);
      	if (!dh) {
      		printf("opendir error %d\n", errno);
      		return 1;
      	}
      
      	while (1) {
      		de = readdir(dh);
      		if (!de) {
      			if (errno) {
      				printf("readdir error %d\n", errno);
      				return 1;
      			}
      			printf("end of listing\n");
      			break;
      		}
      		printf("off=%lu <%s>\n", de->d_off, de->d_name);
      	}
      
      	return 0;
      }
      
      Before the fix with SMB1 on root shares:
      
      <.>            off=1
      <..>           off=2
      <$Recycle.Bin> off=3
      <bootmgr>      off=4
      
      and on non-root shares:
      
      <.>    off=1
      <..>   off=4  <-- after adding .., the offsets jumps to +2 because
      <2536> off=5       we skipped . and .. from response buffer (C)
      <411>  off=6       but still incremented pos
      <file> off=7
      <fsx>  off=8
      
      Therefore the fix for smb2 is to mimic smb1 behaviour and offset the
      index_of_last_entry by 2.
      
      Test results comparing smb1 and smb2 before/after the fix on root
      share, non-root shares and on large directories (ie. multi-response
      dir listing):
      
      PRE FIX
      =======
      pre-1-root VS pre-2-root:
              ERR pre-2-root is missing [bootmgr, $Recycle.Bin]
      pre-1-nonroot VS pre-2-nonroot:
              OK~ same files, same order, different offsets
      pre-1-nonroot-large VS pre-2-nonroot-large:
              OK~ same files, same order, different offsets
      
      POST FIX
      ========
      post-1-root VS post-2-root:
              OK same files, same order, same offsets
      post-1-nonroot VS post-2-nonroot:
              OK same files, same order, same offsets
      post-1-nonroot-large VS post-2-nonroot-large:
              OK same files, same order, same offsets
      
      REGRESSION?
      ===========
      pre-1-root VS post-1-root:
              OK same files, same order, same offsets
      pre-1-nonroot VS post-1-nonroot:
              OK same files, same order, same offsets
      
      BugLink: https://bugzilla.samba.org/show_bug.cgi?id=13107Signed-off-by: default avatarAurelien Aptel <aaptel@suse.com>
      Signed-off-by: default avatarPaulo Alcantara <palcantara@suse.deR>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57539911
    • Andreas Gruenbacher's avatar
      sysfs: Do not return POSIX ACL xattrs via listxattr · 8e9817c6
      Andreas Gruenbacher authored
      commit ffc4c922 upstream.
      
      Commit 786534b9 introduced a regression that caused listxattr to
      return the POSIX ACL attribute names even though sysfs doesn't support
      POSIX ACLs.  This happens because simple_xattr_list checks for NULL
      i_acl / i_default_acl, but inode_init_always initializes those fields
      to ACL_NOT_CACHED ((void *)-1).  For example:
          $ getfattr -m- -d /sys
          /sys: system.posix_acl_access: Operation not supported
          /sys: system.posix_acl_default: Operation not supported
      Fix this in simple_xattr_list by checking if the filesystem supports POSIX ACLs.
      
      Fixes: 786534b9 ("tmpfs: listxattr should include POSIX ACL xattrs")
      Reported-by: default avatarMarc Aurèle La France <tsi@tuyoix.net>
      Tested-by: default avatarMarc Aurèle La France <tsi@tuyoix.net>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Cc: stable@vger.kernel.org # v4.5+
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e9817c6
    • Josh Abraham's avatar
      xen: fix GCC warning and remove duplicate EVTCHN_ROW/EVTCHN_COL usage · 7f9787c0
      Josh Abraham authored
      [ Upstream commit 4dca864b ]
      
      This patch removes duplicate macro useage in events_base.c.
      
      It also fixes gcc warning:
      variable ‘col’ set but not used [-Wunused-but-set-variable]
      Signed-off-by: default avatarJoshua Abraham <j.abraham1776@gmail.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f9787c0
    • Olaf Hering's avatar
      xen: avoid crash in disable_hotplug_cpu · a571f897
      Olaf Hering authored
      [ Upstream commit 3366cdb6 ]
      
      The command 'xl vcpu-set 0 0', issued in dom0, will crash dom0:
      
      BUG: unable to handle kernel NULL pointer dereference at 00000000000002d8
      PGD 0 P4D 0
      Oops: 0000 [#1] PREEMPT SMP NOPTI
      CPU: 7 PID: 65 Comm: xenwatch Not tainted 4.19.0-rc2-1.ga9462db-default #1 openSUSE Tumbleweed (unreleased)
      Hardware name: Intel Corporation S5520UR/S5520UR, BIOS S5500.86B.01.00.0050.050620101605 05/06/2010
      RIP: e030:device_offline+0x9/0xb0
      Code: 77 24 00 e9 ce fe ff ff 48 8b 13 e9 68 ff ff ff 48 8b 13 e9 29 ff ff ff 48 8b 13 e9 ea fe ff ff 90 66 66 66 66 90 41 54 55 53 <f6> 87 d8 02 00 00 01 0f 85 88 00 00 00 48 c7 c2 20 09 60 81 31 f6
      RSP: e02b:ffffc90040f27e80 EFLAGS: 00010203
      RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      RDX: ffff8801f3800000 RSI: ffffc90040f27e70 RDI: 0000000000000000
      RBP: 0000000000000000 R08: ffffffff820e47b3 R09: 0000000000000000
      R10: 0000000000007ff0 R11: 0000000000000000 R12: ffffffff822e6d30
      R13: dead000000000200 R14: dead000000000100 R15: ffffffff8158b4e0
      FS:  00007ffa595158c0(0000) GS:ffff8801f39c0000(0000) knlGS:0000000000000000
      CS:  e033 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000000002d8 CR3: 00000001d9602000 CR4: 0000000000002660
      Call Trace:
       handle_vcpu_hotplug_event+0xb5/0xc0
       xenwatch_thread+0x80/0x140
       ? wait_woken+0x80/0x80
       kthread+0x112/0x130
       ? kthread_create_worker_on_cpu+0x40/0x40
       ret_from_fork+0x3a/0x50
      
      This happens because handle_vcpu_hotplug_event is called twice. In the
      first iteration cpu_present is still true, in the second iteration
      cpu_present is false which causes get_cpu_device to return NULL.
      In case of cpu#0, cpu_online is apparently always true.
      
      Fix this crash by checking if the cpu can be hotplugged, which is false
      for a cpu that was just removed.
      
      Also check if the cpu was actually offlined by device_remove, otherwise
      leave the cpu_present state as it is.
      
      Rearrange to code to do all work with device_hotplug_lock held.
      Signed-off-by: default avatarOlaf Hering <olaf@aepfle.de>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a571f897
    • Vitaly Kuznetsov's avatar
      xen/manage: don't complain about an empty value in control/sysrq node · 9e72ba07
      Vitaly Kuznetsov authored
      [ Upstream commit 87dffe86 ]
      
      When guest receives a sysrq request from the host it acknowledges it by
      writing '\0' to control/sysrq xenstore node. This, however, make xenstore
      watch fire again but xenbus_scanf() fails to parse empty value with "%c"
      format string:
      
       sysrq: SysRq : Emergency Sync
       Emergency Sync complete
       xen:manage: Error -34 reading sysrq code in control/sysrq
      
      Ignore -ERANGE the same way we already ignore -ENOENT, empty value in
      control/sysrq is totally legal.
      Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Reviewed-by: default avatarWei Liu <wei.liu2@citrix.com>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9e72ba07
    • Dan Carpenter's avatar
      cifs: read overflow in is_valid_oplock_break() · 3466db7b
      Dan Carpenter authored
      [ Upstream commit 097f5863 ]
      
      We need to verify that the "data_offset" is within bounds.
      Reported-by: default avatarDr Silvio Cesare of InfoSect <silvio.cesare@gmail.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3466db7b
    • Julian Wiedmann's avatar
      s390/qeth: don't dump past end of unknown HW header · 82e9788a
      Julian Wiedmann authored
      [ Upstream commit 0ac1487c ]
      
      For inbound data with an unsupported HW header format, only dump the
      actual HW header. We have no idea how much payload follows it, and what
      it contains. Worst case, we dump past the end of the Inbound Buffer and
      access whatever is located next in memory.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82e9788a
    • Wenjia Zhang's avatar
      s390/qeth: use vzalloc for QUERY OAT buffer · 743f4a27
      Wenjia Zhang authored
      [ Upstream commit aec45e85 ]
      
      qeth_query_oat_command() currently allocates the kernel buffer for
      the SIOC_QETH_QUERY_OAT ioctl with kzalloc. So on systems with
      fragmented memory, large allocations may fail (eg. the qethqoat tool by
      default uses 132KB).
      
      Solve this issue by using vzalloc, backing the allocation with
      non-contiguous memory.
      Signed-off-by: default avatarWenjia Zhang <wenjia@linux.ibm.com>
      Reviewed-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      743f4a27
    • Kai-Heng Feng's avatar
      r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing RTL_FLAG_TASK_ENABLED · 9fcb4509
      Kai-Heng Feng authored
      [ Upstream commit 6ad56901 ]
      
      After system suspend, sometimes the r8169 doesn't work when ethernet
      cable gets pluggued.
      
      This issue happens because rtl_reset_work() doesn't get called from
      rtl8169_runtime_resume(), after system suspend.
      
      In rtl_task(), RTL_FLAG_TASK_* only gets cleared if this condition is
      met:
      if (!netif_running(dev) ||
          !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
          ...
      
      If RTL_FLAG_TASK_ENABLED was cleared during system suspend while
      RTL_FLAG_TASK_RESET_PENDING was set, the next rtl_schedule_task() won't
      schedule task as the flag is still there.
      
      So in addition to clearing RTL_FLAG_TASK_ENABLED, also clears other
      flags.
      
      Cc: Heiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9fcb4509
    • Miguel Ojeda's avatar
      arm64: jump_label.h: use asm_volatile_goto macro instead of "asm goto" · d7ce4d56
      Miguel Ojeda authored
      [ Upstream commit 13aceef0 ]
      
      All other uses of "asm goto" go through asm_volatile_goto, which avoids
      a miscompile when using GCC < 4.8.2. Replace our open-coded "asm goto"
      statements with the asm_volatile_goto macro to avoid issues with older
      toolchains.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7ce4d56
    • Randy Dunlap's avatar
      hexagon: modify ffs() and fls() to return int · 3c751807
      Randy Dunlap authored
      [ Upstream commit 5c41aaad ]
      
      Building drivers/mtd/nand/raw/nandsim.c on arch/hexagon/ produces a
      printk format build warning.  This is due to hexagon's ffs() being
      coded as returning long instead of int.
      
      Fix the printk format warning by changing all of hexagon's ffs() and
      fls() functions to return int instead of long.  The variables that
      they return are already int instead of long.  This return type
      matches the return type in <asm-generic/bitops/>.
      
      ../drivers/mtd/nand/raw/nandsim.c: In function 'init_nandsim':
      ../drivers/mtd/nand/raw/nandsim.c:760:2: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'long int' [-Wformat]
      
      There are no ffs() or fls() allmodconfig build errors after making this
      change.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Richard Kuo <rkuo@codeaurora.org>
      Cc: linux-hexagon@vger.kernel.org
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Patch-mainline: linux-kernel @ 07/22/2018, 16:03
      Signed-off-by: default avatarRichard Kuo <rkuo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3c751807
    • Randy Dunlap's avatar
      arch/hexagon: fix kernel/dma.c build warning · 0f48ac15
      Randy Dunlap authored
      [ Upstream commit 200f351e ]
      
      Fix build warning in arch/hexagon/kernel/dma.c by casting a void *
      to unsigned long to match the function parameter type.
      
      ../arch/hexagon/kernel/dma.c: In function 'arch_dma_alloc':
      ../arch/hexagon/kernel/dma.c:51:5: warning: passing argument 2 of 'gen_pool_add' makes integer from pointer without a cast [enabled by default]
      ../include/linux/genalloc.h:112:19: note: expected 'long unsigned int' but argument is of type 'void *'
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: linux-sh@vger.kernel.org
      Patch-mainline: linux-kernel @ 07/20/2018, 20:17
      [rkuo@codeaurora.org: fixed architecture name]
      Signed-off-by: default avatarRichard Kuo <rkuo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0f48ac15
    • Joe Thornber's avatar
      dm thin metadata: try to avoid ever aborting transactions · a9537dbf
      Joe Thornber authored
      [ Upstream commit 3ab91828 ]
      
      Committing a transaction can consume some metadata of it's own, we now
      reserve a small amount of metadata to cover this.  Free metadata
      reported by the kernel will not include this reserve.
      
      If any of the reserve has been used after a commit we enter a new
      internal state PM_OUT_OF_METADATA_SPACE.  This is reported as
      PM_READ_ONLY, so no userland changes are needed.  If the metadata
      device is resized the pool will move back to PM_WRITE.
      
      These changes mean we never need to abort and rollback a transaction due
      to running out of metadata space.  This is particularly important
      because there have been a handful of reports of data corruption against
      DM thin-provisioning that can all be attributed to the thin-pool having
      ran out of metadata space.
      Signed-off-by: default avatarJoe Thornber <ejt@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a9537dbf