Received: by 10.223.185.116 with SMTP id b49csp1022115wrg; Wed, 21 Feb 2018 10:43:05 -0800 (PST) X-Google-Smtp-Source: AH8x226Qh9/I7hnZjYs+jvpyus+bHOCFpQRHVkDMB9Rhsz09QZYIrlXiqVqSFbczUSxyEI32V4ct X-Received: by 2002:a17:902:4201:: with SMTP id g1-v6mr3991254pld.62.1519238585497; Wed, 21 Feb 2018 10:43:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238585; cv=none; d=google.com; s=arc-20160816; b=eLTk/wUPbi8GfpCF4iJsptpOtyYgOEYTNn4nrdrRGaNzJ4umfZlKOVf5hAsStTtg1y CqNF2JmuKwvfZv6lt9LF9hNYEgNuD51rH5nekp+QexfKUEzQMDKRX2RkD+El2gyu3+wv WV1+dJYzQOjStTjHNrv9tw14ujSxq5kMjxWbsu+rQ/fOaCJOsAqQnOrZ6RadPMUSz7Nj R4o4G6QC4TzXciXPnuchWYus7zZTCfrlE/3DQTUcDBplwbamQMCL5C22007ZrYIB5olw +rdR3W0rRTW5nrnS3kMdg8QfDLo6uxjn7CLZyn94j2YkgWkS4cRIjv2DhSnZhmwNbERw Dpwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=oH0ENzNwh31jP1Qyo2deSXlbpBRPQMbqFW1i+5Uoe2A=; b=q+vigwlOmu8MB6ob/HDQezIbN4dIbuSQAZu3PE5jIfr2V4V0VWhufABOlNh2pHDTUs f/YjkRx8BG7rXO722jzVXfAg/rthTFnkqsReKWZlxfvMlri1as2tSnw7vaSzlH2dpGHW AqHwCKefqdcqauEggLRqKG0O6mOkafg/741RZliMB/WH9Bqbf26iTXQOSxTZFB8rwfY/ eGV5dL5/17bnNPT6MHWmmo5umGlLg5wkAFHDgbeOUurXPbwrwVkqtXcf00fGKSZRBJs9 UmhezUoGSma+o+pong9CtsyPPl269dWmfvZdhCpzpzBpQAtyjVh0Jbs0xpTtQnXOzWtp ZD3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z188si3351235pfz.46.2018.02.21.10.42.51; Wed, 21 Feb 2018 10:43:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965788AbeBUNZh (ORCPT + 99 others); Wed, 21 Feb 2018 08:25:37 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44740 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965567AbeBUNLV (ORCPT ); Wed, 21 Feb 2018 08:11:21 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 15A59407; Wed, 21 Feb 2018 13:11:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Al Viro , "Steven Rostedt (VMware)" Subject: [PATCH 4.15 125/163] tracing: Fix parsing of globs with a wildcard at the beginning Date: Wed, 21 Feb 2018 13:49:14 +0100 Message-Id: <20180221124537.044703262@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt (VMware) commit 07234021410bbc27b7c86c18de98616c29fbe667 upstream. Al Viro reported: For substring - sure, but what about something like "*a*b" and "a*b"? AFAICS, filter_parse_regex() ends up with identical results in both cases - MATCH_GLOB and *search = "a*b". And no way for the caller to tell one from another. Testing this with the following: # cd /sys/kernel/tracing # echo '*raw*lock' > set_ftrace_filter bash: echo: write error: Invalid argument With this patch: # echo '*raw*lock' > set_ftrace_filter # cat set_ftrace_filter _raw_read_trylock _raw_write_trylock _raw_read_unlock _raw_spin_unlock _raw_write_unlock _raw_spin_trylock _raw_spin_lock _raw_write_lock _raw_read_lock Al recommended not setting the search buffer to skip the first '*' unless we know we are not using MATCH_GLOB. This implements his suggested logic. Link: http://lkml.kernel.org/r/20180127170748.GF13338@ZenIV.linux.org.uk Cc: stable@vger.kernel.org Fixes: 60f1d5e3bac44 ("ftrace: Support full glob matching") Reviewed-by: Masami Hiramatsu Reported-by: Al Viro Suggsted-by: Al Viro Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_filter.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -400,7 +400,6 @@ enum regex_type filter_parse_regex(char for (i = 0; i < len; i++) { if (buff[i] == '*') { if (!i) { - *search = buff + 1; type = MATCH_END_ONLY; } else if (i == len - 1) { if (type == MATCH_END_ONLY) @@ -410,14 +409,14 @@ enum regex_type filter_parse_regex(char buff[i] = 0; break; } else { /* pattern continues, use full glob */ - type = MATCH_GLOB; - break; + return MATCH_GLOB; } } else if (strchr("[?\\", buff[i])) { - type = MATCH_GLOB; - break; + return MATCH_GLOB; } } + if (buff[0] == '*') + *search = buff + 1; return type; }