Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp120916pxb; Thu, 2 Sep 2021 21:10:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUChVx6YVC4x+1zHrfiCXT5Q4Uu6LGa4ykJ4hn6WnVBFDsC5azGV6R2DY5otvM32DjauT+ X-Received: by 2002:a6b:3c16:: with SMTP id k22mr1503463iob.130.1630642225518; Thu, 02 Sep 2021 21:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630642225; cv=none; d=google.com; s=arc-20160816; b=kWpspQFZdq6lhg6l5RvuGgEVlkdY2a6qDQ8XM/14hV9JZYlZQ/cc8aaMz4JYgjsAyg r8p9KcX0RGwE12Z1ppx18JNcqAt6M+SH2cHQEANIShpHS9Ta0DVF96YUwtuRsnnFkWso FpObx8iq/aWiFkshLvASL+dOxwo6yOykPg6n/fWMbq9mAc9YdjJ5Umo8SdlC3OZREkwg 7KQxUTD3SLVuoK/WpDJycnTx9SufSAbqv3Ef4od+hsf3WfOvF9ja65crCtLIBWEb6Bs8 cynMS3Ve9ucEWdhAh3NLDSHLbdDMVZYEI5BTZ1uSRUtEw6PGmZiUpMISeC0ecbKMmXf+ 1s2A== 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:subject:cc:to:from:date; bh=QFuCErFAl1xYaehlbtyxhZlvvsjD6VInporwAQ++y7E=; b=Fahg+YAPA3V306Lpn+I/JhjY2U3XR9LQaHyklodlfUdq3rgLCeNvFHW/K3mSPCW5x1 U4eHZ984kpO68Af1h5HqBVWCRo7uGoTSr/4EI4NM1BgA8IpCM51Sobd4ORjxr6EHgoRy kv7w5gONsJyy5LKyLQgW7DP+td5tFXgLp0EyT1geZDBo3rLs3naFxtBwe09VJ5vFZd9r 1WWsVopXSOdpUpA+ceWVfctAXR9uH0ihDRdT+9WxR8UGlz2EiQLR13WSyFQU4dI4kydf KWERNV/NJdWLSwBwKR1HCae49bPPjOmsEbYb0vlBc6iAUFdAE9YRR5Q6JLrN3PpRW9eg CFKA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m21si4015685jac.82.2021.09.02.21.10.13; Thu, 02 Sep 2021 21:10:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232024AbhICEDw (ORCPT + 99 others); Fri, 3 Sep 2021 00:03:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:38708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231872AbhICEDs (ORCPT ); Fri, 3 Sep 2021 00:03:48 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 58F3960E77; Fri, 3 Sep 2021 04:02:48 +0000 (UTC) Date: Fri, 3 Sep 2021 00:02:46 -0400 From: Steven Rostedt To: Jiang Jiasheng Cc: mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] tracing: Add trace_trigger_soft_disabled() in front of trace_event_buffer_reserve() in trace_inject_entry() Message-ID: <20210903000246.425731d5@oasis.local.home> In-Reply-To: <1630639834-767471-1-git-send-email-jiasheng@iscas.ac.cn> References: <1630639834-767471-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 3 Sep 2021 03:30:34 +0000 Jiang Jiasheng wrote: > Directly use trace_event_buffer_reserve() might be unsafe, How can it be unsafe? > as we can see from the trace_trigger_soft_disabled() of > 'include/linux/trace_events.h' that if the value of > file->flags is 256, the check in the trace_trigger_soft_disabled() > will be passed but actually shouldn't have. > Therefore, we suggest that trace_trigger_soft_disabled() > should be added in front of the trace_event_buffer_reserve() > in trace_inject_entry(). Do you understand what the trace_inject_entry() does? I'm not sure it makes sense to "soft disable" it. > > Signed-off-by: Jiang Jiasheng > --- > kernel/trace/trace_events_inject.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/trace/trace_events_inject.c b/kernel/trace/trace_events_inject.c > index c188045..6dfd3cd 100644 > --- a/kernel/trace/trace_events_inject.c > +++ b/kernel/trace/trace_events_inject.c > @@ -21,6 +21,8 @@ trace_inject_entry(struct trace_event_file *file, void *rec, int len) > void *entry; > > rcu_read_lock_sched(); > + if (trace_trigger_soft_disabled(file)) > + return written; NACK! The above introduces a major bug. Bonus points if you can figure out what that is yourself. -- Steve > entry = trace_event_buffer_reserve(&fbuffer, file, len); > if (entry) { > memcpy(entry, rec, len);