From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751590AbeA1KcD (ORCPT ); Sun, 28 Jan 2018 05:32:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:41532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273AbeA1KcC (ORCPT ); Sun, 28 Jan 2018 05:32:02 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9360420C48 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Sun, 28 Jan 2018 05:31:56 -0500 From: Steven Rostedt To: Al Viro Cc: Dmitry Safonov <0x7f454c46@gmail.com>, open list , Masami Hiramatsu Subject: Re: [RFC] apparent bogosity in unregister_ftrace_function_probe_func() Message-ID: <20180128053156.2483e8c4@vmware.local.home> In-Reply-To: <20180127170748.GF13338@ZenIV.linux.org.uk> References: <20180127031706.GE13338@ZenIV.linux.org.uk> <20180127170748.GF13338@ZenIV.linux.org.uk> X-Mailer: Claws Mail 3.15.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 27 Jan 2018 17:07:48 +0000 Al Viro wrote: Hi Al, > On Sat, Jan 27, 2018 at 01:59:56PM +0000, Dmitry Safonov wrote: > > > > > Incidentally, shouldn't filter_parse_regex("*[ab]", 5, &s, ¬) > > > end up with s = "*[ab]"? We are returning MATCH_GLOB, after all, > > > so we want the entire pattern there... I would've assumed that > > > this is what the code in unregister_ftrace_function_probe_func() > > > is trying to compensate for, the first oddity predates MATCH_GLOB... > > > > No, I don't think filter_parse_regex() should return the full regex.. > > ftrace_match() expects search would be processed string, not a glob. > > So, this unnecessary assignment broke unregistering multiple kprobs > > with a middle/end pattern.. > > 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. > > IOW, it's a different bug sometimes obscured by the one in > unregister_ftrace_function_probe_func(). filter_parse_regex() > ought to revert to *search = buff; when it decides to return > MATCH_GLOB. Or something like > for (i = 0; i < len; i++) { > if (buff[i] == '*') { > if (!i) { > type = MATCH_END_ONLY; > } else if (i == len - 1) { > if (type == MATCH_END_ONLY) > type = MATCH_MIDDLE_ONLY; > else > type = MATCH_FRONT_ONLY; > buff[i] = 0; > break; > } else { /* pattern continues, use full glob */ > return MATCH_GLOB; > } > } else if (strchr("[?\\", buff[i])) { > return MATCH_GLOB; > } > } > if (buff[0] == '*') > *search = buff + 1; > for that matter - i.e. delay that "we want everything past the first character" > until we are certain it's not a MATCH_GLOB. > > That one was introduced by "ftrace: Support full glob matching" in 2016, AFAICS... Yep, I totally agree. This code is one of those places that haven't had the loving it deserved. It was one of our neglected children. Thanks for taking a look here. I'm a bit embarrassed by this, and should have audited it more. I'll have to rip into it and see what else may be incorrect. -- Steve