Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13952943pxu; Mon, 4 Jan 2021 08:51:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKshH0zAyN2znewxhKRexBgtUNi7uYg6J8TA48nAGw3MSdvjtqTInwS2zWb9Vd5zYKASF/ X-Received: by 2002:aa7:c3d3:: with SMTP id l19mr73700816edr.366.1609779082352; Mon, 04 Jan 2021 08:51:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609779082; cv=none; d=google.com; s=arc-20160816; b=lr5Sr/TiMoTVo9eOOm1i6nt0kdXiZzD4ItXlA3LiAP2cpok5OZ9kd52/hJfuCbF9TH Hmm6g8defsrymZmM+ucZPGXutg00tbQVnsZQIrd+rHmWcu8odoNkVMeblTkS1Lq/sb0f 2JxQLWtjgByIBn+VZBq8V/1g2cE/FF+nlMq62OTj49lHmlE0LdpJIZi+sljWvgd9x+QI 0Ztgf5E7+ehxpFylDRhYqyDEKZit6CRLC6X4L5vzQEcoRXEU4NpgYfz3g0Bp4QOv86Sb LG3yCmtdNwwJGKNg2waqk+tl/fUJwyaH5ZUyGqTb3oEkVNEfuOHYTrYDcjrLOjKIRhst DN3g== 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=QYrTJfp5tQOIDNh9x5Qie1miY53LoAiKIoL+TaZLuXc=; b=VvzpwiwYLQriF4mXErsb8kh/FiamgbeoApKPiW/rihZkSUF19tQpwCCA/Oy60XY2Ll Mw/ufTf3Smid3aZn/sK2BRSXr68G+DHK3VDZg0Xiz8hrFWnlF2WWPOtIEgpVDYs1PVDj crMlNnKEqOo5ckIVmoZAPBmJdd5DGuZQZ9ooUqrMHoY9gKlb7Gi9sYpLurpad0CLe/O5 MuKmGtLIFrShW3iYy63U713UoDkZBlm5bMud8cOIZJBemARNrodahP8C/4Zr9gCU12o/ XGUNhufVTSIW7NccAaUDhKBh9yl+WAOpSSVIm2/+js8w8Pqj85jScsQSlcOmiXhVZ/K3 jhlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZAkcQR9z; 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 z21si33563696edr.365.2021.01.04.08.50.59; Mon, 04 Jan 2021 08:51:22 -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=ZAkcQR9z; 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 S1728814AbhADQC1 (ORCPT + 99 others); Mon, 4 Jan 2021 11:02:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:39414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728817AbhADQC1 (ORCPT ); Mon, 4 Jan 2021 11:02:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35A15207AE; Mon, 4 Jan 2021 16:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609776131; bh=AXtDkQKhoWWnD9n01X/y6OhukaBW29RrVkYKZcKQVec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAkcQR9zGxf55qRsuQDcD78jMM21FYe7GgBRP+SeoGfnX9iVXaKqz0RFFvd2mCEn7 WNG7CwA0Yg6aUmy1PmQvADcQbrZ9lTlX6cvHgW0ICJk5LsVuoHjcf/Mbn8mr5xgMtr qdWZvaGQx2nt7+3CeWKrSjKyox4ns8FWr/3lEshA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kevin Vigor , Song Liu Subject: [PATCH 5.10 05/63] md/raid10: initialize r10_bio->read_slot before use. Date: Mon, 4 Jan 2021 16:56:58 +0100 Message-Id: <20210104155709.068169358@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210104155708.800470590@linuxfoundation.org> References: <20210104155708.800470590@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 @@ -1128,7 +1128,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, @@ -1493,6 +1493,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)