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 BD27E336EC4; Fri, 17 Oct 2025 15:21:41 +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=1760714501; cv=none; b=u7RfiewDcQhUrMYQr44Rn/AYn8LTBdT/SPT2c+gk3ym5gA73QDP/6u+o73uwwkq05ziXPWKWXl1IOLuKUZdLzBQJxBgjGk7GM8f+pS2lKFsg4curu/AHVGn6EQi4mpKq5LN91zyNQv5OTkWaW2rebetErkZYatIU0yoTO1TKCnI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760714501; c=relaxed/simple; bh=EwHW+tjCu6hyrRoMfrrfKiJ+MyrF2bp7LE7YQrS4lvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L+6QwwZc1mtFGIIsDt3SZK1uQivLdNqs2lF2lTUC4xnEHrRnhOVENhAkDKCaMrclo0bUPXgqD/KtIb67wPupM+x6FbZhwWtVLtM4FsDtlq+5MJoFCQqcL/PF5SsZN4rrIZaaPYbmWD4loxMAr+/585p2mAjdhJ4w4X254vvzIW0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RqsVCXhv; 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="RqsVCXhv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C762C4CEE7; Fri, 17 Oct 2025 15:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760714501; bh=EwHW+tjCu6hyrRoMfrrfKiJ+MyrF2bp7LE7YQrS4lvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RqsVCXhvnhrsM/E6jM2DoGzxlB6tYEU0GJFr1T5e+x91zZHmSxae4DWB/dtsBpRn2 ntYBfsf0suvmzMrhzgN7Ea6PSJPQbAWxn1hUOekAM3setWMCK8/yhPkCVL1pz1Gjuu b2NpdyItp8Of32jx9di/oEwCQsq0/fhGZlimI6p0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Miaoqian Lin , Max Filippov Subject: [PATCH 6.12 166/277] xtensa: simdisk: add input size check in proc_write_simdisk Date: Fri, 17 Oct 2025 16:52:53 +0200 Message-ID: <20251017145153.186983308@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145147.138822285@linuxfoundation.org> References: <20251017145147.138822285@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miaoqian Lin commit 5d5f08fd0cd970184376bee07d59f635c8403f63 upstream. A malicious user could pass an arbitrarily bad value to memdup_user_nul(), potentially causing kernel crash. This follows the same pattern as commit ee76746387f6 ("netdevsim: prevent bad user input in nsim_dev_health_break_write()") Fixes: b6c7e873daf7 ("xtensa: ISS: add host file-based simulated disk") Fixes: 16e5c1fc3604 ("convert a bunch of open-coded instances of memdup_user_nul()") Cc: stable@vger.kernel.org Signed-off-by: Miaoqian Lin Message-Id: <20250829083015.1992751-1-linmq006@gmail.com> Signed-off-by: Max Filippov Signed-off-by: Greg Kroah-Hartman --- arch/xtensa/platforms/iss/simdisk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/arch/xtensa/platforms/iss/simdisk.c +++ b/arch/xtensa/platforms/iss/simdisk.c @@ -230,10 +230,14 @@ static ssize_t proc_read_simdisk(struct static ssize_t proc_write_simdisk(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - char *tmp = memdup_user_nul(buf, count); + char *tmp; struct simdisk *dev = pde_data(file_inode(file)); int err; + if (count == 0 || count > PAGE_SIZE) + return -EINVAL; + + tmp = memdup_user_nul(buf, count); if (IS_ERR(tmp)) return PTR_ERR(tmp);