]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
drm/ioctl: Fix Spectre v1 vulnerabilities
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Thu, 20 Dec 2018 00:00:15 +0000 (18:00 -0600)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 24 Apr 2019 08:09:11 +0000 (10:09 +0200)
commitfa846ea5cdae1a68e96a7f3e35d8b17ab23cce35
tree73457df5336b4f209b98d77843db2832bf1c4706
parentb18b75668106cbf4e278242ad4e453d2acb0b279
drm/ioctl: Fix Spectre v1 vulnerabilities

nr is indirectly controlled by user-space, hence leading to a
potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/gpu/drm/drm_ioctl.c:805 drm_ioctl() warn: potential spectre issue 'dev->driver->ioctls' [r]
drivers/gpu/drm/drm_ioctl.c:810 drm_ioctl() warn: potential spectre issue 'drm_ioctls' [r] (local cap)
drivers/gpu/drm/drm_ioctl.c:892 drm_ioctl_flags() warn: potential spectre issue 'drm_ioctls' [r] (local cap)

Fix this by sanitizing nr before using it to index dev->driver->ioctls
and drm_ioctls.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20181220000015.GA18973@embeddedor
CVE-2017-5753

(cherry picked from commit 505b5240329b922f21f91d5b5d1e535c805eca6d)
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/gpu/drm/drm_ioctl.c