Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4166259ybi; Mon, 29 Jul 2019 20:42:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAWAobu0xx9EQiyXpZ+hktXvHhhesxdS8U1NgNIDGpzktynHZudkUe5a44z2RsdvSpN0D9 X-Received: by 2002:a62:7641:: with SMTP id r62mr39564146pfc.35.1564458161055; Mon, 29 Jul 2019 20:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564458161; cv=none; d=google.com; s=arc-20160816; b=NiuzQhnnSvkDQhM9vDeF+V8Gi7zvvBWhNryGU7zQyQ8uX/obUlzcL0tTfzVj+Ngy24 +cr4F12ic1FxWLf+7KOBCVL1peAw8E3m7PVy3rtN3RFYh34jTfO0sCFq0+SrPqY+hvGs 3V5Ss6HcKQAPHRijfQ7Jfxr30bygB8l6g30UAkGlazlE15iBU0pSC1EwNmS190Zf+m+U 1Z7Vyg2OxLzuGjTE7ZOfbXp+bGQr3IBinrNbUmyb6PzCUtZcomoVEzhY/i8H8v19IaPK bnPu8SPB65qntXk86eAqmNvtO/YFgdFuR6Urqlmr/C2fDQ6TJjgZzhLEpuNI6X3t18JP uYLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=uPCuOIf6sg5yK0KSPtPqV3XT5J9c2QUHfh7hRvUVM9Q=; b=jDYlrfZ7OPLKvvc0bzR7sgc6AdFz41FHSnHQ42qXA5t/H+BWQWJomhTf9ISgDG9tx2 DuvOZWRcN7HCzfNRMTjItF+DoQCFzcG4tmpZ2nhvzhNL3icnAnZiMr/d3ga0uFWZOctO D4CXMqgFRUiCO3SY/udlMU4yJLS8PH+imrSJslAzZJ32knMbNKx59Q5vbk+HD53qIDJL I7AWFLbVcs+o6QtJT9f/ZquPOM2M24IY6Qm40zjT0QzewtZtYMujJXEUlrkk03ju9zfI e4MslncMrMuSnRDtubrvoR9yD5k6sYIULbjhkYmXbXIGB5Fn3iR1ny4qcXdJvGawt6h5 0hIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Hy2FLxCi; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si26299825pjo.26.2019.07.29.20.42.25; Mon, 29 Jul 2019 20:42:41 -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=@oracle.com header.s=corp-2018-07-02 header.b=Hy2FLxCi; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730123AbfG3ADS (ORCPT + 99 others); Mon, 29 Jul 2019 20:03:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:57964 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728269AbfG3ADQ (ORCPT ); Mon, 29 Jul 2019 20:03:16 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6TNwmXj158307; Tue, 30 Jul 2019 00:02:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=uPCuOIf6sg5yK0KSPtPqV3XT5J9c2QUHfh7hRvUVM9Q=; b=Hy2FLxCigNHcZL+LiQ9TOVR03fZGP6n1y4n/1d9M0cPf117pUilMzBv+jU2SNu0NwrW0 5yXS7ldESXQKdU6wKNVcb8HjJCFvOOUUAb6ewSan3rEh6yla46dAH6TIpbTANqqBpl/b S1kUn1V3iSV41PNr6u9dcTQf9vDD/4+2tlO1HpagBGuBzMSN3Fnz/dJxjocqDKdJuBw+ nD4oTQ+LqNoZqWUCbANFFeIKhm1Jd80c0d9SVV/e2nJBIBsR6sXm/xrS+m+qUWcxXrFu 0GCGdV1/7n7pDf9EfeDEUc8OViK1zXaphWljGCqjcSICJcFET8h5eZQ5ShOgflEg8G0U aw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2u0e1tjwbn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jul 2019 00:02:48 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6TNvbAI019538; Tue, 30 Jul 2019 00:02:48 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2u0ee4kv3d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jul 2019 00:02:47 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x6U02lQj028644; Tue, 30 Jul 2019 00:02:47 GMT Received: from ca-common-hq.us.oracle.com (/10.211.9.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 29 Jul 2019 17:02:47 -0700 From: Divya Indi To: linux-kernel@vger.kernel.org, Steven Rostedt Cc: Divya Indi , Joe Jin , Aruna Ramakrishna , Srinivas Eeda Subject: [PATCH 3/7] tracing: Verify if trace array exists before destroying it. Date: Mon, 29 Jul 2019 17:02:30 -0700 Message-Id: <1564444954-28685-4-git-send-email-divya.indi@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564444954-28685-1-git-send-email-divya.indi@oracle.com> References: <1564444954-28685-1-git-send-email-divya.indi@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9333 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=965 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907290261 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9333 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907290261 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A trace array can be destroyed from userspace or kernel. Verify if the trace array exists before proceeding to destroy/remove it. Signed-off-by: Divya Indi Reviewed-By: Aruna Ramakrishna --- kernel/trace/trace.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 1c80521..468ecc5 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -8421,17 +8421,27 @@ static int __remove_instance(struct trace_array *tr) return 0; } -int trace_array_destroy(struct trace_array *tr) +int trace_array_destroy(struct trace_array *this_tr) { + struct trace_array *tr; int ret; - if (!tr) + if (!this_tr) { return -EINVAL; + } mutex_lock(&event_mutex); mutex_lock(&trace_types_lock); - ret = __remove_instance(tr); + ret = -ENODEV; + + /* Making sure trace array exists before destroying it. */ + list_for_each_entry(tr, &ftrace_trace_arrays, list) { + if (tr == this_tr) { + ret = __remove_instance(tr); + break; + } + } mutex_unlock(&trace_types_lock); mutex_unlock(&event_mutex); -- 1.8.3.1