Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lRF2U-0000kV-Ue for mharc-grub-devel@gnu.org; Tue, 30 Mar 2021 10:08:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRF2S-0000fq-TU for grub-devel@gnu.org; Tue, 30 Mar 2021 10:08:12 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:41475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRF2Q-0004Jr-CW for grub-devel@gnu.org; Tue, 30 Mar 2021 10:08:12 -0400 Received: by mail-pg1-x52c.google.com with SMTP id m7so11791602pgj.8 for ; Tue, 30 Mar 2021 07:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V6zLMP94lRQ4y6j+YfMSz/Wnq9S72xNomZu0BVq3q3k=; b=NO0bsFSnSU0Sfj6s4qKNLnTCNjDbwJfqgoWfRm+clsbj22OUvWikmHPKGp/TxBwKAP oXzd4m9FnJbMb5yq2onRX8LoYjQnif3lQmRhgw9DGlz/muKUrqckRVzf4etg5WB01/yB kcJdmPwMM+zJ5AKieM2DBojuTqqhpLR3srrLM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V6zLMP94lRQ4y6j+YfMSz/Wnq9S72xNomZu0BVq3q3k=; b=jJUj8BwTjl5BR3wgzi3jSQv+83SEZQZOQGhqYjaLVKlzZCts40/Ste7AbYU+UI2JWg n9sliLTNvXBP7T/RJt1bSYl8dC26LTCnkkumUKdTIL6KrLiaBGrykLq5zgdZ7VaKuGNV hAGTBIJyLHrznJ/iwQMBwK0mM0LmEzNLr/qFr1e36QIvmB4T7h7EWB4rfNLLA7wjvcPc V0gjZYNFFbp22fF7M2a5FzeXDCo2G+la+mZdsqXG9LOFr5/ZD7v7mse+L+dOpKWJpyqi GOv89nZijp3ZAXcEvh055/I0CZ0twSDmLDFdQgDzN7AwyroUDrR120mFfHlgH1NMIWbZ FWew== X-Gm-Message-State: AOAM532bxukAwYMwlUIA+g33QdzysW3XGZrCYayA/FyD+FGlAZZd94Wh GkYmtd+P4Yt9ETH+jPR/HdqVkT4vUXVlgw== X-Google-Smtp-Source: ABdhPJwgR8KxfEnaYC5GFIIFIlR1iZN/+9UWf4I3HaD5prIDbw38FHKR/uXkknASLcnWL5us9pQqjw== X-Received: by 2002:a62:1913:0:b029:20f:eadf:28c1 with SMTP id 19-20020a6219130000b029020feadf28c1mr29815503pfz.58.1617113288677; Tue, 30 Mar 2021 07:08:08 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-cc4e-3d4e-f51c-bb52.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:cc4e:3d4e:f51c:bb52]) by smtp.gmail.com with ESMTPSA id c2sm20600253pfb.121.2021.03.30.07.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:08:08 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: rashmica.g@gmail.com, alastair@d-silva.org, Daniel Axtens Subject: [PATCH 04/19] dl: provide a fake grub_dl_set_persistent for the emu target Date: Wed, 31 Mar 2021 01:07:29 +1100 Message-Id: <20210330140744.176698-5-dja@axtens.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210330140744.176698-1-dja@axtens.net> References: <20210330140744.176698-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=dja@axtens.net; helo=mail-pg1-x52c.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, 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.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2021 14:08:13 -0000 Trying to start grub-emu with a module that calls grub_dl_set_persistent will crash because grub-emu fakes modules and passes NULL to the module init function. Provide an empty function for the emu case. Fixes: ee7808e2197c (dl: Add support for persistent modules) Signed-off-by: Daniel Axtens --- include/grub/dl.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/grub/dl.h b/include/grub/dl.h index b3753c9ca262..5decbe2f2fb9 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -243,11 +243,22 @@ grub_dl_get (const char *name) return 0; } +#ifdef GRUB_MACHINE_EMU +/* + * Under grub-emu, modules are faked and NULL is passed to GRUB_MOD_INIT. + * So we fake this out to avoid a NULL deref. + */ +static inline void +grub_dl_set_persistent (grub_dl_t mod __attribute__((unused))) +{ +} +#else static inline void grub_dl_set_persistent (grub_dl_t mod) { mod->persistent = 1; } +#endif static inline int grub_dl_is_persistent (grub_dl_t mod) -- 2.27.0