1. 15 Sep, 2018 30 commits
  2. 09 Sep, 2018 10 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.4.155 · fdf53713
      Greg Kroah-Hartman authored
      fdf53713
    • Dave Airlie's avatar
      drm/drivers: add support for using the arch wc mapping API. · c59fdc4c
      Dave Airlie authored
      commit 7cf321d1 upstream.
      
      This fixes a regression in all these drivers since the cache
      mode tracking was fixed for mixed mappings. It uses the new
      arch API to add the VRAM range to the PAT mapping tracking
      tables.
      
      Fixes: 87744ab3 (mm: fix cache mode tracking in vm_insert_mixed())
      Reviewed-by: Christian König <christian.koenig@amd.com>.
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c59fdc4c
    • Dave Airlie's avatar
      x86/io: add interface to reserve io memtype for a resource range. (v1.1) · 1fc5fa52
      Dave Airlie authored
      commit 8ef42276 upstream.
      
      A recent change to the mm code in:
      87744ab3 mm: fix cache mode tracking in vm_insert_mixed()
      
      started enforcing checking the memory type against the registered list for
      amixed pfn insertion mappings. It happens that the drm drivers for a number
      of gpus relied on this being broken. Currently the driver only inserted
      VRAM mappings into the tracking table when they came from the kernel,
      and userspace mappings never landed in the table. This led to a regression
      where all the mapping end up as UC instead of WC now.
      
      I've considered a number of solutions but since this needs to be fixed
      in fixes and not next, and some of the solutions were going to introduce
      overhead that hadn't been there before I didn't consider them viable at
      this stage. These mainly concerned hooking into the TTM io reserve APIs,
      but these API have a bunch of fast paths I didn't want to unwind to add
      this to.
      
      The solution I've decided on is to add a new API like the arch_phys_wc
      APIs (these would have worked but wc_del didn't take a range), and
      use them from the drivers to add a WC compatible mapping to the table
      for all VRAM on those GPUs. This means we can then create userspace
      mapping that won't get degraded to UC.
      
      v1.1: use CONFIG_X86_PAT + add some comments in io.h
      
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: x86@kernel.org
      Cc: mcgrof@suse.com
      Cc: Dan Williams <dan.j.williams@intel.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1fc5fa52
    • Jeremy Cline's avatar
      fs/quota: Fix spectre gadget in do_quotactl · 59825a7e
      Jeremy Cline authored
      commit 7b6924d9 upstream.
      
      'type' is user-controlled, so sanitize it after the bounds check to
      avoid using it in speculative execution. This covers the following
      potential gadgets detected with the help of smatch:
      
      * fs/ext4/super.c:5741 ext4_quota_read() warn: potential spectre issue
        'sb_dqopt(sb)->files' [r]
      * fs/ext4/super.c:5778 ext4_quota_write() warn: potential spectre issue
        'sb_dqopt(sb)->files' [r]
      * fs/f2fs/super.c:1552 f2fs_quota_read() warn: potential spectre issue
        'sb_dqopt(sb)->files' [r]
      * fs/f2fs/super.c:1608 f2fs_quota_write() warn: potential spectre issue
        'sb_dqopt(sb)->files' [r]
      * fs/quota/dquot.c:412 mark_info_dirty() warn: potential spectre issue
        'sb_dqopt(sb)->info' [w]
      * fs/quota/dquot.c:933 dqinit_needed() warn: potential spectre issue
        'dquots' [r]
      * fs/quota/dquot.c:2112 dquot_commit_info() warn: potential spectre
        issue 'dqopt->ops' [r]
      * fs/quota/dquot.c:2362 vfs_load_quota_inode() warn: potential spectre
        issue 'dqopt->files' [w] (local cap)
      * fs/quota/dquot.c:2369 vfs_load_quota_inode() warn: potential spectre
        issue 'dqopt->ops' [w] (local cap)
      * fs/quota/dquot.c:2370 vfs_load_quota_inode() warn: potential spectre
        issue 'dqopt->info' [w] (local cap)
      * fs/quota/quota.c:110 quota_getfmt() warn: potential spectre issue
        'sb_dqopt(sb)->info' [r]
      * fs/quota/quota_v2.c:84 v2_check_quota_file() warn: potential spectre
        issue 'quota_magics' [w]
      * fs/quota/quota_v2.c:85 v2_check_quota_file() warn: potential spectre
        issue 'quota_versions' [w]
      * fs/quota/quota_v2.c:96 v2_read_file_info() warn: potential spectre
        issue 'dqopt->info' [r]
      * fs/quota/quota_v2.c:172 v2_write_file_info() warn: potential spectre
        issue 'dqopt->info' [r]
      
      Additionally, a quick inspection indicates there are array accesses with
      'type' in quota_on() and quota_off() functions which are also addressed
      by this.
      
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJeremy Cline <jcline@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      59825a7e
    • Adrian Hunter's avatar
      perf auxtrace: Fix queue resize · ef699421
      Adrian Hunter authored
      commit 99cbbe56 upstream.
      
      When the number of queues grows beyond 32, the array of queues is
      resized but not all members were being copied. Fix by also copying
      'tid', 'cpu' and 'set'.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: e5027893 ("perf auxtrace: Add helpers for queuing AUX area tracing data")
      Link: http://lkml.kernel.org/r/20180814084608.6563-1-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef699421
    • Shan Hai's avatar
      bcache: release dc->writeback_lock properly in bch_writeback_thread() · 95861df6
      Shan Hai authored
      commit 3943b040 upstream.
      
      The writeback thread would exit with a lock held when the cache device
      is detached via sysfs interface, fix it by releasing the held lock
      before exiting the while-loop.
      
      Fixes: fadd94e0 (bcache: quit dc->writeback_thread when BCACHE_DEV_DETACHING is set)
      Signed-off-by: default avatarShan Hai <shan.hai@oracle.com>
      Signed-off-by: default avatarColy Li <colyli@suse.de>
      Tested-by: default avatarShenghui Wang <shhuiw@foxmail.com>
      Cc: stable@vger.kernel.org #4.17+
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95861df6
    • Christian Brauner's avatar
      getxattr: use correct xattr length · f7f501c7
      Christian Brauner authored
      commit 82c9a927 upstream.
      
      When running in a container with a user namespace, if you call getxattr
      with name = "system.posix_acl_access" and size % 8 != 4, then getxattr
      silently skips the user namespace fixup that it normally does resulting in
      un-fixed-up data being returned.
      This is caused by posix_acl_fix_xattr_to_user() being passed the total
      buffer size and not the actual size of the xattr as returned by
      vfs_getxattr().
      This commit passes the actual length of the xattr as returned by
      vfs_getxattr() down.
      
      A reproducer for the issue is:
      
        touch acl_posix
      
        setfacl -m user:0:rwx acl_posix
      
      and the compile:
      
        #define _GNU_SOURCE
        #include <errno.h>
        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>
        #include <sys/types.h>
        #include <unistd.h>
        #include <attr/xattr.h>
      
        /* Run in user namespace with nsuid 0 mapped to uid != 0 on the host. */
        int main(int argc, void **argv)
        {
                ssize_t ret1, ret2;
                char buf1[128], buf2[132];
                int fret = EXIT_SUCCESS;
                char *file;
      
                if (argc < 2) {
                        fprintf(stderr,
                                "Please specify a file with "
                                "\"system.posix_acl_access\" permissions set\n");
                        _exit(EXIT_FAILURE);
                }
                file = argv[1];
      
                ret1 = getxattr(file, "system.posix_acl_access",
                                buf1, sizeof(buf1));
                if (ret1 < 0) {
                        fprintf(stderr, "%s - Failed to retrieve "
                                        "\"system.posix_acl_access\" "
                                        "from \"%s\"\n", strerror(errno), file);
                        _exit(EXIT_FAILURE);
                }
      
                ret2 = getxattr(file, "system.posix_acl_access",
                                buf2, sizeof(buf2));
                if (ret2 < 0) {
                        fprintf(stderr, "%s - Failed to retrieve "
                                        "\"system.posix_acl_access\" "
                                        "from \"%s\"\n", strerror(errno), file);
                        _exit(EXIT_FAILURE);
                }
      
                if (ret1 != ret2) {
                        fprintf(stderr, "The value of \"system.posix_acl_"
                                        "access\" for file \"%s\" changed "
                                        "between two successive calls\n", file);
                        _exit(EXIT_FAILURE);
                }
      
                for (ssize_t i = 0; i < ret2; i++) {
                        if (buf1[i] == buf2[i])
                                continue;
      
                        fprintf(stderr,
                                "Unexpected different in byte %zd: "
                                "%02x != %02x\n", i, buf1[i], buf2[i]);
                        fret = EXIT_FAILURE;
                }
      
                if (fret == EXIT_SUCCESS)
                        fprintf(stderr, "Test passed\n");
                else
                        fprintf(stderr, "Test failed\n");
      
                _exit(fret);
        }
      and run:
      
        ./tester acl_posix
      
      On a non-fixed up kernel this should return something like:
      
        root@c1:/# ./t
        Unexpected different in byte 16: ffffffa0 != 00
        Unexpected different in byte 17: ffffff86 != 00
        Unexpected different in byte 18: 01 != 00
      
      and on a fixed kernel:
      
        root@c1:~# ./t
        Test passed
      
      Cc: stable@vger.kernel.org
      Fixes: 2f6f0654 ("userns: Convert vfs posix_acl support to use kuids and kgids")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=199945Reported-by: default avatarColin Watson <cjwatson@ubuntu.com>
      Signed-off-by: default avatarChristian Brauner <christian@brauner.io>
      Acked-by: default avatarSerge Hallyn <serge@hallyn.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7f501c7
    • Mikulas Patocka's avatar
      udlfb: set optimal write delay · 3130702a
      Mikulas Patocka authored
      commit bb24153a upstream.
      
      The default delay 5 jiffies is too much when the kernel is compiled with
      HZ=100 - it results in jumpy cursor in Xwindow.
      
      In order to find out the optimal delay, I benchmarked the driver on
      1280x720x30fps video. I found out that with HZ=1000, 10ms is acceptable,
      but with HZ=250 or HZ=300, we need 4ms, so that the video is played
      without any frame skips.
      
      This patch changes the delay to this value.
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3130702a
    • Mikulas Patocka's avatar
      fb: fix lost console when the user unplugs a USB adapter · c602af2b
      Mikulas Patocka authored
      commit 8c5b0442 upstream.
      
      I have a USB display adapter using the udlfb driver and I use it on an ARM
      board that doesn't have any graphics card. When I plug the adapter in, the
      console is properly displayed, however when I unplug and re-plug the
      adapter, the console is not displayed and I can't access it until I reboot
      the board.
      
      The reason is this:
      When the adapter is unplugged, dlfb_usb_disconnect calls
      unlink_framebuffer, then it waits until the reference count drops to zero
      and then it deallocates the framebuffer. However, the console that is
      attached to the framebuffer device keeps the reference count non-zero, so
      the framebuffer device is never destroyed. When the USB adapter is plugged
      again, it creates a new device /dev/fb1 and the console is not attached to
      it.
      
      This patch fixes the bug by unbinding the console from unlink_framebuffer.
      The code to unbind the console is moved from do_unregister_framebuffer to
      a function unbind_console. When the console is unbound, the reference
      count drops to zero and the udlfb driver frees the framebuffer. When the
      adapter is plugged back, a new framebuffer is created and the console is
      attached to it.
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Bernie Thompson <bernie@plugable.com>
      Cc: Ladislav Michl <ladis@linux-mips.org>
      Cc: stable@vger.kernel.org
      [b.zolnierkie: preserve old behavior for do_unregister_framebuffer()]
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c602af2b
    • Vignesh R's avatar
      pwm: tiehrpwm: Fix disabling of output of PWMs · 57d78f3e
      Vignesh R authored
      commit 38dabd91 upstream.
      
      pwm-tiehrpwm driver disables PWM output by putting it in low output
      state via active AQCSFRC register in ehrpwm_pwm_disable(). But, the
      AQCSFRC shadow register is not updated. Therefore, when shadow AQCSFRC
      register is re-enabled in ehrpwm_pwm_enable() (say to enable second PWM
      output), previous settings are lost as shadow register value is loaded
      into active register. This results in things like PWMA getting enabled
      automatically, when PWMB is enabled and vice versa. Fix this by
      updating AQCSFRC shadow register as well during ehrpwm_pwm_disable().
      
      Fixes: 19891b20 ("pwm: pwm-tiehrpwm: PWM driver support for EHRPWM")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarVignesh R <vigneshr@ti.com>
      Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57d78f3e