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=1796388297; b=bb56LWi3kMKm6fXGf3ForT2u6JsQzMjtEy4rEHvUrGaoI4WFKL7OyRCryFhkhsTITlia FWa8MXcCksGuSV4YegwLN7VwtV5TjNVuOYWhYbnkkhJ6jr8sZIHdCbVn9sknnI80/asKS DZ+MloKyICUQuEgRB+W9ZvPTMN7ZDw3OR/5uT40GgaZ1kBtmKS4Xly45SMLs4PWiFmh0a VD4HFBd0kYNXz0VJF74HaDoqmZVM8E0mwq6SzaV2lIJ3oz/u9HxiHRRHJKNHYh49i1SIl 70H+/jwBLBAkrPqVrlxg3AddS8ZDyAALD1zr0M5Q2/r1j2MDP1j4UWku79+YAH5bSeg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388297; 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=kqxS+8w/IaAAcYtwo6RnnZ6aDty5wuSxaNnH+/r56Go=; b=WrvN/AUOXdfganQWTmWdCqslJKX/IiLLHWtec0ZWuusdgi1c8kZu5b2KWzJYkCXkXaq4 sMESHr5Dhk5Q0onkVUcIZE+TwbTNsmenq2jBz7IMbBBtg/yZHRRDf60/iTkfdQj0NqoOO JQjk5hEDYmPC4BzNUZ5tgmCgHDNC+oSbR6rFbcPv5+I5O1EEkzadr96/072cICP2eVeTF pIW04zJqXL4TsqEgZR+8m2UeBZa/IB94o4fm403FN1Hs10dkRw6UnQm965UxUqjbvJR2C HuNo2TuRkRKB94BJ599VTXsO8njbdWM2Lh6aXJIzYMwxsL7cV3fvHF9kQWWCNdQNxdA== 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=j4klWCOa; 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 5415B606A32D; Fri, 4 Dec 2026 12:44:57 +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=j4klWCOa Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5C721F00897; Fri, 4 Dec 2026 12:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388297; bh=kqxS+8w/IaAAcYtwo6RnnZ6aDty5wuSxaNnH+/r56Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=j4klWCOawsyM1I6gQFGTx62pNNFZ80giYdS9f4R5V2kEHETzwsTPINMh+cSkWKKur M7Ems7NDQCNLk+hG2ktZP+m0WAMH6ZU8+iLGLuKVjyMEE7hHBbcPgRsIv+no/fvCXS fagauUZxLsbHnRN8Jvn12tSZl37z453eQa4OBk2g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shao Mingyin , Mikulas Patocka Subject: [PATCH 6.1 0561/1059] dm mpath: fix buffer overflow in parse_hw_handler() Date: Fri, 4 Dec 2026 19:01:32 +0900 Message-ID: <20261204100658.705489974@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 @@ -1082,8 +1082,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);