Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp64407pxb; Thu, 2 Sep 2021 19:26:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRQULJXYX57G/kEMTwSFtuyZvIkuRHNV0rQMjIoln+E1vAX5c2hkcQWoqIdE3qGgnMC2nl X-Received: by 2002:a17:906:3adb:: with SMTP id z27mr1440165ejd.291.1630635986786; Thu, 02 Sep 2021 19:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630635986; cv=none; d=google.com; s=arc-20160816; b=bRjXqf2J2fLG3uHpLswSBT3d9USwFq6otbnn/wasHHDMzUo7g/0bmcUDCT8R6f8yxQ p5ZXeYXvUm8OvpPxrN/7jz6F6t5CnVq1Ydy/eYZoTW8P0KLon1vqpFBt35UgfsGI6MEw NbzAgnjqseQ5guZ/ooTzC3IAmADaUPHFF61IYP9ziy6eh1hRfH674Nubs07lGtfiMTxk pj2Q/hzIC9cxjCIadBZ7fMECa3NniRzL64ddTNsAenXUryJKdkR6PYEVQy8emowkqZHs YQYPukzysM1skptLsiWzIyfnQ3+BFAHGomsKDjXdrgybsJkyiooFrN6RpjNeAoNWJwfG s2XA== 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=vTTM6Ny6/XWsjFecD4h/kUNJ97pG8222X+imwLamVHk=; b=pbPqjjeixD64aOhFnswTaj+Bfc8hDYuGA6nlDueRWVnSp3zs+bOzDbyKyN65XoYGxN zUMe3dhjb7ZIfQnQc6poWUb7zV9xGKncxxINB7nCGA5e06cYA4xaNEqJeUlA0Tcj/Fb6 S4Y7DNmqmK9+WZFqqcQoDXU9z9iz27zmdgIlrqQdofZ2Q0GI7XjNVtdNiGBgyVDglDIO qfx/b0TcOOIxCpDMFcpJWUIWgP9DX7SbGvTZ4Ru+4oxOcfjTg51RGzwiYrJFb/tRmTfi sQ/098y+JLHwfWjTCo5imgTVDsPMi4epckBMi045tY+uNLIkJsav6gH2yGswuGyclm9E 1jQw== 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 m3si3875657edq.359.2021.09.02.19.26.03; Thu, 02 Sep 2021 19:26:26 -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 S233254AbhICAvG (ORCPT + 99 others); Thu, 2 Sep 2021 20:51:06 -0400 Received: from smtp23.cstnet.cn ([159.226.251.23]:46112 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231577AbhICAvF (ORCPT ); Thu, 2 Sep 2021 20:51:05 -0400 Received: from localhost.localdomain (unknown [124.16.138.128]) by APP-03 (Coremail) with SMTP id rQCowABXeBAlcTFhFZEOAA--.40551S2; Fri, 03 Sep 2021 08:49:41 +0800 (CST) From: Jiang Jiasheng To: bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com Cc: linux-kernel@vger.kernel.org, Jiang Jiasheng Subject: [PATCH 3/3] x86/microcode/amd: Add __list_del_entry_valid() in front of __list_del() in free_cache() Date: Fri, 3 Sep 2021 00:49:40 +0000 Message-Id: <1630630180-644591-1-git-send-email-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: rQCowABXeBAlcTFhFZEOAA--.40551S2 X-Coremail-Antispam: 1UD129KBjvdXoWrZryxtr4UtFWrCrWfJrWkWFg_yoWDtwb_Wa 4rt348ur4fAFy2vwsFyw48GasxZwn5ta95Kryxta4rt343KFs8Aa12ga1YgFy3WrZYqFZ5 Arn5CF4UGas3ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbckFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr 0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVAFwVWD MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV W8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JU3DG5UUUUU= X-Originating-IP: [124.16.138.128] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: 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: Jiang Jiasheng --- 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