Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp610778pxj; Thu, 20 May 2021 17:48:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC16zTmhvEXnQbkAp9oiJR4ORFTkHi/kHzkE6RARiuqUmaWbOQoMyjSV5e+UOM9D8PvK7R X-Received: by 2002:a05:6e02:ee9:: with SMTP id j9mr8061974ilk.14.1621558137981; Thu, 20 May 2021 17:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621558137; cv=none; d=google.com; s=arc-20160816; b=Ad/9OXpvQzBg8TBWvTrg+pPmSnguY1gKL8u1iH7ZguY50jPZ5xRownFXKd5mOt0BYe S+RTbClnvuCNVZhSDUvIQpoIW0ZdzRIvhCO2gDgbRBfPrzLfWGwxmnWK/a7hMKhFDNAo nIx7pcNiWxF+pnqPmUzo7sV8WnVJiofB7Wk3/Xm57vOyg/LZPl3HK69VEPqQh/GtBOyK TxHQEO9UmHDR5esvm9v76XzNSqClcOCc88/baBzhBFrwPSiYUB9AQ+q53QV6U0OamEKc xsIgqZYy2smnIKR/n8f2N3tvL6hoBQ/e458U9wNdmLONQKAh3K0P1LPAIxza5MaAMax5 l2uQ== 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=jrWqcnQj/fEOJGGy56cb2junpUJk5oxKBwGbZYcFOzA=; b=FXipvfqWV1JQn4MtDJC4PofI46KEcZ+hQ3M1BpIznnUYrMRRlyJl4m6IVJn9uDnA2Q IffxB4Ov6Y3SYTKmdat4h3iAqP8xgaHPIL5Re0warRFrW7F8mVwgFvw+D3cAAmgfXEWq zKmAtWQ02zksxFAPlIQ3IUEJqXQOeQ8mlfuff0LSyy30tDQBpJG2UGmWYEMz/1QcbCfC x4QTQ2DYjF+u7SoBflfBYmDwWVwh0eMyQKnKp+1YDbpKrpL0cipkZajISGYBn7DdA626 1XVYQpuKUQfIm3ZRNwqAPot2A03uXFeq5iwbZtMvZX0jNSfZpc354y3+/Ckwx3uDeZKt vuuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DYLUUwB1; 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 i5si4124093iow.84.2021.05.20.17.48.45; Thu, 20 May 2021 17:48:57 -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=DYLUUwB1; 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 S236950AbhETLcE (ORCPT + 99 others); Thu, 20 May 2021 07:32:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:55128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239687AbhETLLS (ORCPT ); Thu, 20 May 2021 07:11:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A113061D4B; Thu, 20 May 2021 10:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505243; bh=ZZ0GxiYV5eYLE4XtpHMTuZPceoQ/HvtP+ZFnq2OETPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DYLUUwB11i1RC1nsq064s/K7E/kRveh9dppi3UQ9M+LoHpp7aS9LujCHqujddqXn6 PIU2AmzCnu7Vh7DQQP3iq8AZERLYeEon+Gj6EnigrouFa74Dm/RrMF6OgDc3W78Hk6 8PhfY/cM5aLyxuzZz6JywVyXDAfgzLSrNezMcvOQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" Subject: [PATCH 4.4 047/190] ftrace: Handle commands when closing set_ftrace_filter file Date: Thu, 20 May 2021 11:21:51 +0200 Message-Id: <20210520092103.728121583@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 @@ -4401,8 +4401,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->hash, parser->buffer, + parser->idx, enable); } trace_parser_put(parser);