From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01998140E3D; Thu, 11 Apr 2024 10:19:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712830780; cv=none; b=oq/7lQ6w5JkXV0tnaW3YlISRFAeXClK+KbTzFM/oNCKYzBDuSzNaiI5tOuKK03cATUJTtBfVOONkfhxGtbjXrYCwMWyYYMbn81SQP1VNltci9/a7iUeleJdyi0fBRXS8pGM7QZJkYoXvcx0aZ05K0//v6zU/j8oHTxSE96n55dU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712830780; c=relaxed/simple; bh=IBcSfhkTqOFLtxfH8MBVMYAB/AYVPTbEAF+XSzDXb9E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nyI2HtBm7V/bhkxyhy6ugHiTUxqGZ29zbshpyoKmxhehEwQ9Tk+Sg7kQg3G4TQIWKUfkhYdbXZzMpi8SkBMhYV+ZBChRzNYVPNTeisEbkKl2MTs9cxjhuCf2oaFNmEV5Ne1T0RLmdAlU5xMlveFmHmZfdaWQ2M35uWMsnXdq5SY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VJLR73Ec; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VJLR73Ec" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CFE8C433C7; Thu, 11 Apr 2024 10:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712830779; bh=IBcSfhkTqOFLtxfH8MBVMYAB/AYVPTbEAF+XSzDXb9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJLR73EcKFAb9GB2Kk8amfMes2zufvKvTr6aON2YMKkJJ1h2hMVX987LB6Udk2jtY qFiwK7n0O6S4+d0zWbofe/5fDeXhyIr6M+OwbZHGasjFxV5tFKkVly5Pe/3nr8iXYN nKJnDTcKKDjO6yb1vSD4lnL6RjxJJc+dlkpcQ3LQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikko Rapeli , Avri Altman , Francesco Dolcini , Ulf Hansson Subject: [PATCH 5.4 116/215] mmc: core: Avoid negative index with array access Date: Thu, 11 Apr 2024 11:55:25 +0200 Message-ID: <20240411095428.391528815@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411095424.875421572@linuxfoundation.org> References: <20240411095424.875421572@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikko Rapeli commit cf55a7acd1ed38afe43bba1c8a0935b51d1dc014 upstream. Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") assigns prev_idata = idatas[i - 1], but doesn't check that the iterator i is greater than zero. Let's fix this by adding a check. Fixes: 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") Link: https://lore.kernel.org/all/20231129092535.3278-1-avri.altman@wdc.com/ Cc: stable@vger.kernel.org Signed-off-by: Mikko Rapeli Reviewed-by: Avri Altman Tested-by: Francesco Dolcini Link: https://lore.kernel.org/r/20240313133744.2405325-2-mikko.rapeli@linaro.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -511,7 +511,7 @@ static int __mmc_blk_ioctl_cmd(struct mm if (idata->flags & MMC_BLK_IOC_DROP) return 0; - if (idata->flags & MMC_BLK_IOC_SBC) + if (idata->flags & MMC_BLK_IOC_SBC && i > 0) prev_idata = idatas[i - 1]; /*