Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp289016rdh; Thu, 23 Nov 2023 04:14:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCAAVqvE1eiuzs42C2gyDaDWzAop7fnjcFFpq+CzMcLGAkNvNzuJfVUPV3mvIdJ7X15pek X-Received: by 2002:a05:6a00:3312:b0:6b5:ec98:4289 with SMTP id cq18-20020a056a00331200b006b5ec984289mr5372963pfb.14.1700741693180; Thu, 23 Nov 2023 04:14:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700741693; cv=none; d=google.com; s=arc-20160816; b=ZI82D0xWcQ8D1DuoJutiEDNGLBcyb/pxlJWrD6lndN/awCoDaXgBd8f5PBEQYtrozQ qESWZ9TtXYitxw/PcW+cTrFVQMLXyiisaobQehblnOcns/18YZdasLNoos5EbFSeSXOm xP+wnKQZL35DXFuaavCBAcIA84MOMVGVbRlIE4P23QzGX17qljowxCYax9/0ADInwV1k BbdRQAY6S9LRCv7r89PdLxreBh8b0gZz0u4C3KFEXXOq/WzlTGQvMai6Zy6ldHOFBUQ2 1E4expKSVEL8kMYdsnWSXamP4m8C9Y+eEf1ocepYzLp12eA9lZKtYI7KbPq98OMbEYX8 ti/g== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ofXB44ROz+vW+APgPHP3Mz+f3vPRg/W9qvLE7U3E/b4=; fh=X09nAlJWkl7t6C8YyHaaPOPhxDvv+DRPUWvBF395L5Y=; b=KS3+Db3l/liAmjn29nCrEimbWbpn6nCzEqSAWZJsElt6GZfhPeXklclaBcW7r3BGWq vrbiQVPis4LESn6h0611x0HMfXlpXXENSF6R8vgkdMZdjsRRX4KIbfguv02bZwwd5pg3 zwmAqP7rkTpPMQSJmeEyfLKebCA82aH68dAkZwA9GPWTrUjWpFPZrLXmvjRTgC0boOM7 a5uy0a4yzJaCuBJ4rQa15eyF1t4qdeDLnJNC3dfhcqwq8MxxjHBEeaU0daDTHFsCCNL+ 3S6sAakLhOI2oiHN+p5ZkYnOOVU/GHzbM8HkB2MvCeXR5pUsh/BRLdCWO0sXucHN7Uwe GFUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UlJdv0lX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a7-20020a056a000c8700b006c32b301f74si1143968pfv.39.2023.11.23.04.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 04:14:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UlJdv0lX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 82B3280477B0; Thu, 23 Nov 2023 04:13:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345231AbjKWMM5 (ORCPT + 99 others); Thu, 23 Nov 2023 07:12:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345215AbjKWMM4 (ORCPT ); Thu, 23 Nov 2023 07:12:56 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D3C691 for ; Thu, 23 Nov 2023 04:13:02 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30465C433C7; Thu, 23 Nov 2023 12:13:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700741582; bh=42j8yCIGOIsdbYfWKArHt6YgWjhLYwGUak0TSa8oLCU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UlJdv0lXQ6T1VSpJnR8JE9zxFg2rCDgSn8m0Ep2KHp6YA9n8T4Tzs1xiNMSiYdOD/ sRjRA+4T8cyH5auQADLfeXR+nmphrtH+ZVwkl0yhbBinRdYGvhiQ6X4TrC+Kge1Xmf UiEyAUy5ylyXgPcmIho7+QBePr4SPpzNAbDTpeRM= Date: Thu, 23 Nov 2023 12:12:56 +0000 From: Greg KH To: Masahiro Yamada Cc: Matthew Maurer , Nick Desaulniers , Miguel Ojeda , Gary Guo , Luis Chamberlain , Nathan Chancellor , Nicolas Schier , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org, Laura Abbott Subject: Re: [PATCH v2 0/5] MODVERSIONS + RUST Redux Message-ID: <2023112312-certified-substance-007c@gregkh> References: <20231118025748.2778044-1-mmaurer@google.com> <2023112314-tubby-eligibly-007a@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 23 Nov 2023 04:13:07 -0800 (PST) On Thu, Nov 23, 2023 at 08:38:45PM +0900, Masahiro Yamada wrote: > On Thu, Nov 23, 2023 at 6:05 PM Greg KH wrote: > > > > On Wed, Nov 22, 2023 at 01:04:09PM -0800, Matthew Maurer wrote: > > > > So, even if you enable CONFIG_MODVERSIONS, > > > > nothing is checked for Rust. > > > > Genksyms computes a CRC from "int foo", and > > > > the module subsystem confirms it is a "int" > > > > variable. > > > > > > > > We know this check always succeeds. > > > > > > > > Why is this useful? > > > The reason this is immediately useful is that it allows us to have Rust > > > in use with a kernel where C modules are able to benefit from MODVERSIONS > > > checking. The check would effectively be a no-op for now, as you have correctly > > > determined, but we could refine it to make it more restrictive later. > > > Since the > > > existing C approach errs on the side of "it could work" rather than "it will > > > work", I thought being more permissive was the correct initial solution. > > > > But it's just providing "fake" information to the CRC checker, which > > means that the guarantee of a ABI check is not true at all. > > > > So the ask for the user of "ensure that the ABI checking is correct" is > > being circumvented here, and any change in the rust side can not be > > detected at all. > > > > The kernel is a "whole", either an option works for it, or it doesn't, > > and you are splitting that guarantee here by saying "modversions will > > only work for a portion of the kernel, not the whole thing" which is > > going to cause problems for when people expect it to actually work > > properly. > > > > So, I'd strongly recommend fixing this for the rust code if you wish to > > allow modversions to be enabled at all. > > > > > With regards to future directions that likely won't work for loosening it: > > > Unfortunately, the .rmeta format itself is not stable, so I wouldn't want to > > > teach genksyms to open it up and split out the pieces for specific functions. > > > Extending genksyms to parse Rust would also not solve the situation - > > > layouts are allowed to differ across compiler versions or even (in rare > > > cases) seemingly unrelated code changes. > > > > What do you mean by "layout" here? Yes, the crcs can be different > > across compiler versions and seemingly unrelated code changes (genksyms > > is VERY fragile) but that's ok, that's not what you are checking here. > > You want to know if the rust function signature changes or not from the > > last time you built the code, with the same compiler and options, that's > > all you are verifying. > > > > > Future directions that might work for loosening it: > > > * Generating crcs from debuginfo + compiler + flags > > > * Adding a feature to the rust compiler to dump this information. This > > > is likely to > > > get pushback because Rust's current stance is that there is no ability to load > > > object code built against a different library. > > > > Why not parse the function signature like we do for C? > > > > > Would setting up Rust symbols so that they have a crc built out of .rmeta be > > > sufficient for you to consider this useful? If not, can you help me understand > > > what level of precision would be required? > > > > What exactly does .rmeta have to do with the function signature? That's > > all you care about here. > > > > > rmeta is generated per crate. > > CRC is computed per symbol. > > They have different granularity. > It is weird to refuse a module for incompatibility > of a symbol that it is not using at all. I agree, this should be on a per-symbol basis, so the Rust infrastructure in the kernel needs to be fixed up to support this properly, not just ignored like this patchset does. thanks, greg k-h