Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp414162pxj; Thu, 20 May 2021 12:15:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbaHi5FIiIaSZ1/w4VZdeHzgRXd0oajSUNmV7iSIHfF12MHVOJvx2zEnmEvVFDGrEtErcy X-Received: by 2002:aa7:c9c9:: with SMTP id i9mr6583721edt.17.1621538139628; Thu, 20 May 2021 12:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538139; cv=none; d=google.com; s=arc-20160816; b=lgiyhv8X7B/vFhgHLd2yStezUZ5M+bFlAJVi4EmpkMvhgor4WW179CzMDITzJtZiak Utf3nlasnMD/IRft8SgR7CUWL27Ttkm7tlRrUZYJwpDUixPhbPCMTQdE7eSkfQgwsjdU ufJT02ZyjsdeAN+IJfHAedUfgSpffldx+EGCPjM73IS7eCIQaz8k6ONtihPn7c3scOEw o1HMwQ6X+0VWkTMgWtgcEJrWToGv+R99qlhv+iti6Q47k50QWPrd58+h6gndSFzokO1J /SxqN+PfQdQYwALSiZ1Kqe/5J7jV7EiZ8we01dXaHuSxEiXaEnS9cFHoLuZ1uIpshQ/X Td8A== 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=SuHO+sWfO2bfbS/IZMR9cm/tIULqbCGbFvWWgIyxTfA=; b=uB1I3d0fM+fjDOWZrd5t97s/2cHyE1ZefPGJqHLql4A9D9F9yj9xnJABY+Ts/4vwbg Ip/l+gMrlFK2RVsJdMFX0DQQxtSb4mlkEgGx0cqLSmIE42QmmDr4tc0eex6qq2HyfGVe 7DQN1CC6D3gLxVqGuchElPBOBNZ9aRFiI4BOv3GYtg/9A/CFnhSc/3pY25Tg1wMFBZkn Q9QSxnyfnxez5u+A9MRZQAHL/4Sc06xiEkcwBoaZFmdr5HmHyKYeGah7DLih/hCeuiOh 7Rf7xvmO9o5bv7gln7HNoyQxhY3z1ChETPWIMHE1d3ZHCyjE1SXp0JXLaZG6PYUXhDBI BXnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p44P0yZW; 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 i27si3106246ejh.691.2021.05.20.12.15.15; Thu, 20 May 2021 12:15:39 -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=p44P0yZW; 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 S237343AbhETKkp (ORCPT + 99 others); Thu, 20 May 2021 06:40:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:55694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236349AbhETKZm (ORCPT ); Thu, 20 May 2021 06:25:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2345761480; Thu, 20 May 2021 09:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504195; bh=qivATiHf16OvUEzdc6XayNzgWAB5IFNxqPbnfVlp3n4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p44P0yZWJMy7f4iY1K9UuThyyfrgrv0y8HdJTnZ+LSaFiclvDfRQo62Gk1cOoyPIV oJrTdk87LQYLqqSx8YqbbIgS6/COm9qIe8svnlUDO8Rk+dcwxK+Qelp81LPCi6agPj C71EUAmlPhpcvi6Pyax2XBh9wROCJKoYknhJC3+Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" Subject: [PATCH 4.14 091/323] ftrace: Handle commands when closing set_ftrace_filter file Date: Thu, 20 May 2021 11:19:43 +0200 Message-Id: <20210520092123.215653929@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -5096,8 +5096,11 @@ int ftrace_regex_release(struct inode *i parser = &iter->parser; if (trace_parser_loaded(parser)) { + int enable = !(iter->flags & FTRACE_ITER_NOTRACE); + parser->buffer[parser->idx] = 0; - ftrace_match_records(iter->hash, parser->buffer, parser->idx); + ftrace_process_regex(iter, parser->buffer, + parser->idx, enable); } trace_parser_put(parser);