From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 452231A9F90; Sat, 30 May 2026 18:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780166963; cv=none; b=V8Uj+O93w9c/dI+Koli2uS6gaRmOKIeB92c1Dpj6wb4Su9Up6ENC2cuFS2i2cxBohA4Zqu9FJRyh3ZA0lumvW9SmiJf6u3Q7tsoXIphQbd6VLhbfpcxnXFFqu/DFsKmUZcwg+KvxN6Cj7iV2keqoUV+MhUJGOBdAHVssIyBdD9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780166963; c=relaxed/simple; bh=pw77T/x5hZoyG3H6E5lHRfKH59grmet6WLFwka2+gA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rSG+CDpyVr+4RX+Ke62dY2y4iV/BPXGtJTeBRH1Kk+bQBkCu6RrGbAOG3FR3qjZciPdZxq0ydbH5klcW6iGZdr4y6IjI/qLW9vUNKbQfTKuR4BfrCMmXvgdItDPptm9sqGHtGfirzphpI3Xgm+fsQdqGq4YLybbr+LKQaJ4d8gM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1iq5KkiB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="1iq5KkiB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C1E51F00893; Sat, 30 May 2026 18:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780166962; bh=utj8TWohUvzNK1H5LdjYIysdB02eKuCzGn/J8aBwYgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1iq5KkiB+Q/ExYNYVSY8QbncIIk154X9GbZzDIM6frnQQLS1KnjxcaTfmgyaUchd9 I3LblnAZhtyDpdzzcFLUau/7u7kg6T7voPjpw4rGM+s4tGo+xoa5WgVSggT3YZS/Pn 2Lu10DB3BsY2j1vU4HAng4YmRZ4XAuc1cOzleTNc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vladimir Oltean , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 524/589] net: dsa: sja1105: fix kasan out-of-bounds warning in sja1105_table_delete_entry() Date: Sat, 30 May 2026 18:06:45 +0200 Message-ID: <20260530160238.382660782@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160224.570625122@linuxfoundation.org> References: <20260530160224.570625122@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-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: Sasha Levin --- drivers/net/dsa/sja1105/sja1105_static_config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_static_config.c b/drivers/net/dsa/sja1105/sja1105_static_config.c index 139b7b4fbd0d5..a348705174fa5 100644 --- a/drivers/net/dsa/sja1105/sja1105_static_config.c +++ b/drivers/net/dsa/sja1105/sja1105_static_config.c @@ -1439,8 +1439,10 @@ int sja1105_table_delete_entry(struct sja1105_table *table, int i) 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--; -- 2.53.0