Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p8Oad-0007BJ-5t for mharc-grub-devel@gnu.org; Thu, 22 Dec 2022 11:38:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p8Oac-0007BB-0x for grub-devel@gnu.org; Thu, 22 Dec 2022 11:38:38 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p8Oaa-0005Az-2n for grub-devel@gnu.org; Thu, 22 Dec 2022 11:38:37 -0500 Received: by mail-pg1-x535.google.com with SMTP id 7so1683385pga.1 for ; Thu, 22 Dec 2022 08:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=TS8Ljm/hw51YphsNQdqSdlWri4H8r5PwFgAZS8QRAbk=; b=So0kTt857DzltjJV8WKW8ZQFzsFoXFTbTHyg7pCSGfebAM3y9OhErr/kfHr0XCZUvF kp7dSH3RRuX/kY78MSYt/Qlrg9Dh9hzEQ6fdDhjdVdd1nN4TcwHoUHd7QKvdby4S7FeA 224XwVYKRDq75E9PcOPynjUPCAFGud1xEXL/3dY/DznFigkr/W7I8Vl+uq04kgaWlHlZ htUG/sTyw5uJMT6MZzMGcaawSQw9UrAvcFSiSoAC3ZN5lriWzfu9w6+GVoC33/PGGX2S tM7I0FqivtLZnM193LwlVL+UnXGPXy7bPiMS/HfNfUOYNI0I3jHTNG8Q4mTgsuL0VAbY JUog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=TS8Ljm/hw51YphsNQdqSdlWri4H8r5PwFgAZS8QRAbk=; b=M2YtQR1MF1wKjuchF9LXGgfZ6JTBfsli2c5wRklIgqVi0l64Fr7yNfspz7tO/GqMSv 4twUA8qwQlS+yJ/r0nH3XyNipKvvpfQ3a2HFQM6wSbPSsYUeun2FT46w5Ka5jMD4k7TO +j6NP3l4UwdkB0hMnD+pShlp6hVBTWDAc8lJ9s0izuBbxMP4avA8kRzirVP+WubMT3NA Geq8bijFwLMxM5o4c9z9zH7P/z00AOQNp9jH+ojqNeeU0QNQZ5etwXkl1WbPbrHSJXxw 9zngQgz5QgdzqFc2z/SpBK6w3VeWNF65b//RZLrodNJmtOg846Mwy4hKAyTNlcYpqudy B6zA== X-Gm-Message-State: AFqh2krB/anpAiK5my8unQpdmLw/4uJWAPGq9qSFH5w7hJJfyYgUGTcf tD+asVtapdh7KnpWPY5FhXeBDqy8tZLV7g== X-Google-Smtp-Source: AMrXdXva1fjx5jhBFYCgalMNM2ODQKF4QTSDe8n8y+gbPvtxQJqxkeGxDGuRB402N2QfKAEoRLBgPw== X-Received: by 2002:aa7:8f38:0:b0:577:fdb8:e5fd with SMTP id y24-20020aa78f38000000b00577fdb8e5fdmr6948766pfr.2.1671727114329; Thu, 22 Dec 2022 08:38:34 -0800 (PST) Received: from [0.0.0.0] (ec2-13-113-80-70.ap-northeast-1.compute.amazonaws.com. [13.113.80.70]) by smtp.gmail.com with ESMTPSA id a22-20020a621a16000000b00576b0893ecasm955952pfa.46.2022.12.22.08.38.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Dec 2022 08:38:33 -0800 (PST) Message-ID: <7c0fa62f-89eb-cfb5-8e99-bd9661ef6912@gmail.com> Date: Fri, 23 Dec 2022 00:38:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Content-Language: en-US To: grub-devel@gnu.org Cc: development@efficientek.com, rharwood@redhat.com, pete@akeo.ie, scdbackup@gmx.net, didier@slint.fr, dkiper@net-space.pl From: Zhang Boyang Subject: [RFC PATCH v3 0/1] kern/dl: Add module version check Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=zhangboyang.id@gmail.com; helo=mail-pg1-x535.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Dec 2022 16:38:38 -0000 Hi, This is the V3 of my patch. V2 is at: https://lists.gnu.org/archive/html/grub-devel/2022-12/msg00234.html V1 is at: https://lists.gnu.org/archive/html/grub-devel/2022-12/msg00213.html [ TD;LR ] 1) The check is always enforced when GRUB is locked down, i.e. modules will be refused to load if they have mismatched version 2) If built with "--disable-modver-check", modules can always be loaded even if they have mismatched version, and no message will be displayed. 3) If built with "--enable-modver-check=audit", modules can always be loaded even if they have mismatched version, but if mismatch is found, a warning message will be displayed. This is the default. 4) If built with "--enable-modver-check=enforce", the behavior is same as 1) [ Why this patch is useful, even for BIOS boot ] Because it helps people diagnose broken (or improper) GRUB installations. For example, if you google "452: out of range pointer", you will got a lot of results in 2022. I think the most of them are related to mismatched modules. However, these problem are often not properly diagnosed because they disappear magically, e.g. update whole system (which triggers grub reinstall). There are several people even suspect there are problems with their hard disk / BIOS. However, the root cause is 052e6068be62 ("mm: When adding a region, merge with region after as well as before") changed the layout of `struct grub_mm_region`, which is both used in main program and "relocator.mod", so the module reads the wrong field and crashes GRUB. Please the commit did nothing wrong because there is no API/ABI compatibility guarantees in GRUB. If there are warning messages about mismatched modules, user will easily notice there are problems with their GRUB installation. [ Why not enforce this check to prevent crashes ] As Glenn & Pete said, most mismatched modules isn't harmful. At most times, GRUB with mismatched modules can boot Linux happily, even if these modules come from another Linux distribution. This enables user to fix his/her GRUB installation without using a boot/rescue disk, because the user can boot the existing Linux using the existing (but improperly installed) GRUB. [ Why warning can be disabled ] Some tools like Rufus relies on mismatched modules. Some advanced users also doesn't like redundant warnings for their existing known-to-work configurations. However, it's highly unrecommended to disable this warning. [ Why this patch is a prerequisite for external signed module support ] Consider this scenario: 1) GRUB 2.XX is free of vulnerabilities 2) GRUB 2.YY is also free of vulnerabilities 3) So GRUB 2.XX shares same SBAT numbers with GRUB 2.YY, therefore SBAT can't help in version check 4) If there is no version check, it's possible to load GRUB 2.YY modules into GRUB 2.XX (and vice versa) 5) However, due to some changes in API or ABI, although unlikely, there is possibility that there are vulnerabilities when using GRUB 2.YY modules with GRUB 2.XX (and vice versa) 6) So we must enforce version check to prevent this from happening However, because version string is only consisted of PACKAGE_VERSION, it must be unique for one given vendor (signer). For example, version string need to be different for Debian 10 and Debian 11 even they both use GRUB 2.06, and no two build in Debian 10 (or Debian 11) have same version string. Best Regards, Zhang Boyang