Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mdDNh-0003lz-6J for mharc-grub-devel@gnu.org; Wed, 20 Oct 2021 11:19:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdDNa-0003iw-Nx for grub-devel@gnu.org; Wed, 20 Oct 2021 11:19:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdDNZ-0004fN-1g for grub-devel@gnu.org; Wed, 20 Oct 2021 11:19:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634743184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pDcxvLligytiLuKQqBqnIAfundIzTU5KZEaVLhpp2OM=; b=jF8mxkAf4k1s6xM0wJkWpt+WQOTEn/duG0KcCiFqk50hz/ix7zQGkgidOKEcdLQzXWNAlX sKZ7v5n9xnSVzTvW1CARthvcEOooguXTZdtW8t3WafO8NqT6I6r8DtLEB2hEeNsFM/4TbF Bdt6wEzNeQERZ7IwnKPIpHyvItpdIdc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-9MZJV7ixOs6fRc2dW5DToQ-1; Wed, 20 Oct 2021 11:19:43 -0400 X-MC-Unique: 9MZJV7ixOs6fRc2dW5DToQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D8421054FB0 for ; Wed, 20 Oct 2021 15:19:42 +0000 (UTC) Received: from eesha.redhat.com (ovpn-0-4.rdu2.redhat.com [10.22.0.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7447910016FC; Wed, 20 Oct 2021 15:19:41 +0000 (UTC) From: Robbie Harwood To: grub-devel@gnu.org Cc: Robbie Harwood Subject: [PATCH v2] Print module name on license check failure Date: Wed, 20 Oct 2021 11:19:13 -0400 Message-Id: <20211020151912.6779-1-rharwood@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=rharwood@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Received-SPF: pass client-ip=170.10.133.124; envelope-from=rharwood@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Oct 2021 15:19:48 -0000 Before performing the license check, resolve the module name so that it can be printed if the license check fails. Prior to this change, grub would only indicate that the check had been failed, but not by what module. This made it difficult to track down either the problem module, or debug the false positive further. Signed-off-by: Robbie Harwood --- grub-core/kern/dl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 48f8a7907..90e83e4d4 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -457,14 +457,16 @@ grub_dl_find_section (Elf_Ehdr *e, const char *name) Be sure to understand your license obligations. */ static grub_err_t -grub_dl_check_license (Elf_Ehdr *e) +grub_dl_check_license (grub_dl_t mod, Elf_Ehdr *e) { Elf_Shdr *s = grub_dl_find_section (e, ".module_license"); if (s && (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0 || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0 || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0)) return GRUB_ERR_NONE; - return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license"); + return grub_error (GRUB_ERR_BAD_MODULE, + "incompatible license in module %s: %s", mod->name, + (char *) e + s->sh_offset); } static grub_err_t @@ -641,8 +643,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) constitutes linking) and GRUB core being licensed under GPLv3+. Be sure to understand your license obligations. */ - if (grub_dl_check_license (e) - || grub_dl_resolve_name (mod, e) + if (grub_dl_resolve_name (mod, e) + || grub_dl_check_license (mod, e) || grub_dl_resolve_dependencies (mod, e) || grub_dl_load_segments (mod, e) || grub_dl_resolve_symbols (mod, e) -- 2.33.0