Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756081Ab1DJLKE (ORCPT ); Sun, 10 Apr 2011 07:10:04 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:36855 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753127Ab1DJLKC (ORCPT ); Sun, 10 Apr 2011 07:10:02 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=fS0D8tIkhw3oBx8dD9NoH4p70pkvqoEO6R4WHsr5Ue6qgr6oucYXTsKRaWAYDRD5Ly mJQFpRGIaeka9dgGWZlqckwnDvAVL4gLooJNamku27KXHjYGo/zFw8DMYPWm9aAVc0dn OHmRcqMpa7/vA8Ft0Fz5omhPAaULrI3ZdscCE= MIME-Version: 1.0 Date: Sun, 10 Apr 2011 19:10:01 +0800 Message-ID: Subject: [2.6.39-rc2, framebuffer] use after free oops From: Daniel J Blueman To: Paul Mundt , linux-fbdev@vger.kernel.org Cc: Linux Kernel Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3955 Lines: 86 When building in the eg vga16 and intelfb framebuffers and page debugging, we can get hit by a use-after-free oops [1]; with page debugging disabled, this slips by unnoticed. When intelfb registers, the vga16 framebuffer is detected covering it's I/O regions, so it is removed (in remove_conflicting_framebuffers->unregister_framebuffer). The problem is the fb_info structure is freed (in unregister_framebuffer->vga16fb_destroy->framebuffer_release->kfree) before all open files to it are closed, so we get a use-after-free scenario. Freeing should be deferred until the last user has gone away. What approach would make sense here? Daniel --- [1] checking generic (a0000 10000) vs hw (d0000000 10000000) fb: conflicting fb hw usage inteldrmfb vs VGA16 VGA - removing generic driver Console: switching to colour VGA+ 80x25 BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 IP: [] mutex_lock_nested+0x94/0x390 PGD 2203ab067 PUD 2203ac067 PMD 0 Oops: 0002 [#2] PREEMPT SMP DEBUG_PAGEALLOC last sysfs file: /sys/devices/pci0000:00/0000:00:1b.0/sound/card0/uevent CPU 3 Modules linked in: arc4 ecb uvcvideo videodev v4l2_compat_ioctl32 i915(+) drm_kms_helper iwlagn mmc_block mac80211 drm video sdhci_pci sdhci mmc_core Pid: 271, comm: plymouthd Tainted: G D 2.6.39-rc2-350cd+ #1 Dell Inc. Latitude E5420/0H5TG2 RIP: 0010:[] [] mutex_lock_nested+0x94/0x390 RSP: 0018:ffff88021ee77c08 EFLAGS: 00010046 RAX: 0000000000010000 RBX: 0000000000000008 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffffffff8170838b RBP: ffff88021ee77c78 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88021e574020 R13: 0000000000000010 R14: 0000000000000246 R15: ffff88021de6f478 FS: 00007f50d6e9c720(0000) GS:ffff88022ec60000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000010 CR3: 00000002203aa000 CR4: 00000000000406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process plymouthd (pid: 271, threadinfo ffff88021ee76000, task ffff88021e574020) Stack: ffffffff81375552 0000000000000000 00000000fffffff2 ffff88021de6f478 ffff88021e574020 0000000000000246 0000000000000000 00000000fffffff2 ffff88021ee77c68 0000000000000000 0000000000000008 0000000000000000 Call Trace: [] ? lock_fb_info+0x22/0x60 [] lock_fb_info+0x22/0x60 [] fb_set_user_cmap+0x15b/0x1a0 [] do_fb_ioctl+0x4b8/0x5e0 [] ? might_fault+0x4e/0xa0 [] ? get_parent_ip+0x11/0x50 [] ? sub_preempt_count+0x9d/0xd0 [] ? _raw_spin_unlock_irqrestore+0x3d/0x80 [] ? __wake_up+0x4e/0x70 [] ? put_ldisc+0x59/0xd0 [] ? tty_ldisc_deref+0x9/0x10 [] ? tty_ioctl+0x299/0xa00 [] fb_ioctl+0x24/0x30 [] do_vfs_ioctl+0x87/0x330 [] ? fget+0x95/0x240 [] ? fget_raw+0x240/0x240 [] sys_ioctl+0x4a/0x80 [] system_call_fastpath+0x16/0x1b Code: 48 8b 04 25 c8 b5 00 00 8b 80 44 e0 ff ff a9 00 ff ff 07 0f 85 d7 02 00 00 9c 41 5e fa e8 15 d2 98 ff 4c 8d 6b 08 b8 00 00 01 00 0f c1 43 08 0f b7 d0 c1 e8 10 39 c2 74 08 f3 90 0f b7 53 08 RIP [] mutex_lock_nested+0x94/0x390 RSP CR2: 0000000000000010 ---[ end trace cdacd65f5f1b187d ]--- note: plymouthd[271] exited with preempt_count 1 -- Daniel J Blueman -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/