Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mb5RY-0007yg-Kn for mharc-grub-devel@gnu.org; Thu, 14 Oct 2021 14:27:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mb5RR-0007yM-Vz for grub-devel@gnu.org; Thu, 14 Oct 2021 14:26:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mb5RP-0002mF-17 for grub-devel@gnu.org; Thu, 14 Oct 2021 14:26:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634236012; 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=xQW6h2pwNi54WtRnXRNDjM8V83DgsRF2Uz1t0aCyt0g=; b=C4qJ/xb+C8ZBeXBQDrvSbzkw4eG9ssg1XQ+VbCzg9+8tPEQ8TkoIY6AVmd7c4obXIP45Bz k5Xdb2RijJbckivZDPp5/kzLocNWI2jI5g9lHfnWDRz0zAA3bJfdAxJT8QYE31fRDG2uUZ J2O5jZyEffT/Tp82PqC7TTwtONcNFeI= 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-238-voQrjCwVMI2YSE8N80mQkQ-1; Thu, 14 Oct 2021 14:26:51 -0400 X-MC-Unique: voQrjCwVMI2YSE8N80mQkQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA5CF8015C7 for ; Thu, 14 Oct 2021 18:26:50 +0000 (UTC) Received: from eesha.redhat.com (ovpn-0-14.rdu2.redhat.com [10.22.0.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AE3A60CC4; Thu, 14 Oct 2021 18:26:45 +0000 (UTC) From: Robbie Harwood To: grub-devel@gnu.org Cc: Robbie Harwood Subject: [PATCH] Print module name on license check failure Date: Thu, 14 Oct 2021 14:26:35 -0400 Message-Id: <20211014182635.26156-1-rharwood@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, 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: Thu, 14 Oct 2021 18:27:01 -0000 At the very least, this will make it easier to track down the problem module - or, if something else has gone wrong, provide more information for debugging. 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