Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp735795pxy; Wed, 5 May 2021 12:31:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNFK9Uwco8VOPrZQ/nFzI4K2QWg0huemA41Yjm7abpAPkbRY9eiZE49Us6A12knmhU8tIO X-Received: by 2002:a17:90b:4d11:: with SMTP id mw17mr13651661pjb.160.1620243080003; Wed, 05 May 2021 12:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620243079; cv=none; d=google.com; s=arc-20160816; b=KTclY2iBpVFZe1NcZaKuMFpFXovrwJmkSfqNMpvkHwEzqUYurGM59vs6Dz6RcskDKy bXf/WqNi8g4OxjNPNqI9RlJ551NHcZhDqdC6Mns0NN5lJAShgmQjDZIW6mdawpB+zzJa XGGEDyMFAG5nAkuKIh1A3vTddrJvH82chzxOexdyt3kFXDA9BUVcChcWIt7giNaE/tCK 3v9bx1I+7R87zKI9mVZBbnkHSaakpZM89mLsydvHYwx2VpwDkGja6XJSnIaYkIv0EXsJ 6sahwArugDK06JfKlGQ+Z6RjGvprvpX15UOC+4zWFp/675QjFjeTsmJtmabpxkhcPpCM PWNw== 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 :message-id:subject:cc:to:from:date; bh=cpvQw4dcxpAwSb0QBvAZOwpAL/yNuzeTiRtqgS4F60w=; b=h9v5nK63sPGGbB629liblkcq+zXNLiy+JgidHruhqyKYM14Y3/E8nr3guOJfxlkFQp cs/rC9kLZ9muZMoAUcuQ5AGLt5bFQ7xg0T48QVcBif/iv+zy7pqsO0O/7QTXadMbD69A R+QmtuTb2IAU+R5jjsii3RbNFsm2TueyYsSpFR6fD2r2Xhi29ps8Nb/j+lMbxrdsP2jG t7yJOjaZP0d6/2rix7mOiBEI0+GDDsXxEc0r89DfeVF9wxecmwkIJqpxbmUZ5GPpbZio D4iVnfnxoADg5jcrnZBlPTmkBkXZes3P//Ix2bzOz8d3GYGuOneS0+OAkHJ87oom4btj CI1A== 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 s19si66847pfu.44.2021.05.05.12.31.07; Wed, 05 May 2021 12:31:19 -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 S233386AbhEEOtS (ORCPT + 99 others); Wed, 5 May 2021 10:49:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:36624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233380AbhEEOtR (ORCPT ); Wed, 5 May 2021 10:49:17 -0400 Received: from gandalf.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 9B335613BA; Wed, 5 May 2021 14:48:20 +0000 (UTC) Date: Wed, 5 May 2021 10:48:18 -0400 From: Steven Rostedt To: LKML Cc: Ingo Molnar , Andrew Morton , Jiri Olsa Subject: [PATCH] ftrace: Handle commands when closing set_ftrace_filter file Message-ID: <20210505104818.24358ef7@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (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 From: "Steven Rostedt (VMware)" # echo switch_mm:traceoff > /sys/kernel/tracing/set_ftrace_filter will cause switch_mm to stop tracing by the traceoff command. # echo -n switch_mm:traceoff > /sys/kernel/tracing/set_ftrace_filter does nothing. The reason is that the parsing in the write function only processes commands if it finished parsing (there is white space written after the command). That's to handle: write(fd, "switch_mm:", 10); write(fd, "traceoff", 8); cases, where the command is broken over multiple writes. The problem is if the file descriptor is closed, then the write call is not processed, and the command needs to be processed in the release code. The release code can handle matching of functions, but does not handle commands. Cc: stable@vger.kernel.org Fixes: eda1e32855656 ("tracing: handle broken names in ftrace filter") Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/ftrace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 057e962ca5ce..c57508445faa 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5591,7 +5591,10 @@ int ftrace_regex_release(struct inode *inode, struct file *file) parser = &iter->parser; if (trace_parser_loaded(parser)) { - ftrace_match_records(iter->hash, parser->buffer, parser->idx); + int enable = !(iter->flags & FTRACE_ITER_NOTRACE); + + ftrace_process_regex(iter, parser->buffer, + parser->idx, enable); } trace_parser_put(parser); -- 2.29.2