Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp486678imu; Fri, 9 Nov 2018 00:43:22 -0800 (PST) X-Google-Smtp-Source: AJdET5ejtKTrxM35LrgjzjsTG215XUfkvEJgl8t9cNpfC1wb5z0KevMRRk1cMud9fIk63MOFut4E X-Received: by 2002:a63:cc12:: with SMTP id x18mr2210582pgf.33.1541753001986; Fri, 09 Nov 2018 00:43:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541753001; cv=none; d=google.com; s=arc-20160816; b=YxzssNfnxWkR7MBMpSQj0WPruuXrYjtETK+Dh7ejJzKyCUkz1Bodn3JOKpI7SA9oNG I1nzHOLASBnM9p+rGvk9n2hA6lJndFca/NZwp+XciSpJwAJxCAiOadk+hNQm7bNcired gfYk722TGuyQNKry6RwbiVTELMsWU2BSHRWgXYbpSenoBYPjEBSyUwzglA5KhMz/+K5g XuV28ZKoDx5zlXoG4LzNIWimpzaJJXMD+DoLm4ks9Y/LFM8za6QM8VINTjE/OdIS9UNl GmkMy8OlDDbWbzc9tz01m+xJhjnatgmGPBPoZN1cvpgg45lEkHeax51PJjHgX/e6aSQc 4YBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=hIv3PmtKc+WOT+FmzLch9Xp9XxHAytlsFHWt2tyMomQ=; b=Nn7uSqYqnrJh+qLBZ9pDqLyAa61oMKp2XDNmhRWmHLBGVw/nEzI21lKkZXj7gof64E qHH/24N9LqAbggcULfUz2Pbwo2zkW6g1U1QCsc1bJKr15gbdh6IGMjrTyP7EVEt3+sHK sbl8PTlVPr75S6IEA7BXBg/T313TleFKLUjArsSadyLivHk+gtPW4PaOPrR6wxqbXOhv HSwv+z+ujnnQ+//qdkLN5mrbhVwB3eVOsGYegzzdSXM7BK1+7IPgs5YBB1yYUWbOrzN+ Mrmii/SsFAk5YVIMH+zeLqIMIRahTsZFmVT0R/tPwDqLgnw1DedS/RDeM7rm78SdpWxK hMcw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n33si5383198pgl.336.2018.11.09.00.43.05; Fri, 09 Nov 2018 00:43:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727634AbeKISWS (ORCPT + 99 others); Fri, 9 Nov 2018 13:22:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:46930 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727518AbeKISWS (ORCPT ); Fri, 9 Nov 2018 13:22:18 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A7450AD4E; Fri, 9 Nov 2018 08:42:42 +0000 (UTC) Subject: Re: UBSAN: Undefined behaviour in mm/page_alloc.c To: Kyungtae Kim , akpm@linux-foundation.org, mhocko@suse.com, pavel.tatashin@microsoft.com, 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, Konstantin Khlebnikov References: From: Vlastimil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J2DD+IrDAGLHwPhCr RyfKalnrbYokvbClM9EuU1oUuh7k+Sg5ECNXEsamW9AiWGCaKWNDdHre3Lf4xl+RJWxghOVW RiUdpLA/a3yDvJNVr6rxkDHQ1P24ZZz/VKDyP+6g8aty2aWEU0YFNjI+rqYZb2OppDx6fdma YnLDcIfDFnkVlDmpznnGCyEqLLyMS3GH52AH13zMT9L9QYgT303+r6QQpKBIxAwn8Jg8dAlV OLhgeHXKr+pOQdFf6iu2sXlUR4MkO/5KWM1K0jFR2ug8Pb3aKOhowVMBT64G0TXhQ/kX4tZ2 ZF0QZLUCHU3Cigvbu4AWWVMNDEOGD/4sn9OoHxm6J04jLUHFUpFKDcjab4NRNWoHLsuLGjve Gdbr2RKO2oJ5qZj81K7os0/5vTAA4qHDP2EETAQcunTn6aPlkUnJ8aw6I1Rwyg7/XsU7gQHF IM/cUMuWWm7OUUPtJeR8loxZiZciU7SMvN1/B9ycPMFs/A6EEzyG+2zKryWry8k7G/pcPrFx O2PkDPy3YmN1RfpIX2HEmnCEFTTCsKgYORangFu/qOcXvM83N+2viXxG4mjLAMiIml1o2lKV cqmP8roqufIAj+Ohhzs= Message-ID: <074309b9-ada4-ce39-5332-d64a1263e9f8@suse.cz> Date: Fri, 9 Nov 2018 09:42:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/9/18 5:09 AM, Kyungtae Kim wrote: > 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. This together with [1] makes me rather convinced that we should really move the check back from __alloc_pages_slowpath to __alloc_pages_nodemask. It should be a single predictable branch with an unlikely()? [1] https://lore.kernel.org/lkml/154109387197.925352.10499549042420271600.stgit@buzz/T/#u > ========================================= > 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 >