Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2365684ybc; Wed, 13 Nov 2019 13:18:32 -0800 (PST) X-Google-Smtp-Source: APXvYqx09n3WzbG/ZEGKK9ewfLznjD77prv4XVhB3kU3I5axfZCoPr2FU5vQDhzwttBe9/ai4jzA X-Received: by 2002:aa7:c98f:: with SMTP id c15mr6081393edt.98.1573679911973; Wed, 13 Nov 2019 13:18:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573679911; cv=none; d=google.com; s=arc-20160816; b=hNFsgp6LHdMoxlGypoa9/LR6kpQRILuiCW8sLMl1pl4g5e0W/FGxWgMKWCVoPv5pWb n/8Cb//IOOq/NGro5AVz4v5nor1/0stoDimANGj4b/DMirXeZhb42oMW411qGa8GAgfM Oi10d0Kqag0s09X9CB2OFi4PRml/KKM4khQ7cGKS9B7jCOXuoTam3lbEf6zjfQpuauLS ZKRdDV2oN8EgIB0LVGNkY+CCBrQiWYSNWHmIH9ma4dyAnYxBq72PxsZ5BEMK+iV/et9w 1sGeqY/e74aHbhatVPzQ4OkiPWeh7Ig0W+Xlx2gYcgBFDFGsfO0l8G33+UfkfBLs1C88 RJgg== 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=RPjQHq0tM5Z7OdG1crdfUzGn0KI+1jsG44d2MmF5/+k=; b=C6QZv8oFhlbTdoFsfPOFes5zlnUYkTzyvZkfLqanxJNJnqiCfzSAVMNI9xUb87opNQ 0c6U2n8DhuRXSTJTZ5ygbsvfL6tevTYfAOvvHjWQZsToj7kQYO84H7kGqvKXqCUdffwj sZNl3zgOKeCnzy6UZCmRE6i0J/TOaDLxoGDkW1MXyAO6eQ7s43Bl5Bbv10n4PL0Q9wQq ZBpzmBLmeVcficVPmehVanfB1D2nQ2Glh4hxK0GlCA0R2ZWM63Ue0BfPtld3JgBsKOsX OEeKKE88QivbWn1WjiUzqR4S7GH9rdHGjwUEHnl7fzj/di0ltsq4QkiucrgcTxRJWUvJ ngvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=Jf5f5dR5; 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 qn27si1915286ejb.426.2019.11.13.13.18.06; Wed, 13 Nov 2019 13:18:31 -0800 (PST) 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-2019-08-05 header.b=Jf5f5dR5; 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 S1726957AbfKMVR3 (ORCPT + 99 others); Wed, 13 Nov 2019 16:17:29 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:37562 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726543AbfKMVR1 (ORCPT ); Wed, 13 Nov 2019 16:17:27 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xADL3tST034275; Wed, 13 Nov 2019 21:17:00 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-2019-08-05; bh=RPjQHq0tM5Z7OdG1crdfUzGn0KI+1jsG44d2MmF5/+k=; b=Jf5f5dR5/jqfmdczHtqgDS1ctMGWiHrpl5MyTuRJ1TCkBoFoPMjcq1Q/sqpL6x1ERkVq NRAeQEbaeSzVQxXnNo0t3HYmgz2iw9HbGyWO+3GsC/ttegoIQgDzKLqUJKRALiHHxD0X eughK9DfWIG6ZGWXWml1jKCDQOX6nNJ5OdnB7njBoH3lg2Z7fB09pSZ3+77z4/aIbY4b 42M5mDUY+wB+H0KpK8cYnDRAYXpAUJ+R7aFJuuqFqTZYmj5Ag7t8tiVUd23bE915fK3I eIVXt43L/g6Oru4L9jrfp+19IFCUGy4WedZktnqEvz3yTOqLqObZV+N3wxOlT4yGLNeV zA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2w5p3qy6b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Nov 2019 21:17:00 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xADL3xnD170590; Wed, 13 Nov 2019 21:17:00 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2w8g1876ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Nov 2019 21:16:59 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xADLGxGF015428; Wed, 13 Nov 2019 21:16:59 GMT Received: from ca-common-hq.us.oracle.com (/10.211.9.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Nov 2019 13:16:58 -0800 From: Divya Indi To: Steven Rostedt , linux-kernel@vger.kernel.org Cc: Divya Indi , Aruna Ramakrishna , Srinivas Eeda , Joe Jin , Manjunath Patil Subject: [PATCH 2/5] tracing: Verify if trace array exists before destroying it. Date: Wed, 13 Nov 2019 13:15:59 -0800 Message-Id: <1573679762-7774-3-git-send-email-divya.indi@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573679762-7774-2-git-send-email-divya.indi@oracle.com> References: <1573679762-7774-1-git-send-email-divya.indi@oracle.com> <1573679762-7774-2-git-send-email-divya.indi@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9440 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=948 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1910280000 definitions=main-1911130175 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9440 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-1910280000 definitions=main-1911130175 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 exists before proceeding to destroy/remove it. Signed-off-by: Divya Indi Reviewed-by: Aruna Ramakrishna Reviewed-by: Manjunath Patil --- kernel/trace/trace.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 1c80521..bff967f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -8421,17 +8421,26 @@ 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