Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4707159pxb; Tue, 28 Sep 2021 02:09:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3moZpAxABYKRFEgc4OOl+s/6e8wEbo2CXjuVt1ojEs8wZYGp/KbEXZOY5C6TVcG7ugVUO X-Received: by 2002:a50:8285:: with SMTP id 5mr4774019edg.318.1632820158234; Tue, 28 Sep 2021 02:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632820158; cv=none; d=google.com; s=arc-20160816; b=0TC2tNsD+kdElT6TxVUtUso4QK+ZaepirzoSO0aWLjq23hpSInJeg/CF6F85QdLd2M XzXHjHmFbY3DeFXhZENqelqRnR/YO/NR2Lvou+0PzyGVr+kAl+8rjbY9NW2mpESjupUj rm4M5tZ8v19almzXKPglDxdsUR9uX0PE2nN5S0a+jmbL3q7OZCehMveYIKtzD7ak3QI2 MZ0fOfdLrrQaj1IhPei56e5o8NDKVIcdrBh/8qouBXGpPyNUvSzMlbIKe/Vl5lMGyc5m YdPmS05hezVoSt7cdntvjwT6wZ7ZLWPH28XH7WNvZWdY6bj31GT9q9iCHXVnwCGwRc/D 15EA== 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=GroDcLWEph7GiSyWmeWJgUf/d7wJQ0+N/he0RITzt0k=; b=JQp9q+RDjRR7c3ZF8A4oulo+q/byzJNfai1/H+TAAMx9dHx9wmrK+au22PZnWK6MWM nDuCaQYlUG9BjhXr+Pjj+FzKO8eCB+zhGC4fx/+NgbIkvC9umwR/BZ34Qb//H8Qx/Axb d4Wd/Fw1IiCckNcNVFbqfvkzrR6kwpCeCRfe0UlVqoIqTUy1LmwAgJ/iUf28iwYePnAs ML0VXg1WAIcmV/8EbRXuRBCTPpblW2uhlf9zjslgG2nnqxrbW7GA7wyxT5zNPBZk3av6 dSLDikCE0s6D0rDRmqEoj8948jyit7v3MdyhuwlzEVrs1hqEtFMedgnttxn17lWIHkJF bZ9A== 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 f29si21280914ejj.403.2021.09.28.02.08.52; Tue, 28 Sep 2021 02:09:18 -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 S239830AbhI1JG4 (ORCPT + 99 others); Tue, 28 Sep 2021 05:06:56 -0400 Received: from smtp21.cstnet.cn ([159.226.251.21]:54592 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239774AbhI1JGz (ORCPT ); Tue, 28 Sep 2021 05:06:55 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-01 (Coremail) with SMTP id qwCowAA3PQmu2lJhUhakAQ--.14119S2; Tue, 28 Sep 2021 17:04:46 +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] x86/microcode/amd: Add __list_del_entry_valid() in front of __list_del() in free_cache() Date: Tue, 28 Sep 2021 09:04:44 +0000 Message-Id: <1632819884-800736-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: qwCowAA3PQmu2lJhUhakAQ--.14119S2 X-Coremail-Antispam: 1UD129KBjvdXoWrZryxtr4UtFWrCrWfJrWkWFg_yoWkAr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ux-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. Fixes: bad5fa6 ("x86, microcode: Move to a proper location") 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