Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2084577ybb; Fri, 29 Mar 2019 18:39:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNNiBg1DPvqgLsGXII4NODOU2bw945fJ7QmeO9aIDbHe+0a5rM2SfJqEJgCH9CzZCX/m8F X-Received: by 2002:aa7:90c7:: with SMTP id k7mr49758702pfk.186.1553909973412; Fri, 29 Mar 2019 18:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553909973; cv=none; d=google.com; s=arc-20160816; b=l6QJvPqX0m3BKaloCuXklTocPqptoBAfs05hlMNp2orKZANhWB4OrSTvXM8Sk57KG6 6YVZ1uH2tETMlQKK8VdHRHHv+fEZ8Npdyr3i16bI8rJIzVF52Jh7ylaAql6EhbI77fir ivKVfaNst+OPyoDSmrsOpAmAOLjzMD5Q7EeON+dd3ncbyuAn1ei0nXYfK4OnBBojcRFY WF4a+AmzXIblQejgqrbrBUmppskTcfFgsfByBF0evB2DCjr/Gc4nrqgVMtuHSmYnYR9M /zA8iq/0zb8hG3SOJ4tRIp9iovLAtAonVQrIA5zwAhbRExMPyaKru4v+HkwwO+h1oHl/ jwug== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jE7HPTUZ6VWCS7SdAPmdqPYwCqO7H7JglivEaG3dINQ=; b=HLezbITd/fOKqXR97iRkv/u++R7oZ2gqrFRv/ULpd2pz8vIG0b24i4zgfOKOOVKRtx pq3reGvcCxRbfQhLnltAuOH/y/areQJ6RlpTbttulLjEPOJ/wAjYwFPsw0/c7igzuVnJ VRLG2rctllGvHfge112QC0oF3ASXbHtIwTIWuZoJ8UdFojTl7QgtbETPUKnpBnKEBY3F 9j8NG5MMiUYAELn2CtmCQDgd2joSaGxMNa0Tv8YBOQ9OjIKXqH6LAuT02s7x1+Vhr5GT uvAQ6Md+t/WE4JxQN1L4xD3xzIi3DQRwr+OIOIXOxBEAG7VibOgYRfevZ5O3vmMwViFm Zt+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="lO/ZVPXT"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w25si3267533pgc.23.2019.03.29.18.39.18; Fri, 29 Mar 2019 18:39:33 -0700 (PDT) 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=@kernel.org header.s=default header.b="lO/ZVPXT"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731654AbfC3Bip (ORCPT + 99 others); Fri, 29 Mar 2019 21:38:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:37372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731392AbfC3BaO (ORCPT ); Fri, 29 Mar 2019 21:30:14 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9608B218D8; Sat, 30 Mar 2019 01:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909413; bh=qWjm99XOLT/i8r1sif+C2VpV1a2vmTbiwYlyt1RKa+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lO/ZVPXTHqGKuJihWGArz9xOAgFawtfjuj0+8V7o2Hklwly+aq8iqTozeA0I42IAU SdsIOK4zso3eykEwtGB+7hGG8EA71ja3RknhCdgVL6wR8/O9o5cuxEgHPw2SnUq2Jn 56w9yIcmGghDlTYN9eMyV/0PhCpFgElDdLTO36QY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org, Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL 4.19 40/57] kvm: properly check debugfs dentry before using it Date: Fri, 29 Mar 2019 21:28:33 -0400 Message-Id: <20190330012854.32212-40-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330012854.32212-1-sashal@kernel.org> References: <20190330012854.32212-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman [ Upstream commit 8ed0579c12b2fe56a1fac2f712f58fc26c1dc49b ] 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 Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c436d95fd7aa..fb74f994cb63 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3912,7 +3912,7 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm) } 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) { -- 2.19.1