Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6143797iog; Thu, 23 Jun 2022 12:15:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tzfq9PHJ8N3KevvCo/y50/U84dAJ3NSbGNwdej1pmlFJfYEK+KwfcoockRbxnta2Gp8Gz/ X-Received: by 2002:a65:4848:0:b0:3fc:52c3:6ca5 with SMTP id i8-20020a654848000000b003fc52c36ca5mr8545970pgs.264.1656011715067; Thu, 23 Jun 2022 12:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011715; cv=none; d=google.com; s=arc-20160816; b=GVBxRONVy9+802hoEHxsOQaaG8jz33+xmBcyqdr5IQdt9wv3mqqh/4c4r4LuaeSYP5 y+IO0jNGcjnTEBFctKSZauncAOQQXkCp0kVv18udVhSQ8kU55oG/xJGqQ7pvY8/8dv+x hH8hC/7041t3frARZy8Vf2cVEXjElOmwSVg4l1hMabEIhWu4PwxuyIyAjQgGNjoOUjQr F4DnP2HtjSfTjLErI8pJzwzXmSjhkApFLfRcuAH2AeCvR0oxwb4Cq1c3+6yoXKv8ebMU zSJAGJHbLFOq8fhl5oGITdh52iM5C1qAEt992Z42wAWfVrjYn9jhSVzIn1eUTMSoogl2 yFnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pkuTtPjDaRXzXCCSiLSgQrwQKVUevil6DlT5gxKwxos=; b=qLqrRqKsscdvFQB5g4Z4e+7MpPv9fZYtXsfcmXDAUX/J6yGckKEIiQG1R81b+qDkTt Ub83aqG4/AAiNhuFv70pgNkA4bI0ex3i0gr0nFbUfQFCFhxcqFE3HobbGJgtQv54/p/+ i/UjnnptqwCaoi7YZoED9gefvCR8A12LArLuZwbn6WUaevyAzUDS4Gr6KQgUTLfdd1ou hszCeWInZ8FFHYIxpRThDiN2WA3+yUaFnEPNGHv+kKXQ6fEMogZsGdUcO2OoqY13jAXE 6QUaemNKsXtzXn6MJPfKzLIXJUcdNRib/2dkYnLB23CyfTO1cqL61Q1BdT2yuhd8+m7A wK2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L3a5eFpa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p20-20020a17090ad31400b001ead1c2f859si3691236pju.187.2022.06.23.12.15.03; Thu, 23 Jun 2022 12:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L3a5eFpa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231248AbiFWRKs (ORCPT + 99 others); Thu, 23 Jun 2022 13:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233775AbiFWRIM (ORCPT ); Thu, 23 Jun 2022 13:08:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D471B53A5E; Thu, 23 Jun 2022 09:56:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 207A0B82493; Thu, 23 Jun 2022 16:56:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74423C3411B; Thu, 23 Jun 2022 16:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003406; bh=u1D/hLqCjUAb9AG1DeAYgoHN8PQ3oSyKG26DNohWGvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3a5eFpaqVxiJw7iAkzv8It7zjuowXmq9heDBYpq12K6kvH7sRjz5p5vzEQMjsvp/ ZF31JtKVWuDW0WHUw2rR7X0IzNUoahNPXb1dy3Mh08c+l+MkOKxfZTdYuYX54ekeAw ohlYbN5Fp6ddvJBfJtk2VboObUNP3l8GXaMaSbds= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Shtylyov , Damien Le Moal , Sasha Levin Subject: [PATCH 4.9 229/264] ata: libata-core: fix NULL pointer deref in ata_host_alloc_pinfo() Date: Thu, 23 Jun 2022 18:43:42 +0200 Message-Id: <20220623164350.557247053@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sergey Shtylyov [ Upstream commit bf476fe22aa1851bab4728e0c49025a6a0bea307 ] In an unlikely (and probably wrong?) case that the 'ppi' parameter of ata_host_alloc_pinfo() points to an array starting with a NULL pointer, there's going to be a kernel oops as the 'pi' local variable won't get reassigned from the initial value of NULL. Initialize 'pi' instead to '&ata_dummy_port_info' to fix the possible kernel oops for good... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov Signed-off-by: Damien Le Moal Signed-off-by: Sasha Levin --- drivers/ata/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 35db918a1de5..42f0a592b5ab 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6051,7 +6051,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev, const struct ata_port_info * const * ppi, int n_ports) { - const struct ata_port_info *pi; + const struct ata_port_info *pi = &ata_dummy_port_info; struct ata_host *host; int i, j; @@ -6059,7 +6059,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev, if (!host) return NULL; - for (i = 0, j = 0, pi = NULL; i < host->n_ports; i++) { + for (i = 0, j = 0; i < host->n_ports; i++) { struct ata_port *ap = host->ports[i]; if (ppi[j]) -- 2.35.1