From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.6 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796326139; b=m41ksfyyEgwvFV3j1Rexh66V7RvstUMXmEziSsKeLZFZUEAH7nZMfqeX8aOqiIba6uk6 +LCITeNTGHBQHdm8ZQONchc5aVxFa3/Rpyr/6beg7FoWClEMHd6aOHziuhuPVmdl0ErFP NCo63mydvlAlCxpBhC/QiSwM4auXp+m/C7Axx+oVONnNMLb2FREyF3sn3ImkSo2gl0wVz 3q5Si1Mz8AErYyK05W0Ejxdd654LGo/3rQVqObFTOiB3Q4igmRpnO7fTdLUxg8d6HvWuY B9Z7RQROv3pYpE97ADfUTueJ5GDUP9TG9PZ0DylNOk3gStyw/xp1/DTES/wGLVPXLFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326139; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Date:From:To: Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=eJrrjhOtNbUBaaIOmSsPEvYfV3eOBloQ9mzeTvGqLa8=; b=hvY3CssAsa3K5FL8/U183BgD8ZIwJ3uDEB7htXgdntrM0PPAU0f8450eQfXeRM3q64Wy CSeftY5H8kvy3Aug8381ayXbdws27uBbGujC1zgsbfZNnEGuCVNvE/8ZVvC56D04Vh7uQ bGKLQDvM4IReJYL0kiC6qI4/HIKXtIkXiqd4CLLfxAhFKCdjMRElkQ2OoFhT9Fvw5HXPi EB4he/i+1va6ojlf/3LwKxexuQC0YiGaIn8Gx/RP21PjCHzeqauXyoMF28v5QGMZnxmoc sD8CVDToj+PDYq6XoZVtdcuzoVB1McznvsOWBOk6Vc3PMq7gcgaZcOJrE7vq5jmdBTw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b="GksbNJ5/"; arc=none smtp.remote-ip=192.198.163.6 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.6]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D153606A69F; Thu, 3 Dec 2026 19:28:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0D153606A69F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GksbNJ5/ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796326138; x=1827862138; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=bn6S5nuWPKttUtwZMJioi4cvEL6Fhl02B8r4j8okcpI=; b=GksbNJ5/HQ+hvwdLbKgtDJ0FWPItoMvczMFQlPHtLcKvnYJuz7sSSprW xO454QDDEUOCQDUfwI+/dPGxAEIoGGGPzhQCAKbKcW1x3b9H1m75J8zLx CMUkvSCaXVSXBl7ulc0ckuvpgRpInEa9wziUlnZGvEQS6Z54ryNl6hwPI l0ccQQXJ3keSa12iR4HJWL/IZV2Kfkh3gkP1qmBrqHbeHMYhA4ahgk8Ua oVy6QsjB4VmZilDJlhF+JxsMq6qVN2Y10S+yamMlAnRwJut8CID/I04jg 3qo0GSyvoQS2OBUyg735Bb2qXpKR8jZ1efHKQjVr5CeLIzNVycUXjcp1S w==; X-CSE-ConnectionGUID: lCRz5aihSjin9wPd7CiZtA== X-CSE-MsgGUID: mE/BbpTeRuysStof4GG5Rg== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="6362" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="6362" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa116.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 11:28:57 -0800 X-CSE-ConnectionGUID: P2PrcQPrQXSARQqE8wbOdA== X-CSE-MsgGUID: tyslC3FkRb+cwvmvtbFLJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="13805122" Received: from lkp-server01.sh.intel.com (HELO 0caa9d2d175c) ([10.239.97.150]) by fmviesa004.fm.intel.com with ESMTP; 03 Dec 2026 11:28:55 -0800 Received: from kbuild by 0caa9d2d175c with local (Exim 4.98.2) (envelope-from ) id 1xZCU8-00000001iUv-1Gpv; Thu, 03 Dec 2026 19:28:52 +0000 Date: Fri, 4 Dec 2026 03:28:40 +0800 From: kernel test robot To: David Carlier , Steven Rostedt , Masami Hiramatsu Cc: oe-kbuild-all@lists.linux.dev, Mathieu Desnoyers , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays Message-ID: <20261204025535.5Ad531hZ-lkp@intel.com> References: <20261203145822.591395-1-devnexen@gmail.com> X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261203145822.591395-1-devnexen@gmail.com> Hi David, kernel test robot noticed the following build errors: [auto build test ERROR on linux-review/David-Carlier/tracing-filters-Fix-MATCH_END_ONLY-on-dynamic-char-arrays/20261126-215228] url: https://github.com/intel-lab-lkp/linux/commits/David-Carlier/tracing-filters-Fix-MATCH_END_ONLY-on-dynamic-char-arrays/20261203-145822 base: https://github.com/intel-lab-lkp/linux David-Carlier/tracing-filters-Fix-MATCH_END_ONLY-on-dynamic-char-arrays/20261126-215228 patch link: https://lore.kernel.org/r/20261203145822.591395-1-devnexen%40gmail.com patch subject: [PATCH v2] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261204/20261204025535.5Ad531hZ-lkp@intel.com/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261204/20261204025535.5Ad531hZ-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/20261204025535.5Ad531hZ-lkp@intel.com/ All errors (new ones prefixed by >>): kernel/trace/trace_events_filter.c: In function 'parse_pred': >> kernel/trace/trace_events_filter.c:2085:51: error: 'regex_match_end' undeclared (first use in this function); did you mean 'regex_match_func'? 2085 | if (pred->regex->match == regex_match_end) | ^~~~~~~~~~~~~~~ | regex_match_func kernel/trace/trace_events_filter.c:2085:51: note: each undeclared identifier is reported only once for each function it appears in vim +2085 kernel/trace/trace_events_filter.c fde59ab1614942a Steven Rostedt (Google 2022-09-06 1674) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1675) /* Called when a predicate is encountered by predicate_parse() */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1676) static int parse_pred(const char *str, void *data, 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1677) int pos, struct filter_parse_error *pe, 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1678) struct filter_pred **pred_ptr) 8b3725621074040 Tom Zanussi 2009-04-28 1679 { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1680) struct trace_event_call *call = data; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1681) struct ftrace_event_field *field; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1682) struct filter_pred *pred = NULL; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1683) unsigned long offset; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1684) unsigned long size; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1685) unsigned long ip; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1686) char num_buf[24]; /* Big enough to hold an address */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1687) char *field_name; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1688) char *name; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1689) bool function = false; f37c3bbc635994e Steven Rostedt 2022-01-13 1690 bool ustring = false; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1691) char q; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1692) u64 val; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1693) int len; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1694) int ret; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1695) int op; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1696) int s; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1697) int i = 0; 8b3725621074040 Tom Zanussi 2009-04-28 1698 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1699) /* First find the field to associate to */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1700) while (isspace(str[i])) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1701) i++; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1702) s = i; 8b3725621074040 Tom Zanussi 2009-04-28 1703 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1704) while (isalnum(str[i]) || str[i] == '_') 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1705) i++; 8b3725621074040 Tom Zanussi 2009-04-28 1706 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1707) len = i - s; 8b3725621074040 Tom Zanussi 2009-04-28 1708 c9f024f1ada1e66 Masami Hiramatsu (Google 2026-10-29 1709) if (!len) { c9f024f1ada1e66 Masami Hiramatsu (Google 2026-10-29 1710) parse_error(pe, FILT_ERR_INVALID_FILTER, pos + i); c9f024f1ada1e66 Masami Hiramatsu (Google 2026-10-29 1711) return -EINVAL; c9f024f1ada1e66 Masami Hiramatsu (Google 2026-10-29 1712) } 8b3725621074040 Tom Zanussi 2009-04-28 1713 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1714) field_name = kmemdup_nul(str + s, len, GFP_KERNEL); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1715) if (!field_name) 8b3725621074040 Tom Zanussi 2009-04-28 1716 return -ENOMEM; 8b3725621074040 Tom Zanussi 2009-04-28 1717 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1718) /* Make sure that the field exists */ 8b3725621074040 Tom Zanussi 2009-04-28 1719 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1720) field = trace_find_event_field(call, field_name); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1721) kfree(field_name); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1722) if (!field) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1723) parse_error(pe, FILT_ERR_FIELD_NOT_FOUND, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1724) return -EINVAL; 8b3725621074040 Tom Zanussi 2009-04-28 1725 } 8b3725621074040 Tom Zanussi 2009-04-28 1726 f37c3bbc635994e Steven Rostedt 2022-01-13 1727 /* See if the field is a user space string */ f37c3bbc635994e Steven Rostedt 2022-01-13 1728 if ((len = str_has_prefix(str + i, ".ustring"))) { f37c3bbc635994e Steven Rostedt 2022-01-13 1729 ustring = true; f37c3bbc635994e Steven Rostedt 2022-01-13 1730 i += len; f37c3bbc635994e Steven Rostedt 2022-01-13 1731 } f37c3bbc635994e Steven Rostedt 2022-01-13 1732 e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1733) /* See if the field is a kernel function name */ e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1734) if ((len = str_has_prefix(str + i, ".function"))) { 56ce4ed6316cae9 David Carlier 2026-11-19 1735 /* Ignore if event is already a function */ 56ce4ed6316cae9 David Carlier 2026-11-19 1736 if (!ftrace_event_is_function(call)) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1737) function = true; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1738) i += len; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1739) } e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1740) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1741) while (isspace(str[i])) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1742) i++; 8b3725621074040 Tom Zanussi 2009-04-28 1743 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1744) /* Make sure this op is supported */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1745) for (op = 0; ops[op]; op++) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1746) /* This is why '<=' must come before '<' in ops[] */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1747) if (strncmp(str + i, ops[op], strlen(ops[op])) == 0) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1748) break; 8b3725621074040 Tom Zanussi 2009-04-28 1749 } 8b3725621074040 Tom Zanussi 2009-04-28 1750 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1751) if (!ops[op]) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1752) parse_error(pe, FILT_ERR_INVALID_OP, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1753) goto err_free; 5928c3cc0ffcb68 Frederic Weisbecker 2009-05-03 1754 } 5928c3cc0ffcb68 Frederic Weisbecker 2009-05-03 1755 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1756) i += strlen(ops[op]); 8b3725621074040 Tom Zanussi 2009-04-28 1757 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1758) while (isspace(str[i])) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1759) i++; 8b3725621074040 Tom Zanussi 2009-04-28 1760 42647658bdd8434 Masami Hiramatsu (Google 2026-10-29 1761) if (!str[i]) { 42647658bdd8434 Masami Hiramatsu (Google 2026-10-29 1762) parse_error(pe, FILT_ERR_INVALID_FILTER, pos + i); 42647658bdd8434 Masami Hiramatsu (Google 2026-10-29 1763) goto err_free; 42647658bdd8434 Masami Hiramatsu (Google 2026-10-29 1764) } 42647658bdd8434 Masami Hiramatsu (Google 2026-10-29 1765) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1766) s = i; 8b3725621074040 Tom Zanussi 2009-04-28 1767 bf4afc53b77aeaa Linus Torvalds 2026-02-21 1768 pred = kzalloc_obj(*pred); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1769) if (!pred) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1770) return -ENOMEM; 8b3725621074040 Tom Zanussi 2009-04-28 1771 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1772) pred->field = field; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1773) pred->offset = field->offset; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1774) pred->op = op; 8b3725621074040 Tom Zanussi 2009-04-28 1775 e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1776) if (function) { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1777) /* The field must be the same size as long */ e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1778) if (field->size != sizeof(long)) { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1779) parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1780) goto err_free; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1781) } e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1782) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1783) /* Function only works with '==' or '!=' and an unquoted string */ e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1784) switch (op) { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1785) case OP_NE: e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1786) case OP_EQ: e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1787) break; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1788) default: e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1789) parse_error(pe, FILT_ERR_INVALID_OP, pos + i); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1790) goto err_free; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1791) } e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1792) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1793) if (isdigit(str[i])) { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1794) /* We allow 0xDEADBEEF */ e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1795) while (isalnum(str[i])) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1796) i++; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1797) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1798) len = i - s; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1799) /* 0xfeedfacedeadbeef is 18 chars max */ e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1800) if (len >= sizeof(num_buf)) { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1801) parse_error(pe, FILT_ERR_OPERAND_TOO_LONG, pos + i); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1802) goto err_free; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1803) } e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1804) 77a1326f64c3245 Justin Stitt 2024-10-14 1805 memcpy(num_buf, str + s, len); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1806) num_buf[len] = 0; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1807) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1808) ret = kstrtoul(num_buf, 0, &ip); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1809) if (ret) { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1810) parse_error(pe, FILT_ERR_INVALID_VALUE, pos + i); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1811) goto err_free; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1812) } e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1813) } else { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1814) s = i; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1815) for (; str[i] && !isspace(str[i]); i++) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1816) ; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1817) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1818) len = i - s; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1819) name = kmemdup_nul(str + s, len, GFP_KERNEL); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1820) if (!name) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1821) goto err_mem; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1822) ip = kallsyms_lookup_name(name); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1823) kfree(name); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1824) if (!ip) { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1825) parse_error(pe, FILT_ERR_NO_FUNCTION, pos + i); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1826) goto err_free; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1827) } e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1828) } e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1829) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1830) /* Now find the function start and end address */ e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1831) if (!kallsyms_lookup_size_offset(ip, &size, &offset)) { e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1832) parse_error(pe, FILT_ERR_NO_FUNCTION, pos + i); e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1833) goto err_free; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1834) } e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1835) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1836) pred->fn_num = FILTER_PRED_FN_FUNCTION; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1837) pred->val = ip - offset; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1838) pred->val2 = pred->val + size; e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1839) e6745a4da964f5f Steven Rostedt (Google 2022-12-19 1840) } else if (ftrace_event_is_function(call)) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1841) /* 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1842) * Perf does things different with function events. 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1843) * It only allows an "ip" field, and expects a string. 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1844) * But the string does not need to be surrounded by quotes. 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1845) * If it is a string, the assigned function as a nop, 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1846) * (perf doesn't use it) and grab everything. 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1847) */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1848) if (strcmp(field->name, "ip") != 0) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1849) parse_error(pe, FILT_ERR_IP_FIELD_ONLY, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1850) goto err_free; 8b3725621074040 Tom Zanussi 2009-04-28 1851 } fde59ab1614942a Steven Rostedt (Google 2022-09-06 1852) pred->fn_num = FILTER_PRED_FN_NOP; 8b3725621074040 Tom Zanussi 2009-04-28 1853 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1854) /* 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1855) * Quotes are not required, but if they exist then we need 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1856) * to read them till we hit a matching one. 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1857) */ 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1858) if (str[i] == '\'' || str[i] == '"') { 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1859) q = str[i++]; 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1860) s = i; 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1861) } else { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1862) q = 0; 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1863) } 8b3725621074040 Tom Zanussi 2009-04-28 1864 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1865) for (; str[i]; i++) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1866) if (q && str[i] == q) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1867) break; 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1868) if (!q) { 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1869) if (str[i] == ')' || str[i] == '&' || 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1870) str[i] == '|') 8b3725621074040 Tom Zanussi 2009-04-28 1871 break; 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1872) if (str[i] == '(' || str[i] == '\'' || 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1873) str[i] == '"') { 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1874) parse_error(pe, FILT_ERR_INVALID_VALUE, 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1875) pos + i); 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1876) goto err_free; 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1877) } 1bacf3014170cc0 Masami Hiramatsu (Google 2026-10-29 1878) } 7ce7e4249921d50 Tom Zanussi 2009-03-22 1879 } 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1880) if (q && !str[i]) { 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1881) parse_error(pe, FILT_ERR_MISSING_QUOTE, pos + i); 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1882) goto err_free; 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1883) } 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1884) len = i - s; 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1885) if (q) 11b973b2c72637f Masami Hiramatsu (Google 2026-10-29 1886) i++; a3653d0a71607dc Masami Hiramatsu (Google 2026-10-29 1887) if (!q && !len) { a3653d0a71607dc Masami Hiramatsu (Google 2026-10-29 1888) parse_error(pe, FILT_ERR_INVALID_VALUE, pos + i); a3653d0a71607dc Masami Hiramatsu (Google 2026-10-29 1889) goto err_free; a3653d0a71607dc Masami Hiramatsu (Google 2026-10-29 1890) } 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1891) if (len >= MAX_FILTER_STR_VAL) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1892) parse_error(pe, FILT_ERR_OPERAND_TOO_LONG, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 1893) goto err_free; 7ce7e4249921d50 Tom Zanussi 2009-03-22 1894 } 8b3725621074040 Tom Zanussi 2009-04-28 1895 bf4afc53b77aeaa Linus Torvalds 2026-02-21 1896 pred->regex = kzalloc_obj(*pred->regex); cfb58e278c6a6b1 Valentin Schneider 2023-07-07 1897 if (!pred->regex) cfb58e278c6a6b1 Valentin Schneider 2023-07-07 1898 goto err_mem; cfb58e278c6a6b1 Valentin Schneider 2023-07-07 1899 pred->regex->len = len; 77a1326f64c3245 Justin Stitt 2024-10-14 1900 memcpy(pred->regex->pattern, str + s, len); cfb58e278c6a6b1 Valentin Schneider 2023-07-07 1901 pred->regex->pattern[len] = 0; 8b3725621074040 Tom Zanussi 2009-04-28 1902 39f7c41c908bc82 Valentin Schneider 2023-07-07 1903 } else if (!strncmp(str + i, "CPUS", 4)) { 39f7c41c908bc82 Valentin Schneider 2023-07-07 1904 unsigned int maskstart; fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1905 bool single; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1906 char *tmp; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1907 39f7c41c908bc82 Valentin Schneider 2023-07-07 1908 switch (field->filter_type) { 39f7c41c908bc82 Valentin Schneider 2023-07-07 1909 case FILTER_CPUMASK: 347d24fc8286e76 Valentin Schneider 2023-07-07 1910 case FILTER_CPU: 3cbec9d7b93d330 Valentin Schneider 2023-07-07 1911 case FILTER_OTHER: 39f7c41c908bc82 Valentin Schneider 2023-07-07 1912 break; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1913 default: 39f7c41c908bc82 Valentin Schneider 2023-07-07 1914 parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1915 goto err_free; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1916 } 39f7c41c908bc82 Valentin Schneider 2023-07-07 1917 39f7c41c908bc82 Valentin Schneider 2023-07-07 1918 switch (op) { 39f7c41c908bc82 Valentin Schneider 2023-07-07 1919 case OP_EQ: 39f7c41c908bc82 Valentin Schneider 2023-07-07 1920 case OP_NE: 39f7c41c908bc82 Valentin Schneider 2023-07-07 1921 case OP_BAND: 39f7c41c908bc82 Valentin Schneider 2023-07-07 1922 break; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1923 default: 39f7c41c908bc82 Valentin Schneider 2023-07-07 1924 parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1925 goto err_free; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1926 } 39f7c41c908bc82 Valentin Schneider 2023-07-07 1927 39f7c41c908bc82 Valentin Schneider 2023-07-07 1928 /* Skip CPUS */ 39f7c41c908bc82 Valentin Schneider 2023-07-07 1929 i += 4; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1930 if (str[i++] != '{') { 39f7c41c908bc82 Valentin Schneider 2023-07-07 1931 parse_error(pe, FILT_ERR_MISSING_BRACE_OPEN, pos + i); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1932 goto err_free; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1933 } 39f7c41c908bc82 Valentin Schneider 2023-07-07 1934 maskstart = i; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1935 39f7c41c908bc82 Valentin Schneider 2023-07-07 1936 /* Walk the cpulist until closing } */ cbb557ba92f08b9 Valentin Schneider 2023-09-01 1937 for (; str[i] && str[i] != '}'; i++) cbb557ba92f08b9 Valentin Schneider 2023-09-01 1938 ; cbb557ba92f08b9 Valentin Schneider 2023-09-01 1939 39f7c41c908bc82 Valentin Schneider 2023-07-07 1940 if (str[i] != '}') { 39f7c41c908bc82 Valentin Schneider 2023-07-07 1941 parse_error(pe, FILT_ERR_MISSING_BRACE_CLOSE, pos + i); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1942 goto err_free; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1943 } 39f7c41c908bc82 Valentin Schneider 2023-07-07 1944 39f7c41c908bc82 Valentin Schneider 2023-07-07 1945 if (maskstart == i) { 39f7c41c908bc82 Valentin Schneider 2023-07-07 1946 parse_error(pe, FILT_ERR_INVALID_CPULIST, pos + i); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1947 goto err_free; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1948 } 39f7c41c908bc82 Valentin Schneider 2023-07-07 1949 39f7c41c908bc82 Valentin Schneider 2023-07-07 1950 /* Copy the cpulist between { and } */ 39f7c41c908bc82 Valentin Schneider 2023-07-07 1951 tmp = kmalloc((i - maskstart) + 1, GFP_KERNEL); 9af4058493c5972 Valentin Schneider 2023-09-01 1952 if (!tmp) 9af4058493c5972 Valentin Schneider 2023-09-01 1953 goto err_mem; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1954 9af4058493c5972 Valentin Schneider 2023-09-01 1955 strscpy(tmp, str + maskstart, (i - maskstart) + 1); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1956 pred->mask = kzalloc(cpumask_size(), GFP_KERNEL); 9af4058493c5972 Valentin Schneider 2023-09-01 1957 if (!pred->mask) { 9af4058493c5972 Valentin Schneider 2023-09-01 1958 kfree(tmp); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1959 goto err_mem; 9af4058493c5972 Valentin Schneider 2023-09-01 1960 } 39f7c41c908bc82 Valentin Schneider 2023-07-07 1961 39f7c41c908bc82 Valentin Schneider 2023-07-07 1962 /* Now parse it */ 39f7c41c908bc82 Valentin Schneider 2023-07-07 1963 if (cpulist_parse(tmp, pred->mask)) { 9af4058493c5972 Valentin Schneider 2023-09-01 1964 kfree(tmp); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1965 parse_error(pe, FILT_ERR_INVALID_CPULIST, pos + i); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1966 goto err_free; 39f7c41c908bc82 Valentin Schneider 2023-07-07 1967 } 9af4058493c5972 Valentin Schneider 2023-09-01 1968 kfree(tmp); 39f7c41c908bc82 Valentin Schneider 2023-07-07 1969 39f7c41c908bc82 Valentin Schneider 2023-07-07 1970 /* Move along */ 39f7c41c908bc82 Valentin Schneider 2023-07-07 1971 i++; fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1972 fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1973 /* fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1974 * Optimisation: if the user-provided mask has a weight of one fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1975 * then we can treat it as a scalar input. fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1976 */ fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1977 single = cpumask_weight(pred->mask) == 1; 1cffbe6c62f10e2 Valentin Schneider 2023-07-07 1978 if (single) { fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1979 pred->val = cpumask_first(pred->mask); fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1980 kfree(pred->mask); 1caf7adb9e00047 Valentin Schneider 2023-09-01 1981 pred->mask = NULL; fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1982 } fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1983 3cbec9d7b93d330 Valentin Schneider 2023-07-07 1984 if (field->filter_type == FILTER_CPUMASK) { fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1985 pred->fn_num = single ? fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1986 FILTER_PRED_FN_CPUMASK_CPU : fe4fa4ec9b464f5 Valentin Schneider 2023-07-07 1987 FILTER_PRED_FN_CPUMASK; 347d24fc8286e76 Valentin Schneider 2023-07-07 1988 } else if (field->filter_type == FILTER_CPU) { 1cffbe6c62f10e2 Valentin Schneider 2023-07-07 1989 if (single) { 2900bcbee3899e9 Valentin Schneider 2023-09-01 1990 if (pred->op == OP_BAND) 2900bcbee3899e9 Valentin Schneider 2023-09-01 1991 pred->op = OP_EQ; 2900bcbee3899e9 Valentin Schneider 2023-09-01 1992 1cffbe6c62f10e2 Valentin Schneider 2023-07-07 1993 pred->fn_num = FILTER_PRED_FN_CPU; 1cffbe6c62f10e2 Valentin Schneider 2023-07-07 1994 } else { 347d24fc8286e76 Valentin Schneider 2023-07-07 1995 pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK; 1cffbe6c62f10e2 Valentin Schneider 2023-07-07 1996 } ca77dd8ce4658d1 Valentin Schneider 2023-07-07 1997 } else if (single) { 2900bcbee3899e9 Valentin Schneider 2023-09-01 1998 if (pred->op == OP_BAND) 2900bcbee3899e9 Valentin Schneider 2023-09-01 1999 pred->op = OP_EQ; 2900bcbee3899e9 Valentin Schneider 2023-09-01 2000 ca77dd8ce4658d1 Valentin Schneider 2023-07-07 2001 pred->fn_num = select_comparison_fn(pred->op, field->size, false); ca77dd8ce4658d1 Valentin Schneider 2023-07-07 2002 if (pred->op == OP_NE) ca77dd8ce4658d1 Valentin Schneider 2023-07-07 2003 pred->not = 1; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2004 } else { 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2005 switch (field->size) { 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2006 case 8: 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2007 pred->fn_num = FILTER_PRED_FN_64_CPUMASK; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2008 break; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2009 case 4: 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2010 pred->fn_num = FILTER_PRED_FN_32_CPUMASK; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2011 break; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2012 case 2: 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2013 pred->fn_num = FILTER_PRED_FN_16_CPUMASK; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2014 break; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2015 case 1: 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2016 pred->fn_num = FILTER_PRED_FN_8_CPUMASK; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2017 break; 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2018 } 3cbec9d7b93d330 Valentin Schneider 2023-07-07 2019 } b0c30afb394edc4 Masami Hiramatsu (Google 2026-10-29 2020) if (pred->fn_num == FILTER_PRED_FN_NOP) { b0c30afb394edc4 Masami Hiramatsu (Google 2026-10-29 2021) parse_error(pe, FILT_ERR_INVALID_OP, pos + i); b0c30afb394edc4 Masami Hiramatsu (Google 2026-10-29 2022) goto err_free; b0c30afb394edc4 Masami Hiramatsu (Google 2026-10-29 2023) } 39f7c41c908bc82 Valentin Schneider 2023-07-07 2024 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2025) /* This is either a string, or an integer */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2026) } else if (str[i] == '\'' || str[i] == '"') { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2027) char q = str[i]; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2028) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2029) /* Make sure the op is OK for strings */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2030) switch (op) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2031) case OP_NE: 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2032) pred->not = 1; df561f6688fef77 Gustavo A. R. Silva 2020-08-23 2033 fallthrough; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2034) case OP_GLOB: 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2035) case OP_EQ: 8b3725621074040 Tom Zanussi 2009-04-28 2036 break; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2037) default: 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2038) parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2039) goto err_free; 8b3725621074040 Tom Zanussi 2009-04-28 2040 } 8b3725621074040 Tom Zanussi 2009-04-28 2041 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2042) /* Make sure the field is OK for strings */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2043) if (!is_string_field(field)) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2044) parse_error(pe, FILT_ERR_EXPECT_DIGIT, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2045) goto err_free; 8b3725621074040 Tom Zanussi 2009-04-28 2046 } 8b3725621074040 Tom Zanussi 2009-04-28 2047 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2048) for (i++; str[i]; i++) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2049) if (str[i] == q) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2050) break; 8b3725621074040 Tom Zanussi 2009-04-28 2051 } 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2052) if (!str[i]) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2053) parse_error(pe, FILT_ERR_MISSING_QUOTE, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2054) goto err_free; 61aaef55300088e Jiri Olsa 2011-08-11 2055 } 8b3725621074040 Tom Zanussi 2009-04-28 2056 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2057) /* Skip quotes */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2058) s++; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2059) len = i - s; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2060) if (len >= MAX_FILTER_STR_VAL) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2061) parse_error(pe, FILT_ERR_OPERAND_TOO_LONG, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2062) goto err_free; 8b3725621074040 Tom Zanussi 2009-04-28 2063 } 8b3725621074040 Tom Zanussi 2009-04-28 2064 bf4afc53b77aeaa Linus Torvalds 2026-02-21 2065 pred->regex = kzalloc_obj(*pred->regex); cfb58e278c6a6b1 Valentin Schneider 2023-07-07 2066 if (!pred->regex) cfb58e278c6a6b1 Valentin Schneider 2023-07-07 2067 goto err_mem; cfb58e278c6a6b1 Valentin Schneider 2023-07-07 2068 pred->regex->len = len; 77a1326f64c3245 Justin Stitt 2024-10-14 2069 memcpy(pred->regex->pattern, str + s, len); cfb58e278c6a6b1 Valentin Schneider 2023-07-07 2070 pred->regex->pattern[len] = 0; 8b3725621074040 Tom Zanussi 2009-04-28 2071 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2072) filter_build_regex(pred); 8b3725621074040 Tom Zanussi 2009-04-28 2073 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2074) if (field->filter_type == FILTER_COMM) { fde59ab1614942a Steven Rostedt (Google 2022-09-06 2075) pred->fn_num = FILTER_PRED_FN_COMM; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2076) } else if (field->filter_type == FILTER_STATIC_STRING) { fde59ab1614942a Steven Rostedt (Google 2022-09-06 2077) pred->fn_num = FILTER_PRED_FN_STRING; cfb58e278c6a6b1 Valentin Schneider 2023-07-07 2078 pred->regex->field_len = field->size; 5389957f6913ac8 David Carlier 2026-12-03 2079 if (pred->regex->match == regex_match_end_str && 5389957f6913ac8 David Carlier 2026-12-03 2080 !field->size) b82178ad9e282e2 Masami Hiramatsu (Google 2026-10-29 2081) pred->regex->match = regex_match_end_dynstr; 7ce7e4249921d50 Tom Zanussi 2009-03-22 2082 05770dd0ad11085 Masami Hiramatsu 2021-11-22 2083 } else if (field->filter_type == FILTER_DYN_STRING) { fde59ab1614942a Steven Rostedt (Google 2022-09-06 2084) pred->fn_num = FILTER_PRED_FN_STRLOC; 1acf1f594e24509 David Carlier 2026-11-26 @2085 if (pred->regex->match == regex_match_end) 1acf1f594e24509 David Carlier 2026-11-26 2086 pred->regex->match = regex_match_end_str; 7884b0bf098c5f3 Chen Jun 2026-08-21 2087 } else if (field->filter_type == FILTER_RDYN_STRING) { fde59ab1614942a Steven Rostedt (Google 2022-09-06 2088) pred->fn_num = FILTER_PRED_FN_STRRELLOC; 1acf1f594e24509 David Carlier 2026-11-26 2089 if (pred->regex->match == regex_match_end) 1acf1f594e24509 David Carlier 2026-11-26 2090 pred->regex->match = regex_match_end_str; 7884b0bf098c5f3 Chen Jun 2026-08-21 2091 } else if (field->filter_type == FILTER_WITHIN) { 7884b0bf098c5f3 Chen Jun 2026-08-21 2092 unsigned long func; 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2093 b16cb6d8040fca3 Steven Rostedt 2026-08-21 2094 if (op == OP_GLOB) { b16cb6d8040fca3 Steven Rostedt 2026-08-21 2095 parse_error(pe, FILT_ERR_GLOB_WITHIN, pos + i); 7884b0bf098c5f3 Chen Jun 2026-08-21 2096 goto err_free; b16cb6d8040fca3 Steven Rostedt 2026-08-21 2097 } 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2098 7884b0bf098c5f3 Chen Jun 2026-08-21 2099 pred->fn_num = FILTER_PRED_FN_WITHIN; 7884b0bf098c5f3 Chen Jun 2026-08-21 2100 func = kallsyms_lookup_name(pred->regex->pattern); 7884b0bf098c5f3 Chen Jun 2026-08-21 2101 if (!func) { 7884b0bf098c5f3 Chen Jun 2026-08-21 2102 parse_error(pe, FILT_ERR_NO_FUNCTION, pos + i); 7884b0bf098c5f3 Chen Jun 2026-08-21 2103 goto err_free; 7884b0bf098c5f3 Chen Jun 2026-08-21 2104 } 7884b0bf098c5f3 Chen Jun 2026-08-21 2105 /* Now find the function start and end address */ 7884b0bf098c5f3 Chen Jun 2026-08-21 2106 if (!kallsyms_lookup_size_offset(func, &size, &offset)) { 7884b0bf098c5f3 Chen Jun 2026-08-21 2107 parse_error(pe, FILT_ERR_NO_FUNCTION, pos + i); 7884b0bf098c5f3 Chen Jun 2026-08-21 2108 goto err_free; 7884b0bf098c5f3 Chen Jun 2026-08-21 2109 } 7884b0bf098c5f3 Chen Jun 2026-08-21 2110 pred->val = func - offset; 7884b0bf098c5f3 Chen Jun 2026-08-21 2111 pred->val2 = pred->val + size; 7884b0bf098c5f3 Chen Jun 2026-08-21 2112 } else { 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2113 if (!ustring_per_cpu) { 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2114 /* Once allocated, keep it around for good */ 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2115 ustring_per_cpu = alloc_percpu(struct ustring_buffer); 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2116 if (!ustring_per_cpu) 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2117 goto err_mem; 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2118 } 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2119 f37c3bbc635994e Steven Rostedt 2022-01-13 2120 if (ustring) fde59ab1614942a Steven Rostedt (Google 2022-09-06 2121) pred->fn_num = FILTER_PRED_FN_PCHAR_USER; f37c3bbc635994e Steven Rostedt 2022-01-13 2122 else fde59ab1614942a Steven Rostedt (Google 2022-09-06 2123) pred->fn_num = FILTER_PRED_FN_PCHAR; 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2124 } 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2125) /* go past the last quote */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2126) i++; 8b3725621074040 Tom Zanussi 2009-04-28 2127 6a072128d262d2b Pavel Tikhomirov 2018-08-23 2128 } else if (isdigit(str[i]) || str[i] == '-') { c9c53ca03d6f97f Steven Rostedt 2011-01-27 2129 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2130) /* Make sure the field is not a string */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2131) if (is_string_field(field)) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2132) parse_error(pe, FILT_ERR_EXPECT_STRING, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2133) goto err_free; c9c53ca03d6f97f Steven Rostedt 2011-01-27 2134 } c9c53ca03d6f97f Steven Rostedt 2011-01-27 2135 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2136) if (op == OP_GLOB) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2137) parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2138) goto err_free; c9c53ca03d6f97f Steven Rostedt 2011-01-27 2139 } c9c53ca03d6f97f Steven Rostedt 2011-01-27 2140 6a072128d262d2b Pavel Tikhomirov 2018-08-23 2141 if (str[i] == '-') 6a072128d262d2b Pavel Tikhomirov 2018-08-23 2142 i++; 6a072128d262d2b Pavel Tikhomirov 2018-08-23 2143 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2144) /* We allow 0xDEADBEEF */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2145) while (isalnum(str[i])) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2146) i++; f03f5979945c573 Jiri Olsa 2011-08-11 2147 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2148) len = i - s; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2149) /* 0xfeedfacedeadbeef is 18 chars max */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2150) if (len >= sizeof(num_buf)) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2151) parse_error(pe, FILT_ERR_OPERAND_TOO_LONG, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2152) goto err_free; f03f5979945c573 Jiri Olsa 2011-08-11 2153 } f03f5979945c573 Jiri Olsa 2011-08-11 2154 77a1326f64c3245 Justin Stitt 2024-10-14 2155 memcpy(num_buf, str + s, len); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2156) num_buf[len] = 0; ec126cac23945de Steven Rostedt 2011-01-27 2157 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2158) /* Make sure it is a value */ 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2159) if (field->is_signed) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2160) ret = kstrtoll(num_buf, 0, &val); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2161) else 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2162) ret = kstrtoull(num_buf, 0, &val); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2163) if (ret) { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2164) parse_error(pe, FILT_ERR_ILLEGAL_INTVAL, pos + s); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2165) goto err_free; ec126cac23945de Steven Rostedt 2011-01-27 2166 } ec126cac23945de Steven Rostedt 2011-01-27 2167 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2168) pred->val = val; 43cd414552d8137 Steven Rostedt 2011-01-27 2169 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2170) if (field->filter_type == FILTER_CPU) fde59ab1614942a Steven Rostedt (Google 2022-09-06 2171) pred->fn_num = FILTER_PRED_FN_CPU; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2172) else { fde59ab1614942a Steven Rostedt (Google 2022-09-06 2173) pred->fn_num = select_comparison_fn(pred->op, field->size, 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2174) field->is_signed); b0c30afb394edc4 Masami Hiramatsu (Google 2026-10-29 2175) if (pred->fn_num == FILTER_PRED_FN_NOP) { b0c30afb394edc4 Masami Hiramatsu (Google 2026-10-29 2176) parse_error(pe, FILT_ERR_INVALID_OP, pos + i); b0c30afb394edc4 Masami Hiramatsu (Google 2026-10-29 2177) goto err_free; b0c30afb394edc4 Masami Hiramatsu (Google 2026-10-29 2178) } 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2179) if (pred->op == OP_NE) 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2180) pred->not = 1; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2181) } 43cd414552d8137 Steven Rostedt 2011-01-27 2182 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2183) } else { 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2184) parse_error(pe, FILT_ERR_INVALID_VALUE, pos + i); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2185) goto err_free; 43cd414552d8137 Steven Rostedt 2011-01-27 2186 } 43cd414552d8137 Steven Rostedt 2011-01-27 2187 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2188) *pred_ptr = pred; 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2189) return i; c00b060f36e1238 Jiri Olsa 2011-08-11 2190 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2191) err_free: cfb58e278c6a6b1 Valentin Schneider 2023-07-07 2192 free_predicate(pred); 80765597bc587fe Steven Rostedt (VMware 2018-03-09 2193) return -EINVAL; 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2194 err_mem: cfb58e278c6a6b1 Valentin Schneider 2023-07-07 2195 free_predicate(pred); 77360f9bbc7e5e2 Steven Rostedt 2022-01-10 2196 return -ENOMEM; 43cd414552d8137 Steven Rostedt 2011-01-27 2197 } 43cd414552d8137 Steven Rostedt 2011-01-27 2198 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki