Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp344756pxu; Thu, 7 Jan 2021 06:35:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxY9cCWQ08lQxWzEUCSe+w87WG7qVHiMNHDNf7312FRsgak7a3ihVXI+lqtL6WqQgclcezw X-Received: by 2002:a17:906:c10e:: with SMTP id do14mr5276783ejc.166.1610030107669; Thu, 07 Jan 2021 06:35:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610030107; cv=none; d=google.com; s=arc-20160816; b=zGz5sOarBSmsYAhdeOX5sovFTS+q2Mqn0W8YWipbq4oJC/obIR4Y+AoMY2LuGVyNnL iluxB+IMdXQH9oO+9TTJXwGRrXmo4exJNoJh14ZPV8oNrhgtbUJopD5CaC/XuBFF1R7B +x+xkSK3lqSZOMBUpV6N/Yd6vW627c6Sp14MiprW1QvtLkykf66u+cD+f0hxJUfbmkTN neUf4KkhIoxJ3Os9tY0IaRgNBycYkfuAIpDzpT2YXahUOIdHqUutYdJm2rYZiFBY37Dl +YFxaM9JObMihnqTalD4dQNm9MHSLSuGzJtN50jfOWjgz9STqjDqfa0WRHYpsEnp+N5d I/9w== 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=jm5kOscMnJ1ReUgLbciAdx8V04uu5Zh/OZA5l5uygjg=; b=JcQLlblfLOUHDLdU2yEeHC/tULqLird0M8mSxzUu8MNjKWNxQYF1LRbrQ7O8Xw1Mup 01STpNxY2wDt1WlcLluVBECx1hfdKOg6gLn0hb30Ib7cL6QrFvZkOeewsqkyV0aUZ87V iJdXgx1HIu08Io1OX6O6lQdC01zcQTRsbwrmhAX21z8b8G/6n3C0igklzgdY80j/91GT 3NNJVUu4wgNmaQxlae/CvMUyutAiLUrA3dXnkykeQZ+ejCeF1HFJT4gJLXAU3vOiHPm3 9AAruEmzHKkHUjTBnLuldHN+YttHEjTgHCg1eCXavIdvxIP0gjj6ebx9PqoynG4Exu/d /YDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="lAb/Kw+R"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si2320426eds.129.2021.01.07.06.34.43; Thu, 07 Jan 2021 06:35:07 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="lAb/Kw+R"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729188AbhAGOcG (ORCPT + 99 others); Thu, 7 Jan 2021 09:32:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:45976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729100AbhAGObz (ORCPT ); Thu, 7 Jan 2021 09:31:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB0D523384; Thu, 7 Jan 2021 14:30:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610029856; bh=j7wIWmPz4LCwK472zUBV70R6svjuVOVYEpgERvVCHsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lAb/Kw+RQ04xmTwXKq70hFSsaIFE/NGZzPbq3AyCqHAWXb776t6D1+V5mEgtxzNwF 2yBpztAgJZgATwIu3GWczVIJFKl0Mi+8GctmMa7Qa+gVHk21mKyapV4naDUUfobVLU bTNXb/55utmvsxXeYTInSHdcHcvaRORY6nN3RmOg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kevin Vigor , Song Liu Subject: [PATCH 4.14 02/29] md/raid10: initialize r10_bio->read_slot before use. Date: Thu, 7 Jan 2021 15:31:17 +0100 Message-Id: <20210107143053.269861038@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210107143052.973437064@linuxfoundation.org> References: <20210107143052.973437064@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Vigor commit 93decc563637c4288380912eac0eb42fb246cc04 upstream. In __make_request() a new r10bio is allocated and passed to raid10_read_request(). The read_slot member of the bio is not initialized, and the raid10_read_request() uses it to index an array. This leads to occasional panics. Fix by initializing the field to invalid value and checking for valid value in raid10_read_request(). Cc: stable@vger.kernel.org Signed-off-by: Kevin Vigor Signed-off-by: Song Liu Signed-off-by: Greg Kroah-Hartman --- drivers/md/raid10.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1120,7 +1120,7 @@ static void raid10_read_request(struct m struct md_rdev *err_rdev = NULL; gfp_t gfp = GFP_NOIO; - if (r10_bio->devs[slot].rdev) { + if (slot >= 0 && r10_bio->devs[slot].rdev) { /* * This is an error retry, but we cannot * safely dereference the rdev in the r10_bio, @@ -1513,6 +1513,7 @@ static void __make_request(struct mddev r10_bio->mddev = mddev; r10_bio->sector = bio->bi_iter.bi_sector; r10_bio->state = 0; + r10_bio->read_slot = -1; memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) * conf->copies); if (bio_data_dir(bio) == READ)