From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kXait-0000Wo-Ha for mharc-grub-devel@gnu.org; Tue, 27 Oct 2020 21:58:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXaip-0000Vg-MA for grub-devel@gnu.org; Tue, 27 Oct 2020 21:57:55 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:46201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXain-0007mr-HA for grub-devel@gnu.org; Tue, 27 Oct 2020 21:57:55 -0400 Received: by mail-pl1-x641.google.com with SMTP id x10so1703798plm.13 for ; Tue, 27 Oct 2020 18:57:52 -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=bfbKzpUClBkqKZ7iuGQ+oEtP/Ocy6l9/5bTaEGDY4mQ=; b=q2jMWnFi9lX7fTYCcGKp2xJa45mZKMR6NSjTOXoLLmXkhRRIz2Frge0OOtnhYGYzWs nmPiNVrhZXNzuNm1Tx28NL374n4UTbv07LnlaihhPRvrWch4d8rpMsZ7DFKdmiXA+SWy HpxAF3qNffCFtEOwc0CzmuWgnTuMGgWjSv/Pg= 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=bfbKzpUClBkqKZ7iuGQ+oEtP/Ocy6l9/5bTaEGDY4mQ=; b=MxIgt6vQ4Nn8XfkWLG/l3eDFCjZoFnLM2MesVtr+GZ7yitYH2V6bsN+93UczEEXkRE NV4iPMFeVrOYZ6zz8PTXrS+lIGrJFJu1jxUuEByywfjzdIB87lOqPeOdUcYTwmFfVkf5 TTjdWkTo9puSJH0x87t7JOYLGBhpNqm1UMrBlmyjblzP8e5kstO2FCKfm3n5JfmJGrVa DuYHdvLgga/IengXqzwqmUyoxTM6fcfDWdrNZcAlkLZznL+fUymrGGiyLPHEqmF8Tt8C tskecnP+J4vUER38vVf0d6A+WusX5sR2ZlnYDcCoSFugBPac5R+ZvFwDAj7l9Q3fg81c f3DQ== X-Gm-Message-State: AOAM533ZyOJt2EV7iue2kwue3pBw9K1wJs0K7uclG2+bTI6u8ll8TkmQ +7+Bl24Exj7GeMM32+DClalfO+aVFjsxFA== X-Google-Smtp-Source: ABdhPJwLjrFiQNjKxIb2gWkEcX5MEUPZ+5TOCV8Ad3vzGvqhJufh9wr3X/i3okD0s5JrVCHUe8dd3Q== X-Received: by 2002:a17:902:76cc:b029:d6:6007:9372 with SMTP id j12-20020a17090276ccb02900d660079372mr4961751plt.50.1603850271554; Tue, 27 Oct 2020 18:57:51 -0700 (PDT) Received: from localhost (2001-44b8-1113-6700-b4f7-e8d4-abaa-2197.static.ipv6.internode.on.net. [2001:44b8:1113:6700:b4f7:e8d4:abaa:2197]) by smtp.gmail.com with ESMTPSA id g67sm3880712pfb.9.2020.10.27.18.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 18:57:51 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: rashmica.g@gmail.com, alastair@d-silva.org, Daniel Axtens Subject: [PATCH v2 03/18] dl: provide a fake grub_dl_set_persistent for the emu target Date: Wed, 28 Oct 2020 12:57:20 +1100 Message-Id: <20201028015735.1131291-4-dja@axtens.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201028015735.1131291-1-dja@axtens.net> References: <20201028015735.1131291-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=dja@axtens.net; helo=mail-pl1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: Wed, 28 Oct 2020 01:57:55 -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 f03c03561a15..941e68abe63b 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -241,11 +241,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.25.1