]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 26 Jul 2021 09:07:40 +0000 (11:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 26 Jul 2021 09:07:40 +0000 (11:07 +0200)
added patches:
drm-return-enotty-for-non-drm-ioctls.patch
nds32-fix-up-stack-guard-gap.patch

queue-4.19/drm-return-enotty-for-non-drm-ioctls.patch [new file with mode: 0644]
queue-4.19/nds32-fix-up-stack-guard-gap.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/drm-return-enotty-for-non-drm-ioctls.patch b/queue-4.19/drm-return-enotty-for-non-drm-ioctls.patch
new file mode 100644 (file)
index 0000000..19210d0
--- /dev/null
@@ -0,0 +1,56 @@
+From 3abab27c322e0f2acf981595aa8040c9164dc9fb Mon Sep 17 00:00:00 2001
+From: Charles Baylis <cb-kernel@fishzet.co.uk>
+Date: Fri, 16 Jul 2021 17:43:12 +0100
+Subject: drm: Return -ENOTTY for non-drm ioctls
+
+From: Charles Baylis <cb-kernel@fishzet.co.uk>
+
+commit 3abab27c322e0f2acf981595aa8040c9164dc9fb upstream.
+
+drm: Return -ENOTTY for non-drm ioctls
+
+Return -ENOTTY from drm_ioctl() when userspace passes in a cmd number
+which doesn't relate to the drm subsystem.
+
+Glibc uses the TCGETS ioctl to implement isatty(), and without this
+change isatty() returns it incorrectly returns true for drm devices.
+
+To test run this command:
+$ if [ -t 0 ]; then echo is a tty; fi < /dev/dri/card0
+which shows "is a tty" without this patch.
+
+This may also modify memory which the userspace application is not
+expecting.
+
+Signed-off-by: Charles Baylis <cb-kernel@fishzet.co.uk>
+Cc: stable@vger.kernel.org
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Link: https://patchwork.freedesktop.org/patch/msgid/YPG3IBlzaMhfPqCr@stando.fishzet.co.uk
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/drm_ioctl.c |    3 +++
+ include/drm/drm_ioctl.h     |    1 +
+ 2 files changed, 4 insertions(+)
+
+--- a/drivers/gpu/drm/drm_ioctl.c
++++ b/drivers/gpu/drm/drm_ioctl.c
+@@ -797,6 +797,9 @@ long drm_ioctl(struct file *filp,
+       if (drm_dev_is_unplugged(dev))
+               return -ENODEV;
++       if (DRM_IOCTL_TYPE(cmd) != DRM_IOCTL_BASE)
++               return -ENOTTY;
++
+       is_driver_ioctl = nr >= DRM_COMMAND_BASE && nr < DRM_COMMAND_END;
+       if (is_driver_ioctl) {
+--- a/include/drm/drm_ioctl.h
++++ b/include/drm/drm_ioctl.h
+@@ -68,6 +68,7 @@ typedef int drm_ioctl_compat_t(struct fi
+                              unsigned long arg);
+ #define DRM_IOCTL_NR(n)                _IOC_NR(n)
++#define DRM_IOCTL_TYPE(n)              _IOC_TYPE(n)
+ #define DRM_MAJOR       226
+ /**
diff --git a/queue-4.19/nds32-fix-up-stack-guard-gap.patch b/queue-4.19/nds32-fix-up-stack-guard-gap.patch
new file mode 100644 (file)
index 0000000..e373002
--- /dev/null
@@ -0,0 +1,42 @@
+From c453db6cd96418c79702eaf38259002755ab23ff Mon Sep 17 00:00:00 2001
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Tue, 29 Jun 2021 12:40:24 +0200
+Subject: nds32: fix up stack guard gap
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+commit c453db6cd96418c79702eaf38259002755ab23ff upstream.
+
+Commit 1be7107fbe18 ("mm: larger stack guard gap, between vmas") fixed
+up all architectures to deal with the stack guard gap.  But when nds32
+was added to the tree, it forgot to do the same thing.
+
+Resolve this by properly fixing up the nsd32's version of
+arch_get_unmapped_area()
+
+Cc: Nick Hu <nickhu@andestech.com>
+Cc: Greentime Hu <green.hu@gmail.com>
+Cc: Vincent Chen <deanbo422@gmail.com>
+Cc: Michal Hocko <mhocko@suse.com>
+Cc: Hugh Dickins <hughd@google.com>
+Cc: Qiang Liu <cyruscyliu@gmail.com>
+Cc: stable <stable@vger.kernel.org>
+Reported-by: iLifetruth <yixiaonn@gmail.com>
+Acked-by: Hugh Dickins <hughd@google.com>
+Link: https://lore.kernel.org/r/20210629104024.2293615-1-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/nds32/mm/mmap.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/nds32/mm/mmap.c
++++ b/arch/nds32/mm/mmap.c
+@@ -59,7 +59,7 @@ arch_get_unmapped_area(struct file *filp
+               vma = find_vma(mm, addr);
+               if (TASK_SIZE - len >= addr &&
+-                  (!vma || addr + len <= vma->vm_start))
++                  (!vma || addr + len <= vm_start_gap(vma)))
+                       return addr;
+       }
index 7e3ae4fa92b66e5a882bcb4b30bae841dfc2e2b3..1d8f13d31e4a07334357715c958cfc182500c0f7 100644 (file)
@@ -106,3 +106,5 @@ tracing-fix-bug-in-rb_per_cpu_empty-that-might-cause-deadloop.patch
 media-ngene-fix-out-of-bounds-bug-in-ngene_command_config_free_buf.patch
 ixgbe-fix-packet-corruption-due-to-missing-dma-sync.patch
 selftest-use-mmap-instead-of-posix_memalign-to-allocate-memory.patch
+nds32-fix-up-stack-guard-gap.patch
+drm-return-enotty-for-non-drm-ioctls.patch