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 59EAF334C24; Fri, 9 Jan 2026 12:21:59 +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=1767961320; cv=none; b=Wbj4admpqLYYQtReGQUMkCyiVF+YDbJmC/MY2rYC12PBg9w1ioLgBnS4A2dRCFcjNYgHR3x6qJld98WshYk3zz82iHg/tj7GK3xSK3ePAgGNwvX4M2L3GbhyVntnd9E8g4oh2Vpe9Dy+ngt5LEQCPcCLa2COpftsxnEVDp09Y84= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767961320; c=relaxed/simple; bh=VpnLxVkVCzeUQFDTXmg+DBwWpnAumuAnbGTSprzYak8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lLTcKV8n6BIxJwJrH130WhtHoS9ZCs/U5nzoF24wQQ/w9pFwEb2z8OIBmf+aejkLnMbDSr5sNnFmEXPED3D+s/XucKv1suI5K3Lcq7F+WV87R6//2/DmWLjtoKQCz4W47oZKc75wjVwaSg6M6g4kXyKsXdPZSKlXicnMpC3ikWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DSNDcVwn; 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="DSNDcVwn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B387C4CEF1; Fri, 9 Jan 2026 12:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767961319; bh=VpnLxVkVCzeUQFDTXmg+DBwWpnAumuAnbGTSprzYak8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DSNDcVwn5ssHMIbaubgcXqwUZZzePER6OshciEp5yBORJejgHUw69WaGJSHzc+mi5 QqUwOPeXcEudgS/Wq2t0tos292C5NIxzDCCDsK1hGylrVD7aSDNk1lkrmWpv1U9NZv zkxiUFbu0jLRoW18OJfqUERIM/8iO8W6Fuww7kF8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vladimir Oltean , Simon Horman , Jakub Kicinski , Chen Yu Subject: [PATCH 6.6 680/737] net: dsa: sja1105: fix kasan out-of-bounds warning in sja1105_table_delete_entry() Date: Fri, 9 Jan 2026 12:43:39 +0100 Message-ID: <20260109112159.635576291@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112133.973195406@linuxfoundation.org> References: <20260109112133.973195406@linuxfoundation.org> User-Agent: quilt/0.69 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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vladimir Oltean [ Upstream commit 5f2b28b79d2d1946ee36ad8b3dc0066f73c90481 ] There are actually 2 problems: - deleting the last element doesn't require the memmove of elements [i + 1, end) over it. Actually, element i+1 is out of bounds. - The memmove itself should move size - i - 1 elements, because the last element is out of bounds. The out-of-bounds element still remains out of bounds after being accessed, so the problem is only that we touch it, not that it becomes in active use. But I suppose it can lead to issues if the out-of-bounds element is part of an unmapped page. Fixes: 6666cebc5e30 ("net: dsa: sja1105: Add support for VLAN operations") Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250318115716.2124395-4-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Chen Yu Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/sja1105/sja1105_static_config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/dsa/sja1105/sja1105_static_config.c +++ b/drivers/net/dsa/sja1105/sja1105_static_config.c @@ -1921,8 +1921,10 @@ int sja1105_table_delete_entry(struct sj if (i > table->entry_count) return -ERANGE; - memmove(entries + i * entry_size, entries + (i + 1) * entry_size, - (table->entry_count - i) * entry_size); + if (i + 1 < table->entry_count) { + memmove(entries + i * entry_size, entries + (i + 1) * entry_size, + (table->entry_count - i - 1) * entry_size); + } table->entry_count--;