Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3767461pxt; Tue, 10 Aug 2021 10:51:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0XtJPKCq5vlbfputsEibOKzunQG0d87cK/7tEd37j5aZW2xhzO/lfVo5kf+6SwrZC+TsS X-Received: by 2002:a92:c24c:: with SMTP id k12mr48762ilo.28.1628617872670; Tue, 10 Aug 2021 10:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617872; cv=none; d=google.com; s=arc-20160816; b=WV+9fwt8YkllZ/htg/vozZxyB+wU1vHuOJOOHaqNb53p9fz2d3z8QFswiMvf1llLT9 MxoQS5QDHO3gnQOfttgWUMjqK7WaN8Jxykia9wakWIsywLo380rauKGj0jiUaTR81LeR M+0jGbNp8g5RR4gxiZXLw3y3i+xsrtlftNkAPP8iu4KF+j45kKicPNPhhhPlHDQ0Uvhx WLmzvs7wNh/A86Ar9poQf7U2qY7yW14OZca1fZ/aUi9RkiViYnl+wWwoT4Vss2jQFMQr cmLCluI65YgWXGjwMlJklYuHcJ3h8Ropre86fXhJHrqakRH8JZariEN2omkLho/EOMnL nhiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=O7mOx5J1LmynxWSmfYyf1zq0LooeHheSlIbBjrdWuGM=; b=k6Dpsc0p6HcB6V8TcvP6sGlVI06GzeNXg+zvi29kRt9nEyFeOGxJiPEJbZp5tqjd+t wiMef97yf+dOlL2iV4HaO1yttWQOuskgMaTFTbj8Pds4ZjHyaYMszkkbKVfKup7EJoke 3og/vX55tkoKeN4tMjeV6wyA2A1bCyvtTczFXJxQuaLNpqUhi+Z/2qWIggKE6X41Qkr7 bF5U5NqMeEgxoepj+FsYwidDAHdELiB8gVuZs48Ic3HeTsEvK1l6HwBggGHcHncR5mEL llSdiaca4GemzKZQ9F0YF08AoRDOolWLl3Vwh+L/w4zSp4YUJG/XlrEEE7J9NeTZMPcT qL7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E9OhdmvZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si22629191ilq.43.2021.08.10.10.51.01; Tue, 10 Aug 2021 10:51:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E9OhdmvZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237361AbhHJRuY (ORCPT + 99 others); Tue, 10 Aug 2021 13:50:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:60930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236222AbhHJRq6 (ORCPT ); Tue, 10 Aug 2021 13:46:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11CFE61205; Tue, 10 Aug 2021 17:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617247; bh=TJODZfoAYA3RjHfN0cW75/6oU4OUeKSGaJcJUgPBnSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E9OhdmvZrc9otTBtNi7X1Hsy3PC0QbVweISg7NTX5KeRjZ777lLfoHLrk4bP7h5TD 8YT/ZNZhOeUtgFVZHdFhy0ck791EDGxFadhlH11RAWvUtHLHVPrOWE4r/LAkjKbXIB 4OYyDJYD/Vw+rXeN164E2ksLjdsD1xGrgk8iqArs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Agrawal , "Steven Rostedt (VMware)" Subject: [PATCH 5.10 077/135] tracing: Fix NULL pointer dereference in start_creating Date: Tue, 10 Aug 2021 19:30:11 +0200 Message-Id: <20210810172958.348192105@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kamal Agrawal commit ff41c28c4b54052942180d8b3f49e75f1445135a upstream. The event_trace_add_tracer() can fail. In this case, it leads to a crash in start_creating with below call stack. Handle the error scenario properly in trace_array_create_dir. Call trace: down_write+0x7c/0x204 start_creating.25017+0x6c/0x194 tracefs_create_file+0xc4/0x2b4 init_tracer_tracefs+0x5c/0x940 trace_array_create_dir+0x58/0xb4 trace_array_create+0x1bc/0x2b8 trace_array_get_by_name+0xdc/0x18c Link: https://lkml.kernel.org/r/1627651386-21315-1-git-send-email-kamaagra@codeaurora.org Cc: stable@vger.kernel.org Fixes: 4114fbfd02f1 ("tracing: Enable creating new instance early boot") Signed-off-by: Kamal Agrawal Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -8683,8 +8683,10 @@ static int trace_array_create_dir(struct return -EINVAL; ret = event_trace_add_tracer(tr->dir, tr); - if (ret) + if (ret) { tracefs_remove(tr->dir); + return ret; + } init_tracer_tracefs(tr, tr->dir); __update_tracer_options(tr);