https://github.com/torvalds/linux
Revision ec67aaa46dce26d671b46c94ac674ad0b67d044c authored by Davidlohr Bueso on 14 June 2018, 22:27:51 UTC, committed by Linus Torvalds on 14 June 2018, 22:55:25 UTC
Both smatch and coverity are reporting potential issues with spectre
variant 1 with the 'semnum' index within the sma->sems array, ie:

  ipc/sem.c:388 sem_lock() warn: potential spectre issue 'sma->sems'
  ipc/sem.c:641 perform_atomic_semop_slow() warn: potential spectre issue 'sma->sems'
  ipc/sem.c:721 perform_atomic_semop() warn: potential spectre issue 'sma->sems'

Avoid any possible speculation by using array_index_nospec() thus
ensuring the semnum value is bounded to [0, sma->sem_nsems).  With the
exception of sem_lock() all of these are slowpaths.

Link: http://lkml.kernel.org/r/20180423171131.njs4rfm2yzyeg6do@linux-n805
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f1b4bd0
History
Tip revision: ec67aaa46dce26d671b46c94ac674ad0b67d044c authored by Davidlohr Bueso on 14 June 2018, 22:27:51 UTC
sysvipc/sem: mitigate semnum index against spectre v1
Tip revision: ec67aaa
File Mode Size
Kconfig -rw-r--r-- 2.3 KB
Makefile -rw-r--r-- 492 bytes
actions.c -rw-r--r-- 36.8 KB
conntrack.c -rw-r--r-- 58.2 KB
conntrack.h -rw-r--r-- 3.1 KB
datapath.c -rw-r--r-- 60.0 KB
datapath.h -rw-r--r-- 7.4 KB
dp_notify.c -rw-r--r-- 2.6 KB
flow.c -rw-r--r-- 23.3 KB
flow.h -rw-r--r-- 8.4 KB
flow_netlink.c -rw-r--r-- 85.5 KB
flow_netlink.h -rw-r--r-- 3.1 KB
flow_table.c -rw-r--r-- 18.9 KB
flow_table.h -rw-r--r-- 2.8 KB
meter.c -rw-r--r-- 14.4 KB
meter.h -rw-r--r-- 1.2 KB
vport-geneve.c -rw-r--r-- 3.1 KB
vport-gre.c -rw-r--r-- 2.7 KB
vport-internal_dev.c -rw-r--r-- 7.4 KB
vport-internal_dev.h -rw-r--r-- 1.0 KB
vport-netdev.c -rw-r--r-- 5.4 KB
vport-netdev.h -rw-r--r-- 1.1 KB
vport-vxlan.c -rw-r--r-- 4.3 KB
vport.c -rw-r--r-- 12.9 KB
vport.h -rw-r--r-- 6.2 KB

back to top