Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1707255pxb; Mon, 13 Sep 2021 03:50:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy2jZOvxB8ZK8jgtOODOqDWYgHLXygIQUWIcG4L1ppcFk9ZPmzsl+P8SRRMkR22paYjtsI X-Received: by 2002:aa7:cb0f:: with SMTP id s15mr12559862edt.190.1631530204147; Mon, 13 Sep 2021 03:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631530204; cv=none; d=google.com; s=arc-20160816; b=QYjvSFyljc+5TEB0UbHPMXzlQHnU8/Q8sW8Vt1HtBia04X7gEONbi9lxjNnPEd3D2l cHyfXNNsz+pl4vIdfHwqOhjiSn7eiNa9xq4+PTKhuAvnF8rog5yRNoMG0ZWgl1viYzdo dxqsOqXfFTB7tBdZLKz6DHJQsB2wOVYlgcx9n6ziQOYEhAYPL2HJggtXLu56uUXKW1U5 DXaNBssHEd/IdDvgTX44TEPXdD/72HiX4NAx4tNx0EMq8Ji5E6WdZrBLm6UeYbo8zasg 3gHSZFl1jkVhfE4G11qzRecxeB9FdSpz7CrXdFTyYIr0rLSWMarDRbBKR06ddXjMGw4L OY/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=lQbpLezxoQsaWRbU/r+U+Zx93ZOdUDgjTFRdnk1KRAw=; b=h3GpcvPJX0Kzi/gSiKky96ejKGVXxfCfwb8M+3mR8g00qqAIE7W3O9zUENxEnEvEAx HQfmJiijLadFbIKJ+kUFrwsaKqY+j5S++eA0WlcrDK1lLhZPbXmeWPbzx8fTLl/5J/Qd kjCOGvRUfyjXAtCap6MREKA1swW3RlwSRozS/jVpJomoJr7+mRq+1HTlPaBQPYY/eeie YJ4flv5LtCKUDBVJu8r9aIWvdsGKF53ugTMnCRE5lucfe7WLmVGc56mTYQ9b5/af2pD4 Ci1XfB+LI1lMLmF0BI1eOo9z10EBjgtHnkIHypwLjrSGS7TkCUOrSBecJYbmhxPTRszr C1Sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l4si9947860edj.282.2021.09.13.03.49.40; Mon, 13 Sep 2021 03:50:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238798AbhIMJqT (ORCPT + 99 others); Mon, 13 Sep 2021 05:46:19 -0400 Received: from smtp21.cstnet.cn ([159.226.251.21]:53790 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238757AbhIMJqS (ORCPT ); Mon, 13 Sep 2021 05:46:18 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-01 (Coremail) with SMTP id qwCowAA3PyuDHT9hqz9gAA--.49159S2; Mon, 13 Sep 2021 17:44:35 +0800 (CST) From: Jiasheng Jiang To: bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com Cc: linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH 3/6 RESEND] x86/microcode/amd: Potentially delete invalid pointer Date: Mon, 13 Sep 2021 09:44:33 +0000 Message-Id: <1631526273-2257451-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: qwCowAA3PyuDHT9hqz9gAA--.49159S2 X-Coremail-Antispam: 1UD129KBjvdXoWrZryxtr4UtFWrCrWfJrWkWFg_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: X-Mailing-List: linux-kernel@vger.kernel.org Directly use __list_del() to remove 'p->plist' might be unsafe, as we can see from the __list_del_entry_valid() of 'lib/list_debug.c' that p->plist->prev or p->plist->next may be the LIST_POISON, or p->list is not a valid double list. In that case, __list_del() will be corruption. Therefore, we suggest that __list_del_entry_valid() should be added in front of the __list_del() in free_cache. Signed-off-by: Jiasheng Jiang --- arch/x86/kernel/cpu/microcode/amd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 3d4a483..e589cff 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -626,6 +626,8 @@ static void free_cache(void) struct ucode_patch *p, *tmp; list_for_each_entry_safe(p, tmp, µcode_cache, plist) { + if (!__list_del_entry_valid(&p->plist)) + continue; __list_del(p->plist.prev, p->plist.next); kfree(p->data); kfree(p); -- 2.7.4