Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1397371pxj; Fri, 21 May 2021 13:14:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3K4JWgsbw1B/zlayS5iTRrRV89Hz+aLkKdsIFqFaYEc/CnpCN79lrcV4DvRXrF0GUiIxZ X-Received: by 2002:a92:c566:: with SMTP id b6mr579812ilj.222.1621628074303; Fri, 21 May 2021 13:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621628074; cv=none; d=google.com; s=arc-20160816; b=GHfUJ5sku3jdF2XLU0o7k04fp6TbwndRuUCGZuM5kSpepbFIgpHjGuacf/6/hkKefy qGYqSqw6+kw+Tj+sg4VTUOsJ37hwf1c16SOTPigWZGq5TH2sIl76uX5maCp8mrnzoNkR ygmJiEPyBwrSjy7RuN/qdc4UhcP7b9Y5uv2LlYlqPRNBBavr93VeJBjNsVQzHQhfTjaZ 2vOeX/sspJ4BzWYASXgj2nurvtcjRFHdxtVpzi2jlTPfcd1SVTdLBwk/OXOcs7Fenlu7 7Wgrd2CBItYWyZJsHIpFjAjqCg8meGJ7iomTwiy43Z6PftAwPUAxmhyBne/fSYr1ybiF VB8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nADiD1tX0a3psHklw+i0Vqe/rfU4LnRtWhqVIiYVeH0=; b=FaPm9SEKhUVvi4A4spcM5TEK5CCpS+TKvJZGshsPT7zuHrl/OcrbBwDE7KDWVc09ca casi5/k1075ATTVRuKXvcqflWJlERpLO1E7gRy5Li+Q/wv0i0n7YjpidlpqvyYmRuUGb QoySsipa7H5I1aD+WwB4beJa56g8bEO+ecLeSQwcDdVjr6E7TZvAHsWZZVYD2bLg0J0W lFz4anb9pCU1iWlWxa3m+HHXcjJ0kdMvkOOJomSTWmr7zG4UDppA0/2jtGRtpLD0vsfy AyF6lWnY6N2LjwEKGDr/wXd/0CremvZin4LsGApp43Aeb48WfmvGZsPK06gkpjjggO2j Ha3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Pwl/YLjm"; 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 a13si5989514iok.48.2021.05.21.13.14.21; Fri, 21 May 2021 13:14:34 -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="Pwl/YLjm"; 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 S231959AbhEUKrM (ORCPT + 99 others); Fri, 21 May 2021 06:47:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:38312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230480AbhEUKrL (ORCPT ); Fri, 21 May 2021 06:47:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 60AF86008E; Fri, 21 May 2021 10:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621593948; bh=AouORxPeos/y+srTBjjykWrp10gH9l+EJwzDVaBiOsg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pwl/YLjmbbmCHYM/4vkJnO4I9Xq5kU+l5NYkEjGdbPDx7Q2Uy5sr1HCjPDGq/Kifb 5WNYRdL7oSDo6bi58PSRQHTJK29fktEFhr3UT41QSaSPo+dvGT4Lu3wtIPAF8TTazG sac01OBCJb29sqDlCrzbFNlcHyUgXU8Xzqtbj+TQ= Date: Fri, 21 May 2021 12:45:46 +0200 From: Greg Kroah-Hartman To: Lee Jones Cc: Quentin Perret , Masahiro Yamada , open list , Matthias Maennich , Giuliano Procida , kernel-team@android.com Subject: Re: [PATCH] export: Make CRCs robust to symbol trimming Message-ID: References: <20210408180105.2496212-1-qperret@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 21, 2021 at 10:57:44AM +0100, Lee Jones wrote: > On Mon, 10 May 2021 at 11:25, Quentin Perret wrote: > > > Hi, > > > > On Thursday 08 Apr 2021 at 18:01:05 (+0000), Quentin Perret wrote: > > > The CRC calculation done by genksyms is triggered when the parser hits > > > EXPORT_SYMBOL*() macros. At this point, genksyms recursively expands the > > > types, and uses that as the input for the CRC calculation. In the case > > > of forward-declared structs, the type expands to 'UNKNOWN'. Next, the > > > result of the expansion of each type is cached, and is re-used when/if > > > the same type is seen again for another exported symbol in the file. > > > > > > Unfortunately, this can cause CRC 'stability' issues when a struct > > > definition becomes visible in the middle of a C file. For example, let's > > > assume code with the following pattern: > > > > > > struct foo; > > > > > > int bar(struct foo *arg) > > > { > > > /* Do work ... */ > > > } > > > EXPORT_SYMBOL_GPL(bar); > > > > > > /* This contains struct foo's definition */ > > > #include "foo.h" > > > > > > int baz(struct foo *arg) > > > { > > > /* Do more work ... */ > > > } > > > EXPORT_SYMBOL_GPL(baz); > > > > > > Here, baz's CRC will be computed using the expansion of struct foo that > > > was cached after bar's CRC calculation ('UNKOWN' here). But if > > > EXPORT_SYMBOL_GPL(bar) is removed from the file (because of e.g. symbol > > > trimming using CONFIG_TRIM_UNUSED_KSYMS), struct foo will be expanded > > > late, during baz's CRC calculation, which now has visibility over the > > > full struct definition, hence resulting in a different CRC for baz. > > > > > > This can cause annoying issues for distro kernel (such as the Android > > > Generic Kernel Image) which use CONFIG_UNUSED_KSYMS_WHITELIST. Indeed, > > > as per the above, adding a symbol to the whitelist can change the CRC of > > > symbols that are already kept exported. As such, modules built against a > > > kernel with a trimmed ABI may not load against the same kernel built > > > with an extended whitelist, even though they are still strictly binary > > > compatible. While rebuilding the modules would obviously solve the > > > issue, I believe this classifies as an odd genksyms corner case, and it > > > gets in the way of kernel updates in the GKI context. > > > > > > To work around the issue, make sure to keep issuing the > > > __GENKSYMS_EXPORT_SYMBOL macros for all trimmed symbols, hence making > > > the genksyms parsing insensitive to symbol trimming. > > > > > > Signed-off-by: Quentin Perret > > > > Gentle ping. > > > > Is there anything else I should do in this one? > > > > With Greg's Ack and ~6 weeks on the list, you're probably golden. > > I *could* pick this up, but seems wrong somehow. > > Greg, is this something you're prepared to merge? If not, who's the > g{uy,al}? What does get_maintainer.pl show?