Repository navigation
Commit ec67aaa
sysvipc/sem: mitigate semnum index against spectre v1
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 commit ec67aaa
1 file changed
Lines changed: 14 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
368 | 369 | | |
369 | 370 | | |
370 | 371 | | |
| 372 | + | |
371 | 373 | | |
372 | 374 | | |
373 | 375 | | |
| |||
385 | 387 | | |
386 | 388 | | |
387 | 389 | | |
388 | | - | |
| 390 | + | |
| 391 | + | |
389 | 392 | | |
390 | 393 | | |
391 | 394 | | |
| |||
638 | 641 | | |
639 | 642 | | |
640 | 643 | | |
641 | | - | |
| 644 | + | |
| 645 | + | |
642 | 646 | | |
643 | 647 | | |
644 | 648 | | |
| |||
718 | 722 | | |
719 | 723 | | |
720 | 724 | | |
721 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
722 | 728 | | |
723 | 729 | | |
724 | 730 | | |
| |||
1356 | 1362 | | |
1357 | 1363 | | |
1358 | 1364 | | |
| 1365 | + | |
1359 | 1366 | | |
1360 | 1367 | | |
1361 | 1368 | | |
| |||
1509 | 1516 | | |
1510 | 1517 | | |
1511 | 1518 | | |
| 1519 | + | |
| 1520 | + | |
1512 | 1521 | | |
1513 | 1522 | | |
1514 | 1523 | | |
| |||
2081 | 2090 | | |
2082 | 2091 | | |
2083 | 2092 | | |
2084 | | - | |
| 2093 | + | |
| 2094 | + | |
2085 | 2095 | | |
2086 | 2096 | | |
2087 | 2097 | | |
| |||
0 commit comments