Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kODOH-0003NC-DP for mharc-grub-devel@gnu.org; Fri, 02 Oct 2020 01:13:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kODOD-0003Jv-9n for grub-devel@gnu.org; Fri, 02 Oct 2020 01:13:53 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:53777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kODO5-00055X-P0 for grub-devel@gnu.org; Fri, 02 Oct 2020 01:13:53 -0400 Received: by mail-pj1-x1042.google.com with SMTP id t7so151398pjd.3 for ; Thu, 01 Oct 2020 22:13:43 -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=HisVQ1Jm6f+gc8mZOYGeq7pG/UxuVt0MHlHUqRFzH94Dv8qd2KY9gxoAtMTRM6qeoP +Nw9hXYt+lkkXxbzTd/PdyRroIbwqCBM/oVKMzYh00FGbDCzDyiz8ZqR0sjlHAJcG9BK m/d1etx2n6SEKk6QD9aU96rWV1wBU9FldbSBU= 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=Ly06DQcadEdxaidGgpEmUn4CDxEeQ5OfTPejKXz1Q0hJhYU+jNbl0TUUVWXeJEhI2F Mb0RwuQA1sc4o6nfY4nXEsurr6P1RoN9hu66/CmTphk2sP0qtlsPbPeo810ia77yuY1o kas/zxpQyJ/KW2z+0rdbUf/u9uCMey2wDb5yHSNh6rjTvNEsFleZhSRJCrzqLNFK6/VD AjprjKAKQFqdomTlz5wxJP2Nn53OyrbQREoFrVo5B1eITzeVxfTvFNXk9fTWif9qWAY8 R2R+UpR4l2i7aGlebd5SzLeId/BMLwsa8len50h8kD8pAl3lD/RHKW5YsBuE+VafnWhu Mv4Q== X-Gm-Message-State: AOAM530miiwFoEATnQt3d5hG88jlqcXN19Rm7RsFEEKJlkbB0D5mBV7g uqJsTSB40nU8t6l1ywk6V0wizqeRcf0Jiw== X-Google-Smtp-Source: ABdhPJznSFQYNB2gEo0FWYIFyiShf00SBgXDRN1lYcVi5cbU6qDpxZO2StOviflFdJZyVFCWsKbk8g== X-Received: by 2002:a17:90b:11c4:: with SMTP id gv4mr895319pjb.136.1601615622133; Thu, 01 Oct 2020 22:13:42 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-804e-30c2-4157-6268.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:804e:30c2:4157:6268]) by smtp.gmail.com with ESMTPSA id y3sm386801pfb.18.2020.10.01.22.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 22:13:41 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: rashmica.g@gmail.com, alastair@d-silva.org, Daniel Axtens Subject: [PATCH 03/18] dl: provide a fake grub_dl_set_persistent for the emu target Date: Fri, 2 Oct 2020 15:13:06 +1000 Message-Id: <20201002051321.1538488-4-dja@axtens.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002051321.1538488-1-dja@axtens.net> References: <20201002051321.1538488-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=dja@axtens.net; helo=mail-pj1-x1042.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: Fri, 02 Oct 2020 05:13:53 -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