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 4A11E1F95E for ; Mon, 9 Sep 2024 06:58:33 +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=1725865113; cv=none; b=QJd+MqPycEZN8wTEwUflt2clw9iXcfUqkBfJfZlOfnRqIm9VseDPxPnIZ0O3r6bk4iQ7t/nDYGHlQFljLvsELeExy7zenwe/hoVLJlOBWld7IuYk8wklzoOOk/uTbJuy1i1UldM0VCk9kNBY2HRV8QjFlhhJ2k87HGlgrh/A8j0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725865113; c=relaxed/simple; bh=yDiyBXzvaOqNBkFeeMQ3PaTHGS3BcvdVakN2fvFq1hY=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=od4WiEz2hXPispTcYAG8E48try8lK6eGz/izDCXnqSAH4dsF9Gvihm8ome9KMNCHlkXNxo8o+gyGoGxGSGY/LLj/e2DsHaN98ksD13Cd5xWzTvDBaBkVTXXC3ImhhUqu47FSeUeZlpnUEiWorsEg9txQ2lW3SK1M0haue+Awq0U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=B3xkSNCy; 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="B3xkSNCy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF7BDC4CEC5; Mon, 9 Sep 2024 06:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725865113; bh=yDiyBXzvaOqNBkFeeMQ3PaTHGS3BcvdVakN2fvFq1hY=; h=Subject:To:Cc:From:Date:From; b=B3xkSNCynvoua6vMbts7KFAge4S7gTClbjZZ1zpRhr9dJMRR8VEeZJBlIpTneNgqD mfUtTQ4Yyw7WONIrBP6rAoEdPL6gT8cSsMbg4i3o1GU0Q7+dUtVYfgJvyfXma75pe1 fVyMw4EsuVl+89Vna9lTrI7VS4B1M+g8GvVLYG70= Subject: FAILED: patch "[PATCH] nvmem: u-boot-env: error if NVMEM device is too small" failed to apply to 6.1-stable tree To: git@johnthomson.fastmail.com.au,gregkh@linuxfoundation.org,rafal@milecki.pl,srinivas.kandagatla@linaro.org,stable@kernel.org Cc: From: Date: Mon, 09 Sep 2024 08:58:22 +0200 Message-ID: <2024090922-marathon-revival-7771@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 8679e8b4a1ebdb40c4429e49368d29353e07b601 # git commit -s git send-email --to '' --in-reply-to '2024090922-marathon-revival-7771@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^.. Possible dependencies: 8679e8b4a1eb ("nvmem: u-boot-env: error if NVMEM device is too small") 6bafe07c9306 ("nvmem: u-boot-env: improve coding style") a832556d23c5 ("nvmem: u-boot-env: use nvmem device helpers") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 8679e8b4a1ebdb40c4429e49368d29353e07b601 Mon Sep 17 00:00:00 2001 From: John Thomson Date: Mon, 2 Sep 2024 15:25:08 +0100 Subject: [PATCH] nvmem: u-boot-env: error if NVMEM device is too small MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verify data size before trying to parse it to avoid reading out of buffer. This could happen in case of problems at MTD level or invalid DT bindings. Signed-off-by: John Thomson Cc: stable Fixes: d5542923f200 ("nvmem: add driver handling U-Boot environment variables") [rmilecki: simplify commit description & rebase] Signed-off-by: Rafał Miłecki Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20240902142510.71096-2-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c index 936e39b20b38..593f0bf4a395 100644 --- a/drivers/nvmem/u-boot-env.c +++ b/drivers/nvmem/u-boot-env.c @@ -176,6 +176,13 @@ static int u_boot_env_parse(struct u_boot_env *priv) data_offset = offsetof(struct u_boot_env_image_broadcom, data); break; } + + if (dev_size < data_offset) { + dev_err(dev, "Device too small for u-boot-env\n"); + err = -EIO; + goto err_kfree; + } + crc32_addr = (__le32 *)(buf + crc32_offset); crc32 = le32_to_cpu(*crc32_addr); crc32_data_len = dev_size - crc32_data_offset;