Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3745077pxk; Tue, 29 Sep 2020 05:20:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU0Y2gIaCfkhf+AMN7nykWA2+gsxnXTHguLJDmxKG73fVIy1ylceI5Ik/K/Z35LNvPJ9pb X-Received: by 2002:a17:907:207a:: with SMTP id qp26mr1340214ejb.387.1601382059324; Tue, 29 Sep 2020 05:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601382059; cv=none; d=google.com; s=arc-20160816; b=BhS+3z3ucMla4hiZ6VEYABIlUoovqWP/DXp4EX5azyjGevh4Ywxsd3Apk5Ao3Of+3p bPYlougfrbT60iqsmuA9yHT4FxDfMZ7OVzS7dF656ZjdjJ1RaRPAck//yD/qotNr7o/n zsTXRBnY90YzilZ3XHYx2npjoNly1C08juA937GRwsgPQub5fTIz9PT7XFCEdteS0nrK FaoHBViwIDH08rELgpONS+iud51gfzCVNG/jUJcra4LLgDUQKmk53CZtmXrh+cJ8BRIm xxfD5kfXO+n1WgeaC0F6y5FZAX8rjfgUbE2r/K2sO+LIE3OWQJilhInFZh6jyTFG0eZl 8c6g== 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=+qqFGmMtFShRNrOhfoMJcBgMb3qtCd2Od+r8MnwsHRY=; b=c36t6cUnQA0rZML2c54mvPBhhUMtdAEo+9vztY1y0ir8mN8cZGBT0IN8R7lDs9IlQU UuXrcmWlLvtRzXAOTCrWnt44xDyy6E9GTztzP0VMhVSOyqrqMCkSSew/1VQzxipvDYCp V0qUkQK9QRdpM8mTQLr9DXdmAThW+CY+mECKI/V24HW92W2P19cIZeaHyYmmx8RM4HXi 0DIHHNCesbTDAyPORkkYZrazA1jEvJ97cxw/lN3mruYSguS2OQOa4qpX0nUvvSoyyTBV CELlHuFTrxBtI3B/3XC3ef1SATrHUQJIt5ayYg3i7aO2PNTnW9+Fy2OHX+M5DaLqCpSn A7ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z5Ea1Uib; 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=fail (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 n23si2604169edv.598.2020.09.29.05.20.36; Tue, 29 Sep 2020 05:20:59 -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=@kernel.org header.s=default header.b=z5Ea1Uib; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732281AbgI2MQ3 (ORCPT + 99 others); Tue, 29 Sep 2020 08:16:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730048AbgI2LhA (ORCPT ); Tue, 29 Sep 2020 07:37:00 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 040FD23ECD; Tue, 29 Sep 2020 11:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379164; bh=uVMjTa5atjK6tyc8X+GwNa4AhXL8VLDIQZgcxdaOgRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z5Ea1UibZA8uyQ0UpFDiY6l/LBk7FmUOTA+Fgy4I7F1cgqgAx/FWmMO/LCcllNRv+ HdNvAfA7vhqTcKFI9sTu4HHST/whFdO/+0ryd6t7MdojjD3wZwZuJSq9ete1GB5sRR pc0lUS8eMspZMJwF+KsA9rOZJkGXgUWpV35Fx9pU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Divya Indi , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 5.4 041/388] tracing: Adding NULL checks for trace_array descriptor pointer Date: Tue, 29 Sep 2020 12:56:12 +0200 Message-Id: <20200929110012.479768363@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@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: Divya Indi [ Upstream commit 953ae45a0c25e09428d4a03d7654f97ab8a36647 ] As part of commit f45d1225adb0 ("tracing: Kernel access to Ftrace instances") we exported certain functions. Here, we are adding some additional NULL checks to ensure safe usage by users of these APIs. Link: http://lkml.kernel.org/r/1565805327-579-4-git-send-email-divya.indi@oracle.com Signed-off-by: Divya Indi Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin --- kernel/trace/trace.c | 3 +++ kernel/trace/trace_events.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index cd3d91554aff1..9007f5edbb207 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3233,6 +3233,9 @@ int trace_array_printk(struct trace_array *tr, if (!(global_trace.trace_flags & TRACE_ITER_PRINTK)) return 0; + if (!tr) + return -ENOENT; + va_start(ap, fmt); ret = trace_array_vprintk(tr, ip, fmt, ap); va_end(ap); diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index ed9eb97b64b47..309b2b3c5349e 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -793,6 +793,8 @@ int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set) char *event = NULL, *sub = NULL, *match; int ret; + if (!tr) + return -ENOENT; /* * The buf format can be : * *: means any event by that name. -- 2.25.1