From patchwork Fri May 5 11:57:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 98627 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp81135qge; Fri, 5 May 2017 04:58:09 -0700 (PDT) X-Received: by 10.98.192.80 with SMTP id x77mr4361461pff.1.1493985488950; Fri, 05 May 2017 04:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1493985488; cv=none; d=google.com; s=arc-20160816; b=Suurte2W8G0eK+nvTBeI3Td3uSWP9DaLfVP0weJr49PSq4bskNic/UGXIIT2+aBaMg Wr+Xy1crUat4ZhdK/Sbv4MZu1eHqlKJg+dzxgriFn1hi8/Ce6C93GL/ooWKx5BktxtLn aK5X9lviQ/z3WN75GWYn2IdKVyDOS1kpah7IgUABVCAvO9DhqJIyniaH9FsyBFkvV4Ha CWMpULjlLahLyJA6Cu/zo3fzhj5r0LxdMsMh6Rr3T2sh1GlPjGqxjSQNwD4La+tHWTHi +Dfv+COwvvcmVkPDu6WBPwBlYLDcLWb2TM6hjO+5VyJ6+7Jpm7Urdlo7o9Q+xa+Bv3em LssA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=pJH3pmBEyytw2eKKZNxbZeTMWieQnNvbqP2ex498oEA=; b=z8UpGrDExpTsu6ink9fRjuIcZtz4IABiMai+u7x3brmqEkMxspdO58brdDhplrSlHC PowZ6X9JGObkIaTLAi6tnW4BkeuzEs1xpjpiCqA8ZveHasoIFJn6mtH9IXsgYowlfUDx htbRW5Fd6rVoV7tYbsWYqCupFGbDyqRyW/OTkA4JtX8UYMvfoXY1LsTdEt68rXNUTDT1 qe2XxOppF1NiVPj5wKUVcKkhSV5by9E630cxJzxRLkbu4J7VDoO+B92e/5OHcztfRlg9 HYOlwT1F+BxbaA00Q21GhS+nH54tbOBofh86h1WvNHoSleFfqTYJcX7VzsphsqR1nG2V Rhow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 m25si5435892pli.193.2017.05.05.04.58.08; Fri, 05 May 2017 04:58:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753263AbdEEL55 (ORCPT + 6 others); Fri, 5 May 2017 07:57:57 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:54515 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753179AbdEEL54 (ORCPT ); Fri, 5 May 2017 07:57:56 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0MBCPl-1dEYTQ1YuL-00ACvY; Fri, 05 May 2017 13:57:33 +0200 From: Arnd Bergmann To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, Paul Gortmaker , Rusty Russell , Arnd Bergmann Subject: [PATCH 2/9] [3.18-stable] modpost: expand pattern matching to support substring matches Date: Fri, 5 May 2017 13:57:18 +0200 Message-Id: <20170505115725.1424772-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170505115725.1424772-1-arnd@arndb.de> References: <20170505115725.1424772-1-arnd@arndb.de> X-Provags-ID: V03:K0:Kh8gp4HGOCDFtjqMZqwzAnNC0F4/aRgi4tXQ8gGQ4xQGqcAqkcq BpjVWqJD42aqZIxA1CsuHdg0rgxh6yF/p4SQM1enppVlCthlg4nbfCd58wZbH3WVGsAayuS jtBev4S9uudKO2vnFt5e283+P2U+Dc3tuY4o4tDtVxrGPenR5GWuzmBP9wta/evok8+Yk2a kBCZcWU7FwAdY65jBTZeQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:Efnp/cREowo=:f5JnZTO1POqMLDz9zUyQoK wmLCGDBt8Z9yAJcT1ubVOF1bDEQqiA+fej7+gP0g833whmpVcV+0ZW49Y1poYKoILoKNud5Qe dZ+kFHBzzu0JYlKYRGC4u4OGRU7sNlkXeowMvoUUACwTS6YOSfOEzK4p+y59TEGeBgM3tKMLt KwogmpTCZbYpBYnYgEVU8WefJUFnh2KBn4qjhzaTrd/sM9nVAgvf3X/bwxEKOZkqBt9g+8pP/ vLWZ+u2nA8MU2YNqPJv7/WZtvAwGbWmv7qTnTqMu8D+BjPBlNC8UbfFfCcYJ8IeIHRTHAg4zG cwwyOXkZeym04WKFpaNQAC7Qy6dDptWkHLtuHFQ67aH5OQt6iUQ0iqYhYlcWJT3IOIpT7gc/P vbpAMhkhZlEKdpnvV7inS4VMyYGCJxmPzQvY4d02Zj8/QGiwA/6iOq5epQ1BTr/8CCm/XXIYH QJb2xQhSVhd6PTppbcqZbBCK8JhsF14iEp4Ka3ET+K1F5OBLSiGP/9vEGLZYt2y4GY5D6hehP ZGk760PiwRDsRxSnHqbKo9KfPDxkhCl2vLa0NaZPE9brx4tg0JyuSIaZNV4T7UFRbFJGry3zq GWO56gpnn06ND/U9JGxDq4qx45/x+uQefOjLBeeQLStNm1sYclq4iClohQ9DrsYMKNB7sOm0h Qk03QHwqwOIZByapSrHbmGmIE1wxR7F+ddvKU22LdHI/kUP8JSKMCMM+tqmWTsN5Xuss= Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Paul Gortmaker Commit 09c20c032b0f753969ae778d9783d946f054d7fe upstream. Currently the match() function supports a leading * to match any prefix and a trailing * to match any suffix. However there currently is not a combination of both that can be used to target matches of whole families of functions that share a common substring. Here we expand the *foo and foo* match to also support *foo* with the goal of targeting compiler generated symbol names that contain strings like ".constprop." and ".isra." Signed-off-by: Paul Gortmaker Signed-off-by: Rusty Russell Signed-off-by: Arnd Bergmann --- scripts/mod/modpost.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.9.0 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d439856f8176..688b93cc06fe 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -776,6 +776,7 @@ static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) * "foo" will match an exact string equal to "foo" * "*foo" will match a string that ends with "foo" * "foo*" will match a string that begins with "foo" + * "*foo*" will match a string that contains "foo" */ static int match(const char *sym, const char * const pat[]) { @@ -784,8 +785,17 @@ static int match(const char *sym, const char * const pat[]) p = *pat++; const char *endp = p + strlen(p) - 1; + /* "*foo*" */ + if (*p == '*' && *endp == '*') { + char *here, *bare = strndup(p + 1, strlen(p) - 2); + + here = strstr(sym, bare); + free(bare); + if (here != NULL) + return 1; + } /* "*foo" */ - if (*p == '*') { + else if (*p == '*') { if (strrcmp(sym, p + 1) == 0) return 1; }