Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp297140imu; Thu, 8 Nov 2018 20:10:14 -0800 (PST) X-Google-Smtp-Source: AJdET5fv+/4adsN19n1Pu0qvZ3jSC+2ZB0V4R6TO8qu/NCTmsSaG7dvhPe2zxG6AzQsUtL4mOl4r X-Received: by 2002:a62:418a:: with SMTP id g10-v6mr7340355pfd.44.1541736614472; Thu, 08 Nov 2018 20:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541736614; cv=none; d=google.com; s=arc-20160816; b=ckGI85e8neYjs/eujvx8ZszZ7zsi61lgPpA919u07kFnue9Nv3AC71XEaUFzi0xLzq NbTsOHmXQ2eTg/uhgnnDQnzJ/vzhA90MIAsRKbh2fYyvj1nrz1xGhHKd2fidEHsr0Ix5 W9cW7EKmWmWdpRVkcyAS2KDSB0Kgxqbqvz8e/8+paG5dpH7exJySIpakjow/+2WreaxE 9b01WhhbGeMMaSoRlb/Io1RZKpkc/6AElxyiNVQYpfPjqjuzK7BJ9AOLSw8AHejWdWr7 G/15EeATAi4P6JzN1s3rS08w3/yoppQNwllD8FmwAz3g008Pf/P4I2IS7wEx4WmA4PKr Uymw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature; bh=QZTt1M1Bhslsqs5FDY7sztKF5nMC2rhSbk9Lt25tVAM=; b=C9yYD+SOMAidO5W3FVhywlMZMTZ/hxuRzpXvGrBVZje3vWWR8WfBaq4LGQHMffvHzM 4e9Xani2pAs+qgOZLbU0NjKU3CWIKbxDEVmqltf3OESjO02tzvNfCTSgsl9wiSsZbgck eiPINWQvUxPaWocBgLiTWdnob94jIHLstjcOXmMlb1dW5/MjsySKkQNVo0UqS1Wgufps 229/feHgLJGt2+KbpBonXP3t0Rb1nwZyGFgNlbomzWUtRc9QW0O4nd/wakN06Fu0gXch YQzrSLpjqPnaY/kMosjUiSoxPYFFFm0sESRD6nbJBFXm7XmyVBq2/yBEF9hy8h+8TRA9 Imkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mwOBQfXF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f23-v6si4954362pgl.207.2018.11.08.20.09.56; Thu, 08 Nov 2018 20:10:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mwOBQfXF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727514AbeKINsT (ORCPT + 99 others); Fri, 9 Nov 2018 08:48:19 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:44531 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727378AbeKINsT (ORCPT ); Fri, 9 Nov 2018 08:48:19 -0500 Received: by mail-io1-f65.google.com with SMTP id c6-v6so365437iob.11 for ; Thu, 08 Nov 2018 20:09:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=QZTt1M1Bhslsqs5FDY7sztKF5nMC2rhSbk9Lt25tVAM=; b=mwOBQfXFfb1JdZdmauszOr310DoiIag9mbZ0eaHEZdYHkIXgrqnXCsmwGAc+RDOgaS vy9DmvKhq0s/xnvKhw9WxYPhJxX+/Yo5NjFLb4WgK13uTyndXyB9ye4yZ7hntjO2nT0F HKIqA51rPPHukiRRcUSEqEuvT768JV21AYxiLU3R0u17gmrIrAbZN5QZsAqc55dmTJC1 6sVpFXC88siDJDZeLqvzTvUguw4c52svSFvd8VUsPgzX/zSkYP9By9XF9wbMXjKLuESY cPsuawCrMg3oaNQjmgZrAYdTpPmzdqOYlIqq1fjbvdQZpuZxDWA9v9BeUfmkc9HCguIW XR8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=QZTt1M1Bhslsqs5FDY7sztKF5nMC2rhSbk9Lt25tVAM=; b=cZvqvXXAH1S/A2H1yW1x7LyDCdu5Lp9KYZwksT5oPVRasjlqt+Y4X4uRNUJBihJPMQ auqtMRFgyQoecpVEeo8IS+GJ+D8UkrqtpyyuwNhpakJYZ64ZrJxDUoHa+ue4hkQoYKpk FfWFaZrkkdtHNjSIHLQUwdS7p3SwRyhYakXoRMhaMEScSIyWkzUmv59i88EERyL9F6KT qpcUd5q+DM9PW07HisjSl/5jis89RgeKT6MlIszYQg2kP2FMLWiisVIVEP9obTEFG7IR 0pfF47GYDouYx9omYhOy9sdf0Pl6qjlhZXkCrAEElFduWctapZR2tdPK+fo0BVRMI4Oa zk/Q== X-Gm-Message-State: AGRZ1gLC0yd8zRhIM+cVLq+ZrFC7z28Wjtc3DcIn20j6IaFqZHL61eGo 3Fswyl/HZLBhz9LEsBI+Ti3IB+qEfeSIuc9TSi8= X-Received: by 2002:a6b:d305:: with SMTP id s5-v6mr4809061iob.190.1541736575098; Thu, 08 Nov 2018 20:09:35 -0800 (PST) MIME-Version: 1.0 From: Kyungtae Kim Date: Thu, 8 Nov 2018 23:09:23 -0500 Message-ID: Subject: UBSAN: Undefined behaviour in mm/page_alloc.c To: akpm@linux-foundation.org, mhocko@suse.com, pavel.tatashin@microsoft.com, vbabka@suse.cz, osalvador@suse.de, rppt@linux.vnet.ibm.com, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, alexander.h.duyck@linux.intel.com, mgorman@techsingularity.net Cc: lifeasageek@gmail.com, threeearcat@gmail.com, syzkaller@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We report a bug in v4.19-rc2 (4.20-rc1 as well, I guess): kernel config: https://kt0755.github.io/etc/config_v2-4.19 repro: https://kt0755.github.io/etc/repro.c4074.c In the middle of page request, this arose because order is too large to handle (mm/page_alloc.c:3119). It actually comes from that order is controllable by user input via raw_cmd_ioctl without its sanity check, thereby causing memory problem. To stop it, we can use like MAX_ORDER for bounds check before using it. ========================================= UBSAN: Undefined behaviour in mm/page_alloc.c:3117:19 shift exponent 51 is too large for 32-bit type 'int' CPU: 0 PID: 6520 Comm: syz-executor1 Not tainted 4.19.0-rc2 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xd2/0x148 lib/dump_stack.c:113 ubsan_epilogue+0x12/0x94 lib/ubsan.c:159 __ubsan_handle_shift_out_of_bounds+0x2b6/0x30b lib/ubsan.c:425 __zone_watermark_ok+0x2c7/0x400 mm/page_alloc.c:3117 zone_watermark_fast mm/page_alloc.c:3216 [inline] get_page_from_freelist+0xc49/0x44c0 mm/page_alloc.c:3300 __alloc_pages_nodemask+0x21e/0x640 mm/page_alloc.c:4370 alloc_pages_current+0xcc/0x210 mm/mempolicy.c:2093 alloc_pages include/linux/gfp.h:509 [inline] __get_free_pages+0x12/0x60 mm/page_alloc.c:4414 dma_mem_alloc+0x36/0x50 arch/x86/include/asm/floppy.h:156 raw_cmd_copyin drivers/block/floppy.c:3159 [inline] raw_cmd_ioctl drivers/block/floppy.c:3206 [inline] fd_locked_ioctl+0xa00/0x2c10 drivers/block/floppy.c:3544 fd_ioctl+0x40/0x60 drivers/block/floppy.c:3571 __blkdev_driver_ioctl block/ioctl.c:303 [inline] blkdev_ioctl+0xb3c/0x1a30 block/ioctl.c:601 block_ioctl+0x105/0x150 fs/block_dev.c:1883 vfs_ioctl fs/ioctl.c:46 [inline] do_vfs_ioctl+0x1c0/0x1150 fs/ioctl.c:687 ksys_ioctl+0x9e/0xb0 fs/ioctl.c:702 __do_sys_ioctl fs/ioctl.c:709 [inline] __se_sys_ioctl fs/ioctl.c:707 [inline] __x64_sys_ioctl+0x7e/0xc0 fs/ioctl.c:707 do_syscall_64+0xc4/0x510 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4497b9 Code: e8 8c 9f 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 9b 6b fc ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fb5ef0e2c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fb5ef0e36cc RCX: 00000000004497b9 RDX: 0000000020000040 RSI: 0000000000000258 RDI: 0000000000000014 RBP: 000000000071bea0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 0000000000005490 R14: 00000000006ed530 R15: 00007fb5ef0e3700 ========================================================= Thanks, Kyungtae Kim