Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2083650ybb; Fri, 29 Mar 2019 18:37:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyROUObUPJLtSl/h+CwRbzBUWnn3Eg0Ge6EOj4Zn5dXkRWv8TDTbHQNxgHS7x0qht3+9ump X-Received: by 2002:a65:5c4b:: with SMTP id v11mr47936049pgr.411.1553909866366; Fri, 29 Mar 2019 18:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553909866; cv=none; d=google.com; s=arc-20160816; b=dxyWRx1YYvzJa7IM9dWhxuefZFJGhxF1+4EUaAqyMpVfzeBSotAtzdXfTvL0hTyXbi K8ecPP2rpMeo1NhN7ZjRVFYUVOo5nbJGnKTcjtyk+Gb7Cmle80wSWxi7IRuLo+SJtdew IHR2JEHHxTyt2Y3L6SXPP8elrsLW/MnUanU0g0HpS6ZHZeCVIzBOu5RHQSQjNN3ANECf aEEf9H4/aQGjHw79yQnoDdI0vE6ElbaHayHHhjq62dnbzvhtKB11fnR5lv5D7RPPv3zi FyJnUAgmrI4vmDzbQUkdqEk4ovVCOqIhVBN9s/DXUrC566VmZwWS14OSOabvA2JKrBSh n6XQ== 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=9zZCsDsKHqZaLIMHfGM6ECno13B1nuMURN+BinNTk6w=; b=ozz/9XQQ5THKmAvxQ8d7V0MQfFIzkCCTLcUzE2Q66w/P+tWiRzAwwIpEiyMu9ttKs2 V6riZ0bBBzAuCJ0fFhVh5D2bYpj6IfWLOtVseeaQxoYnt1Ji/6929RyV9uXRY297G/Gk VS2F615ZQUH2hYBqjVfsiX1WaQ8p0D20Zmz4ih9a2gAoWgrhUYJUxPzaUN8YsMwI51mW 54FB0fHC9umg8dCfX7AUgu209ofmSFRgZQlCYMCSlcBgYpUSFJ4frstN4jVxhpXp0mbl NRcBO49za4MTCGCV72TKPXTwwnh0VtyDmWici5ECQ0mYAPXxg6v1lwwMJqPdi+PtiETZ A3jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wGzLMqG9; 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 i4si3035061pgs.408.2019.03.29.18.37.31; Fri, 29 Mar 2019 18:37:46 -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=wGzLMqG9; 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 S1731889AbfC3Bg7 (ORCPT + 99 others); Fri, 29 Mar 2019 21:36:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:38352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731821AbfC3BbB (ORCPT ); Fri, 29 Mar 2019 21:31:01 -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 53DB72184C; Sat, 30 Mar 2019 01:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909461; bh=DOMDnq5/92XMUx9rDb9dh32r3ZeTfeSGNI7IhJn8+0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wGzLMqG9UZ0DUU4HYrsNeZzfXkG0b3ehmGRvVEtJ3lY28xJjb5w+7FP99BaLksovn I6ShNAEyGiSVkcMrVmHCD8vFVy7vRTZmFKPwEFok1UR5hMHbZ9T/MBcVISGcdk78rj yZGzcSrzh3UQ6GBWB8gkehNqJOI0Mzh9ltodI+fg= 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.14 19/37] blk-mq: protect debugfs_create_files() from failures Date: Fri, 29 Mar 2019 21:30:02 -0400 Message-Id: <20190330013020.379-19-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330013020.379-1-sashal@kernel.org> References: <20190330013020.379-1-sashal@kernel.org> MIME-Version: 1.0 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 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 d95439154556..da0453277f7f 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -791,6 +791,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