From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752851AbcCGOaZ (ORCPT ); Mon, 7 Mar 2016 09:30:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:55666 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752734AbcCGOaQ (ORCPT ); Mon, 7 Mar 2016 09:30:16 -0500 Date: Mon, 07 Mar 2016 15:30:15 +0100 Message-ID: From: Takashi Iwai To: dri-devel@lists.freedesktop.org Cc: Jiri Slaby , Gerd Hoffmann , Dave Airlie , linux-kernel@vger.kernel.org Subject: Kernel WARNING via bochsdrmfb mmap User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.5 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Jiri Slaby reported a kernel WARNING triggered by syzkaller. It can be reliably reproduced via fbdev mmap access on bochs drm. The warning looks like below: WARNING: CPU: 3 PID: 29356 at ../drivers/gpu/drm/ttm/ttm_bo_vm.c:265 ttm_bo_vm_open+0x11a/0x180 [ttm]() Modules linked in: ... Supported: Yes CPU: 3 PID: 29356 Comm: syz-executor Tainted: G E 4.4.3-0-default #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.1-0-g4adadbd-20151112_172657-sheep25 04/01/2014 0000000000000003 ffff880036cbfb50 ffffffff819eae91 0000000000000000 ffff880035294000 ffffffffa0a46d60 0000000000000009 ffff880036cbfb90 ffffffff8116face ffffffffa0a34e5a ffffffffa0a46d60 0000000000000109 Call Trace: [] ? dump_stack+0xb3/0x112 [] ? warn_slowpath_common+0xde/0x140 [] ? ttm_bo_vm_open+0x11a/0x180 [ttm] [] ? ttm_bo_vm_fault+0xe70/0xe70 [ttm] [] ? warn_slowpath_null+0x2e/0x40 [] ? ttm_bo_vm_open+0x11a/0x180 [ttm] [] ? __split_vma.isra.30+0x3ed/0x7f0 [] ? do_munmap+0xd14/0x1010 [] ? __lock_acquire+0xb3d/0x49d0 [] ? mmap_region+0x1d5/0x11d0 [] ? cap_mmap_addr+0x46/0x110 [] ? do_mmap+0x758/0x990 [] ? vm_mmap_pgoff+0x164/0x1b0 [] ? task_of_stack+0x240/0x240 [] ? SyS_mmap_pgoff+0xcd/0x590 [] ? vm_stat_account+0x130/0x130 [] ? security_file_ioctl+0x91/0xc0 [] ? lockdep_sys_exit_thunk+0x12/0x14 [] ? SyS_mmap+0x1b/0x30 [] ? entry_SYSCALL_64_fastpath+0x12/0x76 The bug was confirmed to happen on the latest vanilla 4.5-rc6, too. The reproducer code is attached below. Judging from the code, it comes from the fact that vma->vm_file->f_mapping via fbdev access isn't changed to bodev's one. In the case of /dev/dri/*, f_mapping is replaced in drm_open(). But, fbdev open doesn't change f_mapping, and its callback doesn't take the file pointer, so there is no way to fiddle with it there, either. What's the preferred way to fix this? I can think of several ways, e.g. - adding f_mapping pointer field in struct fb_info - passing the file pointer in fbdev open callback so that f_mapping can be corrected - adjusting f_mapping in vm_open dynamically (is it safe?) or - drop WARN_ON() :) thanks, Takashi --- #include #include #include #include #include #include #include int main(void) { void *addr; int fd = open("/dev/fb0", O_RDONLY); if (fd < 0) err(1, "open"); addr = mmap(0, 8192, PROT_READ, MAP_SHARED, fd, 0); if (addr == MAP_FAILED) err(1, "1st mmap"); if (mmap(addr, 4096, PROT_READ, MAP_SHARED | MAP_FIXED | MAP_ANONYMOUS, -1, 0) == MAP_FAILED) err(1, "2nd mmap"); return 0; }