Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2976590imu; Sun, 9 Dec 2018 14:06:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/V85Tkf5o+17OntH00IIJh4aT6VVhjblucOQcsTellilqD96NZqOX4+Vx8RyNH78NiNwOs6 X-Received: by 2002:a63:66c6:: with SMTP id a189mr8856898pgc.167.1544393213966; Sun, 09 Dec 2018 14:06:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544393213; cv=none; d=google.com; s=arc-20160816; b=SmB90+2ulB1qgs8fsMmeN3bYijTAzAyVGh6wy948LR5kLUgVw7srkJTofpiKJk2el6 rq/67cUBAR5HgyxJt8Sx7fgu99H/Emv9ExdCAsHogYT9J+nHEomwttbcpEUPZil2oS/i aI4ZyJMdUSKXro3hlQPsDVDBPt5tSyMg80iz+T7RWcr7L0Lq8Iv8ohS9D3i2N2EZrdiy 7dBND4rZdphtIHJPsD0tGL5TKq17VDcnFAJf2gmp+Nq5sHbjqtFaFUqhG0m2x3FNcx1m lPl3cZTI805UdQyIToVOkZ0sELtESgQERFXIGLJK6u4//rL4pWvGI1PIRhBcEX0RJmp0 u3XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=RO5nMq+vASH2caEdzWJqbnv0d0mHSrYYxpQxKfp/CsM=; b=KSL+Q+kjpnBY1zcdMIvZZTLiUfkIKOoSCMVb2bTLTpAx7jh54HQuaP0+iTLg+zzNnE Zx2gheFlUPJ3x2HgFPGl8ZX6yPOEeNvblGMF/HJEbTF+Q9pUo20abe2RcW5Cqsk5XlxN XnXpH6zKc1yFrq6ZzMarK1llZDPnkGLeiZOPmQnGoWKhYUd6XoHbZZoFO3E0DgMeweDS Ac0kbu37rTnpgEtxZFmyLmI6bJn2rX+sGDUt7q6H3GRFlTsszZh9TJo+0QLXwiHpRaAx qlWOjkFHRo/FKxWsv2GGyIRkcU39TF3oWiW3sJGq1w0+RspVqd6fpmN29XGcFSL/4YuU sW7g== ARC-Authentication-Results: i=1; mx.google.com; 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 30si7986013pgr.396.2018.12.09.14.06.38; Sun, 09 Dec 2018 14:06:53 -0800 (PST) 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; 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 S1727372AbeLIWFT (ORCPT + 99 others); Sun, 9 Dec 2018 17:05:19 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:36914 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbeLIWFR (ORCPT ); Sun, 9 Dec 2018 17:05:17 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73K-0002ic-9t; Sun, 09 Dec 2018 21:55:54 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72b-0003Id-2U; Sun, 09 Dec 2018 21:55:09 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Jens Axboe" , "Mauricio Faria de Oliveira" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 081/328] partitions/aix: fix usage of uninitialized lv_info and lvname structures In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mauricio Faria de Oliveira commit 14cb2c8a6c5dae57ee3e2da10fa3db2b9087e39e upstream. The if-block that sets a successful return value in aix_partition() uses 'lvip[].pps_per_lv' and 'n[].name' potentially uninitialized. For example, if 'numlvs' is zero or alloc_lvn() fails, neither is initialized, but are used anyway if alloc_pvd() succeeds after it. So, make the alloc_pvd() call conditional on their initialization. This has been hit when attaching an apparently corrupted/stressed AIX LUN, misleading the kernel to pr_warn() invalid data and hang. [...] partition (null) (11 pp's found) is not contiguous [...] partition (null) (2 pp's found) is not contiguous [...] partition (null) (3 pp's found) is not contiguous [...] partition (null) (64 pp's found) is not contiguous Fixes: 6ceea22bbbc8 ("partitions: add aix lvm partition support files") Signed-off-by: Mauricio Faria de Oliveira Signed-off-by: Jens Axboe Signed-off-by: Ben Hutchings --- block/partitions/aix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/block/partitions/aix.c +++ b/block/partitions/aix.c @@ -177,7 +177,7 @@ int aix_partition(struct parsed_partitio u32 vgda_sector = 0; u32 vgda_len = 0; int numlvs = 0; - struct pvd *pvd; + struct pvd *pvd = NULL; struct lv_info { unsigned short pps_per_lv; unsigned short pps_found; @@ -231,10 +231,11 @@ int aix_partition(struct parsed_partitio if (lvip[i].pps_per_lv) foundlvs += 1; } + /* pvd loops depend on n[].name and lvip[].pps_per_lv */ + pvd = alloc_pvd(state, vgda_sector + 17); } put_dev_sector(sect); } - pvd = alloc_pvd(state, vgda_sector + 17); if (pvd) { int numpps = be16_to_cpu(pvd->pp_count); int psn_part1 = be32_to_cpu(pvd->psn_part1);