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 7068D1DE4DF; Tue, 8 Oct 2024 12:44:20 +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=1728391460; cv=none; b=PQ4VIAbPNx1GSczMULBQYPzBbZTepO+3w9ee6jzKYMdd6RCk4U6v0ZcAM/o1OJiI24KHT5Ly+UeAxB28429tzZymbqeahBA2EyE+dYa6TQeyjNWM4+T45Hj8QUTFNAI880mMATGEObySvY0+2GnP8/plrTZnQ8Iz1Arnv9AriTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728391460; c=relaxed/simple; bh=aaJ6yfQzo50xh+OAoFbxjzSUZgQV01drWYZ+WWNfbE0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JgH8ROEvh77dkKxhm+6CZ0jv8d1eiC2DPcN5eru3+npKmncQAKLyFCIRrVcqedpFMPwfkPXF8PRTWfmHcY3k4YmRxahN/Je8omjh8GNWNenrIn/Mnzd7FgfclSCD123xIiJG0/nubDVlE6OC6VSXfuTyk6Bb6x+YzcTv4waiuxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pw/tZ/x9; 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="pw/tZ/x9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4B0AC4CEC7; Tue, 8 Oct 2024 12:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728391460; bh=aaJ6yfQzo50xh+OAoFbxjzSUZgQV01drWYZ+WWNfbE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pw/tZ/x91LvCyZX4tlcBdcuCV9nKenXlRSzCOBkq4x2zJf/3wEDk3W++EB/EpOG34 P1qmkEi9DXU45NF/8FlOtpwHNMMbHJy1khPKOqImxKUIFl8vft5kRKUB7uPsosQNQx s4DuofNAMJQvHBANtXORsP8ZmvneF4QDNVM1tSpA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jakub Kicinski , Simon Horman , Sasha Levin Subject: [PATCH 6.11 122/558] tipc: guard against string buffer overrun Date: Tue, 8 Oct 2024 14:02:32 +0200 Message-ID: <20241008115707.167157246@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115702.214071228@linuxfoundation.org> References: <20241008115702.214071228@linuxfoundation.org> User-Agent: quilt/0.67 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 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Simon Horman [ Upstream commit 6555a2a9212be6983d2319d65276484f7c5f431a ] Smatch reports that copying media_name and if_name to name_parts may overwrite the destination. .../bearer.c:166 bearer_name_validate() error: strcpy() 'media_name' too large for 'name_parts->media_name' (32 vs 16) .../bearer.c:167 bearer_name_validate() error: strcpy() 'if_name' too large for 'name_parts->if_name' (1010102 vs 16) This does seem to be the case so guard against this possibility by using strscpy() and failing if truncation occurs. Introduced by commit b97bf3fd8f6a ("[TIPC] Initial merge") Compile tested only. Reviewed-by: Jakub Kicinski Signed-off-by: Simon Horman Link: https://patch.msgid.link/20240801-tipic-overrun-v2-1-c5b869d1f074@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/tipc/bearer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 5a526ebafeb4b..3c9e25f6a1d22 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -163,8 +163,12 @@ static int bearer_name_validate(const char *name, /* return bearer name components, if necessary */ if (name_parts) { - strcpy(name_parts->media_name, media_name); - strcpy(name_parts->if_name, if_name); + if (strscpy(name_parts->media_name, media_name, + TIPC_MAX_MEDIA_NAME) < 0) + return 0; + if (strscpy(name_parts->if_name, if_name, + TIPC_MAX_IF_NAME) < 0) + return 0; } return 1; } -- 2.43.0