From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385568; b=l2uRk+itOMnVsg+2pQd2sstGolGwYdhfUF9VsT+XZSejjB0lKQUWB75/Zn3lWXb31TVW x9LTEyhiGT5fd2enygeczwCRnFdUOok/GFZnb0bo4Thxxu5lMZ4MCL3TaoPCAF00kiWI0 Z6c1WceSWWKe6X2GueROZjxPegc57zTXKus86e/ihl4K/Db24BiUifqqmDDvCG+obD9nJ NiGXHbz4qmwV6w7i3FeO3JwOdyk8gYurF+wpJlCEDCoGqbBS/hlG7Uhjlg39fvNbAzdxG PuamvYZjibrntVGIeeXZDy/2r0lE9sY52s1e9uu9DunG9aQFP8x8oG/HiiLyLYvHFDA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385568; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=DGjuYbpIj9VJsjhdsXaf1SKAJOVKioWyBOAOsaRrxb0=; b=uyq+eGlG3FKDdG2PB8eqmppQ1bJ8zxspRR+wp+3IH+U+hCcYyRxgxBEATghPMTC+L7ae tOjn4s+eUH0LaykJtwphMXeDTDsjXra8CGbkWe/c+xytRcrgkYtwMk0eNRgTTtN8G8Zg7 QFk7rBq53ZQ7hf5SuHqaR8hW3BbWrsv5zE84+gRPlIfZ19K0XNt+CVmnODZLqoUgXxvDf 3A34TRFMIzEPIejqHuZLekYqSa3NPLQFvObdG5OL9TFyI7pUmXeq4g3wzJCXj5KEpJddw UP9/ilnF54qRUELc8RmqvkOf2RIbtBUi0KSIlAbzRC3h/mIph3pHC3r4kG2TRzmamAA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=lrtHnoE1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A252606A322; Fri, 4 Dec 2026 11:59:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=lrtHnoE1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CDA21F00931; Fri, 4 Dec 2026 11:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385567; bh=DGjuYbpIj9VJsjhdsXaf1SKAJOVKioWyBOAOsaRrxb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lrtHnoE1SE4aGHpgYomy43lJmJE7LcWhEuxjGnhiGeMAR5NBp/PvR63pIx0QZqCzO DUkIFsYg+GW5v6ts7d9I/rudAt993CZYaF4gNJuGFq1lO+XuvpwvXsYKtIKloOy+D1 HBU3SOgAuEsOTEbd9q6sLHAIJdDPh7z4B3fKbUEs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shao Mingyin , Mikulas Patocka Subject: [PATCH 6.6 0604/1167] dm mpath: fix buffer overflow in parse_hw_handler() Date: Fri, 4 Dec 2026 19:00:31 +0900 Message-ID: <20261204100717.788919129@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: shao.mingyin@zte.com.cn commit 8f611fe94a781c6fb658488cc7eab4e4923e6df6 upstream. parse_hw_handler() builds the hw_handler parameter string in a buffer sized with len = 4; plus one byte per argument. Those four bytes were meant for the decimal form of the parameter count, three digits plus the terminating NUL. dm_read_arg_group() accepts up to 1024 arguments and the count written is 'hw_argc - 1', so a count of 1000 or more needs four digits plus the NUL and sprintf() writes one byte past the allocation. Size the buffer from the actual string length instead. Fixes: 2bfd2e1337f0 ("[SCSI] scsi_dh: Use scsi_dh_set_params() in multipath.") Cc: stable@vger.kernel.org Signed-off-by: Shao Mingyin Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-mpath.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -1083,8 +1083,9 @@ static int parse_hw_handler(struct dm_ar if (hw_argc > 1) { char *p; - int i, j, len = 4; + int i, j, len; + len = snprintf(NULL, 0, "%d", hw_argc - 1) + 1; for (i = 0; i <= hw_argc - 2; i++) len += strlen(as->argv[i]) + 1; p = m->hw_handler_params = kzalloc(len, GFP_KERNEL);