Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2749271ybh; Mon, 5 Aug 2019 06:15:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxQ2mA8cIbEXanQgdowBQoeV90O1+W/78TbGzs+43fN13D0qaNQMyu5KkZ1ilZpVX1Slai X-Received: by 2002:a63:ff0c:: with SMTP id k12mr93337524pgi.186.1565010924822; Mon, 05 Aug 2019 06:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565010924; cv=none; d=google.com; s=arc-20160816; b=HeHMKMHFAO5g69hmeKdnQHdOhY3w004Tv8PEPNGTFP1TIaUbixyD33g/5JVV5qB0j0 0Ry7TH+GYtm0rK+X1jcQWkY4MbMaGGk0OlrNppqTkluahm5T3GSueqBICHvE8MFhX+D8 2IV5CvAERO5JREHBVeCq9At1B9dk+7z0dxIKqYlLb3yLRbSQCJ6801hj6moQNYIBPNXq ONV9m9Ugy8M2K/KXnDdxMV2LqQjxPKwRyyFuyNGIozWVfsCuNZkT6Y74SHo9zxk1C+BZ Ztxekkpn7MpofocNxhXepOtUkJKtVBlHN4dle+WvPYaJN3dOi2YZ7aRt2ADPEhdW6FWR J0bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SD9ttZesgCMqmEk2R0IAsTOvhOIDcDiFcMHpY3rLYzw=; b=WTDZUyug9HgQ2dhGe997qQnV+4g7BpoIXngpnvjZ41gm8bV0v/x2hOHQWbZiYctlut ElkJlXebIDM19WsqnaT1XqcmiqLENlYKnCQ6570bUnIga1iIWXzwgCw4QmJJY7mXKLmr GkpyHBwcBItp/9j1Hh1V6KK3waKPQm2iVKckq0X/vLsAVKmcc1pP7l4uGEcFs8ag38iD 8MmM5+cbc/hlvD0hiCX+d5badouwds0YvGfKdx+tobwWNp+k8o8KyCN2b0Odsxb7XjCP auqa6k+ftEDmzS3nIKW5Hrb91Ke5Zs+ZsKH6eEy9GOKqR8Eq8AAiS7zitbrPrah7o/4h UhCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Mg9g/rfU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h36si41317196plb.199.2019.08.05.06.15.08; Mon, 05 Aug 2019 06:15:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Mg9g/rfU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729134AbfHENH4 (ORCPT + 99 others); Mon, 5 Aug 2019 09:07:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:45612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729882AbfHENHw (ORCPT ); Mon, 5 Aug 2019 09:07:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B91492087B; Mon, 5 Aug 2019 13:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010471; bh=agc1PVtAORgXiE6ckLoFTP2zJuRjb4W6lkyVJlTVHyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mg9g/rfUciPkQQi6ayY5sR0hSpZuN65oO6Ssw+Nou+8W4YZFzMRprrHmq4E7OUJ6e GilfSh0CKdRnA+Mi5P+G5AhE97IVtg9aoeoU8U0MdQGekodNSminK0zrjiRiCQOY4e +xf1V/IfgisNEHKL79BT2Bz7cVuEAgTREMrldcR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Prarit Bhargava , Barret Rhoden , David Arcari , Jessica Yu , Heiko Carstens , Sasha Levin Subject: [PATCH 4.14 06/53] kernel/module.c: Only return -EEXIST for modules that have finished loading Date: Mon, 5 Aug 2019 15:02:31 +0200 Message-Id: <20190805124928.729264842@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124927.973499541@linuxfoundation.org> References: <20190805124927.973499541@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6e6de3dee51a439f76eb73c22ae2ffd2c9384712 ] Microsoft HyperV disables the X86_FEATURE_SMCA bit on AMD systems, and linux guests boot with repeated errors: amd64_edac_mod: Unknown symbol amd_unregister_ecc_decoder (err -2) amd64_edac_mod: Unknown symbol amd_register_ecc_decoder (err -2) amd64_edac_mod: Unknown symbol amd_report_gart_errors (err -2) amd64_edac_mod: Unknown symbol amd_unregister_ecc_decoder (err -2) amd64_edac_mod: Unknown symbol amd_register_ecc_decoder (err -2) amd64_edac_mod: Unknown symbol amd_report_gart_errors (err -2) The warnings occur because the module code erroneously returns -EEXIST for modules that have failed to load and are in the process of being removed from the module list. module amd64_edac_mod has a dependency on module edac_mce_amd. Using modules.dep, systemd will load edac_mce_amd for every request of amd64_edac_mod. When the edac_mce_amd module loads, the module has state MODULE_STATE_UNFORMED and once the module load fails and the state becomes MODULE_STATE_GOING. Another request for edac_mce_amd module executes and add_unformed_module() will erroneously return -EEXIST even though the previous instance of edac_mce_amd has MODULE_STATE_GOING. Upon receiving -EEXIST, systemd attempts to load amd64_edac_mod, which fails because of unknown symbols from edac_mce_amd. add_unformed_module() must wait to return for any case other than MODULE_STATE_LIVE to prevent a race between multiple loads of dependent modules. Signed-off-by: Prarit Bhargava Signed-off-by: Barret Rhoden Cc: David Arcari Cc: Jessica Yu Cc: Heiko Carstens Signed-off-by: Jessica Yu Signed-off-by: Sasha Levin --- kernel/module.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 94528b8910278..4b372c14d9a1f 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3391,8 +3391,7 @@ static bool finished_loading(const char *name) sched_annotate_sleep(); mutex_lock(&module_mutex); mod = find_module_all(name, strlen(name), true); - ret = !mod || mod->state == MODULE_STATE_LIVE - || mod->state == MODULE_STATE_GOING; + ret = !mod || mod->state == MODULE_STATE_LIVE; mutex_unlock(&module_mutex); return ret; @@ -3560,8 +3559,7 @@ again: mutex_lock(&module_mutex); old = find_module_all(mod->name, strlen(mod->name), true); if (old != NULL) { - if (old->state == MODULE_STATE_COMING - || old->state == MODULE_STATE_UNFORMED) { + if (old->state != MODULE_STATE_LIVE) { /* Wait in case it fails to load. */ mutex_unlock(&module_mutex); err = wait_event_interruptible(module_wq, -- 2.20.1