From patchwork Thu Feb 28 15:34:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10833361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E3BA1515 for ; Thu, 28 Feb 2019 15:34:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E26B2ECFB for ; Thu, 28 Feb 2019 15:34:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 201C42F055; Thu, 28 Feb 2019 15:34:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2592ECFB for ; Thu, 28 Feb 2019 15:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387509AbfB1Pel (ORCPT ); Thu, 28 Feb 2019 10:34:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:35766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732065AbfB1Pek (ORCPT ); Thu, 28 Feb 2019 10:34:40 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A3B59206DD; Thu, 28 Feb 2019 15:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551368080; bh=fJK6iMzVu0kVdh0LvvygSDe9BB+1XB4OIFTMCsjXWH8=; h=Date:From:To:Cc:Subject:From; b=MrnjIUGhQYCBUFZqVBISbCFt65iTZqGIvbTw3c1L4+4MNWQ/HRV/cMgRORfqfU5I+ iOuBiWw3zVaPVKBp/q+bGN5EgQj2XvjbRlN/fILpHE78hr3Uv0Z/Y50jqNR68wFV+O 2y8KUMiFis5q+NpiIJsGfP6smlGrxo38yMniKptw= Date: Thu, 28 Feb 2019 16:34:37 +0100 From: Greg Kroah-Hartman To: Linus Torvalds Cc: Paolo Bonzini , Radim =?utf-8?b?S3LEjW3DocWZ?= , Eric Biggers , kvm@vger.kernel.org, syzbot , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, penguin-kernel@i-love.sakura.ne.jp, syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk Subject: [PATCH] kvm: properly check debugfs dentry before using it Message-ID: <20190228153437.GI8481@kroah.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP debugfs can now report an error code if something went wrong instead of just NULL. So if the return value is to be used as a "real" dentry, it needs to be checked if it is an error before dereferencing it. This is now happening because of ff9fb72bc077 ("debugfs: return error values, not NULL"). syzbot has found a way to trigger multiple debugfs files attempting to be created, which fails, and then the error code gets passed to dentry_path_raw() which obviously does not like it. Reported-by: Eric Biggers Reported-and-tested-by: syzbot+7857962b4d45e602b8ad@syzkaller.appspotmail.com Cc: "Radim Krčmář" Cc: kvm@vger.kernel.org Acked-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- Linus, this should go in before 5.0-final is out, as it resolves a problem found by syzbot. Paolo has given his ack for me to send this directly to you. If you want this in [GIT PULL] format, I can do that as well. virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4044,7 +4044,7 @@ static void kvm_uevent_notify_change(uns } add_uevent_var(env, "PID=%d", kvm->userspace_pid); - if (kvm->debugfs_dentry) { + if (!IS_ERR_OR_NULL(kvm->debugfs_dentry)) { char *tmp, *p = kmalloc(PATH_MAX, GFP_KERNEL); if (p) {