From patchwork Tue Sep 29 10:59:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 290716 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=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, 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 33A43C4727C for ; Tue, 29 Sep 2020 12:48:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC92920C09 for ; Tue, 29 Sep 2020 12:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601383706; bh=hSbqn9gtBKGhA8jofV0GXTT4aCyDeC+U8vFJgHuiqko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hFMVUex16uManJTBHqqaJwhIyfry2xWYo3bqHpkWj8o1dacy6EZ8RbIC8yh08s6os ijggx7Qt4OkkjTKZlQWCpaFvjNYj+rwys0WvXsuuZsAM1J62Wd8M5UlpvzPHoA1o97 OINNFUNodehkDo7eB6BeODU+DXt/27qJ1xHbM1us= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728396AbgI2LDU (ORCPT ); Tue, 29 Sep 2020 07:03:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:38800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728377AbgI2LDL (ORCPT ); Tue, 29 Sep 2020 07:03:11 -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 D2C2A21734; Tue, 29 Sep 2020 11:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377389; bh=hSbqn9gtBKGhA8jofV0GXTT4aCyDeC+U8vFJgHuiqko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qhpLxpapccMlDCg05ATEolGmeIwt0l/DDgjUsaiPizbotNfAhEvw+b0SV9mTJaW/T d/QKfT5ehIxwqv6dDBHaIE2sWaicwKepYp619DEsc3KSY4Iskz4pMSE7VZ7UKUN1Aq C/ASxg1+0HsoCNpOGcpmF08ZuSl5H7FRKgr2JPC0= 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 4.4 19/85] tracing: Adding NULL checks for trace_array descriptor pointer Date: Tue, 29 Sep 2020 12:59:46 +0200 Message-Id: <20200929105929.182236111@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105928.198942536@linuxfoundation.org> References: <20200929105928.198942536@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 06efd18bf3e38..17ea5f9d36b48 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2271,6 +2271,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 bd4c0bb61ad72..9d6e755d17546 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -755,6 +755,8 @@ static 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.