Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2474595pxj; Mon, 10 May 2021 04:00:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXvVeiuasV2VCM0qLmE83QNYIx49A9txcYA+wqb4UYfIxe9BMoNM7qe+m+UxOZktYy4Yu1 X-Received: by 2002:a5d:9f01:: with SMTP id q1mr17996518iot.7.1620644451990; Mon, 10 May 2021 04:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644451; cv=none; d=google.com; s=arc-20160816; b=HV95IuYF+w1x+z+AjlAI37yGX2esrMclrBDq4IjOi6ZiFOtH+1K0rp8KQTXwtlyl33 KFYLrY2Y6ZNqK/WvMHXhc/5MMxfMFrvi8k04yXFh+8obWduef09sspeP649BwizZq8Lo +BO6/S6jkBCfCiusH6HQYRegqwmF1mBj91MASH2/S67pv66+ovT3ta0iWMpNd6+p691O 2JO3phY074g2BL9LmyjYZNQARuj497fkZlGHZu5r6A4USBQrv8C/etRSE8DTDL5iyybR 1DmdEI6KuR3tkS0wvbmAdSepX9GL5AI4cX2Sv57Uq9lzrecQjP4iLsAsrJMSMZCj4bBm lT4A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5V2yfofUOaTg5IG3X6V43Md2nItrCt0D07Cf6Tqz5n0=; b=K7PSVCX6IbJkKj+Pdta06nSkb3hamMCz6jWoYTFQ0z7Hvi7LCeLqo3fILw1svfooRz j5++QulPDbumajj0waEGcPc4R5mF8FFrmS8JFaXOX03hcB1a9T8PXuNUUoEjdoXIgKNa VYlCMV+uNVdl3V/RB+kEHRUnq4ToGZnMptLk3r/LpNV3LVav/NEj87MMFzRlBlI32i7j OuhlZQeYlyWsXYa1fCwvGaJouTR+7Bb+3ms9hyVSpwqwqHDDkmhPM8Nl/F6aivUdrTjZ 1XcgEdeaG9Rh2VCYYLl3t9xWqsVafHaCQFar2klN9t62IdOOs0xHdnMAOY5B0traEJN0 kejQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GAuktRT1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si16857365ilq.17.2021.05.10.04.00.39; Mon, 10 May 2021 04:00:51 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GAuktRT1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233404AbhEJKye (ORCPT + 99 others); Mon, 10 May 2021 06:54:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:57592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231830AbhEJKnY (ORCPT ); Mon, 10 May 2021 06:43:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CBAB561981; Mon, 10 May 2021 10:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642778; bh=b0SCXIwu0w5AlP6zDo9kyjnJFWVzFfAoAa3H34IXwVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GAuktRT1hWpd5rBQYqR+iKRp6tWk11WZIbgjbz/ty5ciDEwAfD+PfASLlawW5Xhdk YH8dvVDL2vekAYtLym6LId6d9lvLcW89U7bLAhCjgfzr+m+CVG5aRI4oUIjz7lg+Zq +COJCscMV10dZunxHyBjNHfdyrUpiH90MNGoxPy0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" Subject: [PATCH 5.10 012/299] ftrace: Handle commands when closing set_ftrace_filter file Date: Mon, 10 May 2021 12:16:49 +0200 Message-Id: <20210510102005.253710209@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt (VMware) commit 8c9af478c06bb1ab1422f90d8ecbc53defd44bc3 upstream. # 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) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/ftrace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5632,7 +5632,10 @@ int ftrace_regex_release(struct inode *i 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);