Received: from n169-111.mail.139.com (n169-111.mail.139.com [120.232.169.111]) (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 5E3771EA7CE for ; Mon, 25 May 2026 03:18:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=120.232.169.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779679139; cv=none; b=Rvpm/TCC0cXIzITixypqVnV99kamBXxjUYvkk7P2YOsZc1uEGXIj4j98UddluXijBZq4KRn5dyiO9nbUbLrPWHiwN1FyDLGAbLj8i8xd7bFYVyQX3c7mbac43452zoHgFP8guBBFw6YXpQD32jalH2OBLOPpVQWb6P5JxULur14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779679139; c=relaxed/simple; bh=N1sJ56JHFf/bXeRmF2fsfoXenNPTm2633gGXN0vPxgs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Zsx+0+cdXQkqw21yL5pfqmAN16V6s6VBD3U4GGEk2t04Cj7kUobbVOteNBU4Rjw4XJdYDiihzcQzkMTyF7B4edhLeR/NL6tBwvXHU2ToF62Qqzcv9bKLIC9FPXTHqBfkj1lcCT6EmDvVucn5bo8xJ96AjZMW4DKe5nbsl37AaCM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=139.com; spf=pass smtp.mailfrom=139.com; dkim=pass (1024-bit key) header.d=139.com header.i=@139.com header.b=BUd2C3ta; arc=none smtp.client-ip=120.232.169.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=139.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=139.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=139.com header.i=@139.com header.b="BUd2C3ta" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=139.com; s=dkim; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=BUd2C3tah5hIvvLpseQxtMBWH1uPzPwtri5h/1+FxWurxZrWGCI3uwVmgf83xcMMLMfE5xmFlMgCJ lQ2T8LgL3QNZoDqk5Kk0D1lghLO+eJATTvIZlvQrSNQ0NhQJdh9alWYc9Wq+a2DoZOKPTtyD1DJpFj BrytVedbPLhHTtOE= X-RM-TagInfo: emlType=0 X-RM-SPAM: X-RM-SPAM-FLAG:00000000 Received:from NTT-kernel-dev (unknown[117.136.0.39]) by rmsmtp-lg-appmail-18-12021 (RichMail) with SMTP id 2ef56a13bf8f72a-7b68d; Mon, 25 May 2026 11:18:41 +0800 (CST) X-RM-TRANSID:2ef56a13bf8f72a-7b68d From: Rajani Kantha <681739313@139.com> To: vladimir.oltean@nxp.com, horms@kernel.org, kuba@kernel.org Cc: stable@vger.kernel.org Subject: [PATCH 5.15.y] net: dsa: sja1105: fix kasan out-of-bounds warning in sja1105_table_delete_entry() Date: Mon, 25 May 2026 11:18:40 +0800 Message-Id: <20260525031840.5358-1-681739313@139.com> X-Mailer: git-send-email 2.35.3 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: Rajani Kantha <681739313@139.com> --- 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 baba204ad62f..2ac91fe2a79b 100644 --- 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 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.35.3