Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp851510pxk; Thu, 17 Sep 2020 19:04:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT89mvHT10GVUOgoOsbKc/KHhPsMqZpUIgg+QjX+TINpK/Jf0fHL1gnhnYnvBVZX/2muxc X-Received: by 2002:a05:6402:8:: with SMTP id d8mr34561846edu.15.1600394642688; Thu, 17 Sep 2020 19:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394642; cv=none; d=google.com; s=arc-20160816; b=Jp4oWHKenYDW/SXL4A8mZyX5wbK/6OIslxxcpjMilWLljadmTFH8xe+Wki8WZTgdgA N+BFhfIcu15hke4PSLuAmL5uJijmR6XJ9puvT9zyvh750hZvU0TBihjhuS1e7fR66LzW YoRrgQRvvWYWPj9TMfB10Nn7kiH1MyptpdfqAuP6l7+tDXcquqtumrML/KxAV6QlzNWA Yun5b17mX+lG49pYQE4gC2M5oADt6bhPDdgXj5WjBu710goDLiZt93+ZoUZih8KgPoqY +IFayaIAbCbrlK1OQWIBqpxk2li365dkoSvCR5gZ2EIr9kZBGtHNq8/KOpJ8SpkFIsu4 sFVw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+qqFGmMtFShRNrOhfoMJcBgMb3qtCd2Od+r8MnwsHRY=; b=u+4282cOqtf0cBL06LBZSDlVowPTMkl3Zi9IzSWQt4Qrnz5O27GWxTBx6DwbcfgFQL n6rMzYaIBmoHunteo9g44EioauEW4tRoraZdF05PZpehNL7qqteXU2fMljw5bo7KZosZ sf4+b3KXuEnzhljmZ1S8Qp1H68Z+nWQPVuBxb/9qyFqWdkCSD/eWMMrkSqFDpBLuDewT jWCKUbLAC7SJvDeE7jMrEjZrEp901e/TI/mVLEcmFOWUlo/RGWCzD6NTyItK0l5ZDqqM lHKgSsHJSv5atCVOmBt3VxkvekBAjMV6lNryIf7hKkU7TuAP2rRcNy2F9IQrLgLC3Xkd GyRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mCyFRvWB; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w4si1115383ede.468.2020.09.17.19.03.39; Thu, 17 Sep 2020 19:04:02 -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=mCyFRvWB; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726658AbgIRCCI (ORCPT + 99 others); Thu, 17 Sep 2020 22:02:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:47002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726617AbgIRCCF (ORCPT ); Thu, 17 Sep 2020 22:02:05 -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 2268321D92; Fri, 18 Sep 2020 02:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394522; bh=uVMjTa5atjK6tyc8X+GwNa4AhXL8VLDIQZgcxdaOgRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mCyFRvWB7aDDKWTsgCuKaCa1kzl/DrLDCbO/bzChOcNAytR2jlSowpoM1902dPhXy Z434PxMsvRL1w8eb4vm52BcM5RCPXEp1etP39HwJGJBXRfQVKJUIhSS7mf6zINieUV LblB7Q8Tvz6hcIp6Dmq85BqNvcLxV5pHo/932Syg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Divya Indi , Steven Rostedt , Sasha Levin Subject: [PATCH AUTOSEL 5.4 044/330] tracing: Adding NULL checks for trace_array descriptor pointer Date: Thu, 17 Sep 2020 21:56:24 -0400 Message-Id: <20200918020110.2063155-44-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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