Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1711653
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.12 03/65] futex: Remove unnecessary warning from get_futex_key |
| Date | 2017-08-15 03:40 +0200 |
| Message-ID | <ueyZP-3cJ-7@gated-at.bofh.it> (permalink) |
| References | <ueyQ9-39h-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mel Gorman <mgorman@suse.de>
commit 48fb6f4db940e92cfb16cd878cddd59ea6120d06 upstream.
Commit 65d8fc777f6d ("futex: Remove requirement for lock_page() in
get_futex_key()") removed an unnecessary lock_page() with the
side-effect that page->mapping needed to be treated very carefully.
Two defensive warnings were added in case any assumption was missed and
the first warning assumed a correct application would not alter a
mapping backing a futex key. Since merging, it has not triggered for
any unexpected case but Mark Rutland reported the following bug
triggering due to the first warning.
kernel BUG at kernel/futex.c:679!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 3695 Comm: syz-executor1 Not tainted 4.13.0-rc3-00020-g307fec773ba3 #3
Hardware name: linux,dummy-virt (DT)
task: ffff80001e271780 task.stack: ffff000010908000
PC is at get_futex_key+0x6a4/0xcf0 kernel/futex.c:679
LR is at get_futex_key+0x6a4/0xcf0 kernel/futex.c:679
pc : [<ffff00000821ac14>] lr : [<ffff00000821ac14>] pstate: 80000145
The fact that it's a bug instead of a warning was due to an unrelated
arm64 problem, but the warning itself triggered because the underlying
mapping changed.
This is an application issue but from a kernel perspective it's a
recoverable situation and the warning is unnecessary so this patch
removes the warning. The warning may potentially be triggered with the
following test program from Mark although it may be necessary to adjust
NR_FUTEX_THREADS to be a value smaller than the number of CPUs in the
system.
#include <linux/futex.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <unistd.h>
#define NR_FUTEX_THREADS 16
pthread_t threads[NR_FUTEX_THREADS];
void *mem;
#define MEM_PROT (PROT_READ | PROT_WRITE)
#define MEM_SIZE 65536
static int futex_wrapper(int *uaddr, int op, int val,
const struct timespec *timeout,
int *uaddr2, int val3)
{
syscall(SYS_futex, uaddr, op, val, timeout, uaddr2, val3);
}
void *poll_futex(void *unused)
{
for (;;) {
futex_wrapper(mem, FUTEX_CMP_REQUEUE_PI, 1, NULL, mem + 4, 1);
}
}
int main(int argc, char *argv[])
{
int i;
mem = mmap(NULL, MEM_SIZE, MEM_PROT,
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
printf("Mapping @ %p\n", mem);
printf("Creating futex threads...\n");
for (i = 0; i < NR_FUTEX_THREADS; i++)
pthread_create(&threads[i], NULL, poll_futex, NULL);
printf("Flipping mapping...\n");
for (;;) {
mmap(mem, MEM_SIZE, MEM_PROT,
MAP_FIXED | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
}
return 0;
}
Reported-and-tested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/futex.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -670,13 +670,14 @@ again:
* this reference was taken by ihold under the page lock
* pinning the inode in place so i_lock was unnecessary. The
* only way for this check to fail is if the inode was
- * truncated in parallel so warn for now if this happens.
+ * truncated in parallel which is almost certainly an
+ * application bug. In such a case, just retry.
*
* We are not calling into get_futex_key_refs() in file-backed
* cases, therefore a successful atomic_inc return below will
* guarantee that get_futex_key() will still imply smp_mb(); (B).
*/
- if (WARN_ON_ONCE(!atomic_inc_not_zero(&inode->i_count))) {
+ if (!atomic_inc_not_zero(&inode->i_count)) {
rcu_read_unlock();
put_page(page);
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.12 00/65] 4.12.8-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 36/65] staging: comedi: comedi_fops: do not call blocking ops when !TASK_RUNNING Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 62/65] MIPS: DEC: Fix an int-handler.S CPU_DADDI_WORKAROUNDS regression Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 53/65] pnfs/blocklayout: require 64-bit sector_t Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 31/65] iio: accel: st_accel: add SPI-3wire support Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 45/65] usb: core: unlink urbs from the tail of the endpoints urb_list Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 29/65] staging:iio:resolver:ad2s1210 fix negative IIO_ANGL_VEL read Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 09/65] mtd: nand: atmel: Fix DT backward compatibility in pmecc.c Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 58/65] pinctrl: uniphier: fix WARN_ON() of pingroups dump on LD20 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 30/65] iio: aspeed-adc: wait for initial sequence. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:30 +0200
[PATCH 4.12 24/65] USB: serial: option: add D-Link DWM-222 device ID Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 11/65] mtd: nand: Declare tBERS, tR and tPROG as u64 to avoid integer overflow Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 03/65] futex: Remove unnecessary warning from get_futex_key Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 26/65] USB: serial: pl2303: add new ATEN device id Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 07/65] xfs: Fix leak of discard bio Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 02/65] mm: fix list corruptions on shmem shrinklist Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 17/65] i2c: designware: Some broken DSTDs use 1MiHz instead of 1MHz Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 05/65] xtensa: mm/cache: add missing EXPORT_SYMBOLs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 06/65] xtensa: dont limit csum_partial export by CONFIG_NET Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 23/65] drm/i915: Fix out-of-bounds array access in bdw_load_gamma_lut Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 21/65] drm/bridge: tc358767: fix probe without attached output node Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 20/65] nfs/flexfiles: fix leak of nfs4_ff_ds_version arrays Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 16/65] fuse: initialize the flock flag in fuse_file on allocation Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 12/65] iscsi-target: fix memory leak in iscsit_setup_text_cmd() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 15/65] target: Fix node_acl demo-mode + uncached dynamic shutdown regression Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 18/65] nand: fix wrong default oob layout for small pages using soft ecc Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 01/65] mm: ratelimit PFNs busy info message Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 08/65] pinctrl: armada-37xx: Fix number of pin in south bridge Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 13/65] iscsi-target: Fix iscsi_np reset hung task during parallel delete Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 27/65] usb: musb: fix tx fifo flush handling again Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 19/65] mmc: mmc: correct the logic for setting HS400ES signal voltage Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 22/65] drm/etnaviv: Fix off-by-one error in reloc checking Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 04/65] xtensa: fix cache aliasing handling code for WT cache Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
[PATCH 4.12 14/65] usb-storage: fix deadlock involving host lock and scsi_done Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 03:40 +0200
Re: [PATCH 4.12 00/65] 4.12.8-stable review Guenter Roeck <linux@roeck-us.net> - 2017-08-15 12:50 +0200
Re: [PATCH 4.12 00/65] 4.12.8-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 16:40 +0200
Re: [PATCH 4.12 00/65] 4.12.8-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-08-15 20:10 +0200
Re: [PATCH 4.12 00/65] 4.12.8-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-15 20:20 +0200
csiph-web