From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 047F7C43381 for ; Thu, 28 Feb 2019 15:25:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C873520C01 for ; Thu, 28 Feb 2019 15:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551367499; bh=Jz5VDi7UV+WTpAAFZWCheUBHUAl0P0Hs3Ay6DdkK5eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=J8cxST3gKb7M6Vpjh68wu+tLXs9FzdQS4YVL+PMWst/c7jXU1w/GoSRvKilA1g1LW 91Ux8m9tHgl6U0LFMDuiQ/+i+QHp2MA42XaUopT54xId3mSJpsMmRBj2t5RIEkNtxW ajXUD+Uo1xrgVqhYwonyEDQIEGfQbyr0iK1SD55A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727924AbfB1PYx (ORCPT ); Thu, 28 Feb 2019 10:24:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:45628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388201AbfB1PMO (ORCPT ); Thu, 28 Feb 2019 10:12:14 -0500 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 39E8B218D8; Thu, 28 Feb 2019 15:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551366733; bh=Jz5VDi7UV+WTpAAFZWCheUBHUAl0P0Hs3Ay6DdkK5eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NVfZgU/sLrDc0zXL3D7NFFAtYzmK2G+rrTAAl7pdJAlqp+l+niwaWBv3i7OFjHECK rdKMMP7SHKyg7TeCJq0zcnAFk4IPJbO455uTIGaHle8cVsmETAmv8ib3F2ZheKZO44 jP82uEqswSywKfsF/LhMUVSKF/zDT/EF+gayG0vQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 34/64] blk-mq: protect debugfs_create_files() from failures Date: Thu, 28 Feb 2019 10:10:35 -0500 Message-Id: <20190228151105.11277-34-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190228151105.11277-1-sashal@kernel.org> References: <20190228151105.11277-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Greg Kroah-Hartman [ Upstream commit 36991ca68db9dd43bac7f3519f080ee3939263ef ] If debugfs were to return a non-NULL error for a debugfs call, using that pointer later in debugfs_create_files() would crash. Fix that by properly checking the pointer before referencing it. Reported-by: Michal Hocko Reported-and-tested-by: syzbot+b382ba6a802a3d242790@syzkaller.appspotmail.com Reported-by: Tetsuo Handa Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- block/blk-mq-debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index cb1e6cf7ac48f..9dc3a0896462f 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -806,6 +806,9 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = { static bool debugfs_create_files(struct dentry *parent, void *data, const struct blk_mq_debugfs_attr *attr) { + if (IS_ERR_OR_NULL(parent)) + return false; + d_inode(parent)->i_private = data; for (; attr->name; attr++) { -- 2.19.1