Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p7tya-0005Wl-NF for mharc-grub-devel@gnu.org; Wed, 21 Dec 2022 02:57:20 -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 1p7tyY-0005Vt-O3 for grub-devel@gnu.org; Wed, 21 Dec 2022 02:57:18 -0500 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7tyW-0006ay-6A for grub-devel@gnu.org; Wed, 21 Dec 2022 02:57:18 -0500 Received: by mail-pf1-x42e.google.com with SMTP id 124so10179498pfy.0 for ; Tue, 20 Dec 2022 23:57:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:cc:content-language :references:to:subject:from:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=MWRpYJmbwhUfLitTnXJlzbCPso9ydGgbMvBB33kieE0=; b=K/8lUou7ybQmncsjZMWMMNEk7jG/USGzUVvBCMt4AEKDIJ981cDwYLTfSWRENAhTMI i390dk6EeEnJ7UXBqiI2Tlr2cqu29Ra1yleXSz8ZgBP+3MFMA1sqyRX4rZvjoiOpor+7 Jz8xNpSlXnaVPZWHzp24dcXxhUss8/K745wEsHDzEv4Mlf+3H1X/bxAyDg2r0kQHA75D RNjPF33ari5AdFME6KpK2aOd7Ccsas5cAnODyln4CNYNWqQ9as1A4BkT8sboBqvybVrC YKTie+h0YTUpM7EeZ9h9ZzmERy7nAsh5MkbG4o5HCdcHw/iLYXmILd4KvY7+I3oDMtSn zW1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:content-language :references:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MWRpYJmbwhUfLitTnXJlzbCPso9ydGgbMvBB33kieE0=; b=iij7Pmdx8Qimw4AFJk9IGH6CWO7DmCB9D3NhHaA+Q5ANKRZmfM/EK8HaJrxT3d6m3G GKX/uJNMvDzWDjOQ4uMDX7VSvwEHPOAH8Hu+wZTmqlmXgVG8FyXBNnRpW/bh0eT8tgAO x8lB5Rn/ES2AHbu/QmOWM0lQ30rY1wmHRISIp/N8IEt4+JRMbJgbUIBloaR2cL8C1k4E 3R7uhNMemW0Jh7qlGBtkdwnXqL81cAnliWor4vAIbzEK3uVBz8MDuECCxn3iwNJ4lcrN i/tAFK9g5uT7G1klX4/pZ2QjMA15U7gvcpnzs4vbun1n5NaTQi4lsC74xYGTbGqsneqH Be2A== X-Gm-Message-State: AFqh2kpaZu3ZYwptHY+f8YYV2MJf3so7S7uE3s4BQ3/BMNlBqAYjMCTP qfvxWKqwmdDJgf0HUj4rljs= X-Google-Smtp-Source: AMrXdXuhp64y0nIIHxMXRlXyE37OBaIOKRqweazcuqClak0Q+5qYSGtXyvbazbVpohDFChH9xF+0cQ== X-Received: by 2002:a05:6a00:26ee:b0:578:777e:7f18 with SMTP id p46-20020a056a0026ee00b00578777e7f18mr636101pfw.3.1671609433170; Tue, 20 Dec 2022 23:57:13 -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 v126-20020a626184000000b005764c8f8f07sm9857076pfb.84.2022.12.20.23.57.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Dec 2022 23:57:12 -0800 (PST) Message-ID: <3326fa35-0c2a-2a71-c191-a1195b52f550@gmail.com> Date: Wed, 21 Dec 2022 15:57:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 From: Zhang Boyang Subject: Re: [RFC PATCH] kern/dl: Add module version check To: Robbie Harwood References: <20221219153329.154238-1-zhangboyang.id@gmail.com> Content-Language: en-US Cc: The development of GNU GRUB , Glenn Washburn , Daniel Kiper , Pete Batard In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=zhangboyang.id@gmail.com; helo=mail-pf1-x42e.google.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 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, NICE_REPLY_A=-1.161, 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: Wed, 21 Dec 2022 07:57:19 -0000 Hi, (sorry for duplicate emails because I forgot to add CCs) On 2022/12/21 06:58, Robbie Harwood wrote: > Zhang Boyang writes: > >> This patch add version information to GRUB modules. Specifically, >> PACKAGE_VERSION is embedded as null-terminated string in .modver >> section. This string is checked at module loading time. That module will >> be rejected if mismatch is found. This will prevent loading modules from >> different versions of GRUB. >> >> It should be pointed out that the version string is only consisted of >> PACKAGE_VERSION. Any difference not reflected in PACKAGE_VERSION is not >> noticed by version check (e.g. configure options). > > Right now, this only affects non-secureboot scenarios (because we don't > have external signed module support). I would want to see a resolution > to the external module signing question first so that we don't paint > ourselves into a corner with something like this. > This feature is a prerequisite for external signed module support (and it is mainly designed for this purpose). SBAT itself is not sufficient to protect version mismatch attacks. 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 4) So 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, there is possibility that there are vulnerabilities when using GRUB 2.YY modules with GRUB 2.XX. > I share Glenn's confusion about what real-world problems this addresses: > my understanding is that grub modules mostly register callbacks, so the > possibility of disaster is low (unless the callback interfaces change of > course, but that generally has not happened). > Please see my reply to Glenn for a example that mismatched modules crashes GRUB. > The combination of those two things leads me to suspect this is not the > right approach. It seems likely that if we want to down the road of > versionlocking, something like the kernel's ephemeral key approach would > be better suited - and if we want external modules (which I don't think > we do), full SBAT support. > Sorry but I'm not familiar with the kernel's ephemeral key approach. Could you please give me some links to this? By the way, I figured out why shim doesn't enforce SBAT checks for files if they are not directly loaded by shim AND have no SBAT information. According to https://github.com/rhboot/shim/commit/a2da05fcb8972628bec08e4adfc13abbafc319ad , it's vendor's responsibility to revoke all files without SBAT information and only sign files with SBAT information at all time. My grub-wrap patch (https://lists.gnu.org/archive/html/grub-devel/2022-12/msg00070.html ) already has support for embedding SBAT information to PE wrappers, although it not enforced. With this patch, it should be easy to implement external modules if wanted (yes, with full SBAT support, if vendor always add SBAT information to modules). Best Regards, Zhang Boyang > Be well, > --Robbie