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 690321DFD1; Sun, 1 Sep 2024 16:55:06 +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=1725209706; cv=none; b=RocdOY49IAUorO9gE9VDxswLRX+hbDH3kyrjlQMB1AMjGfszM1AL2OaIKdARgVwz8s9QOjORF/2hsXCNo5yvzmIWRCECP+RSBNrioWdF7qnYnXMBRjQyqtR9uS/WPrw0Nv11ZjqIpqM+jGewiaz2tbpkdkARe4ZTy40ZjJsnuxQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725209706; c=relaxed/simple; bh=P03iV06rJJrIAuXpH1LU+LZVodYq1ACl5tTEpdyYkws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DGlt8VThXHelsCZXr3qiKo9fRW15x0dalPq+qpQxASXCd2d5RHtqu8w77ELSj3Rr79+xxXt0JvugJMI/zR7iAzX3SU41bAbebXDskwHJQf3RAJ71vIl7oir+kuPGGoau6NfiqDVHupt258wB5QemqSZnxw8ERvrTl2qnnXyTZyk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aHhQkaz9; 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="aHhQkaz9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2092C4CEC3; Sun, 1 Sep 2024 16:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725209706; bh=P03iV06rJJrIAuXpH1LU+LZVodYq1ACl5tTEpdyYkws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aHhQkaz953y1ZHMcub3M7kmUBqGidE4yNO8IjMxnZRRAsS6iQ7pIPJog0gMkZM4bn NNdKp8pm1mC2iyDGssTz/DQ5IpiBguYTmD5aemsRdpMIbamHZJQPvX6J8lxB+dBig3 Ej9BVEYiu+y+vlExjjjwRzfYoXXqxrs6f+UYKcY4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot , Dmitry Torokhov , Tetsuo Handa , Linus Torvalds , George Kennedy Subject: [PATCH 5.10 119/151] Input: MT - limit max slots Date: Sun, 1 Sep 2024 18:17:59 +0200 Message-ID: <20240901160818.585920817@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901160814.090297276@linuxfoundation.org> References: <20240901160814.090297276@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa commit 99d3bf5f7377d42f8be60a6b9cb60fb0be34dceb upstream. syzbot is reporting too large allocation at input_mt_init_slots(), for num_slots is supplied from userspace using ioctl(UI_DEV_CREATE). Since nobody knows possible max slots, this patch chose 1024. Reported-by: syzbot Closes: https://syzkaller.appspot.com/bug?extid=0122fa359a69694395d5 Suggested-by: Dmitry Torokhov Signed-off-by: Tetsuo Handa Signed-off-by: Linus Torvalds Cc: George Kennedy Signed-off-by: Greg Kroah-Hartman --- drivers/input/input-mt.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c @@ -45,6 +45,9 @@ int input_mt_init_slots(struct input_dev return 0; if (mt) return mt->num_slots != num_slots ? -EINVAL : 0; + /* Arbitrary limit for avoiding too large memory allocation. */ + if (num_slots > 1024) + return -EINVAL; mt = kzalloc(struct_size(mt, slots, num_slots), GFP_KERNEL); if (!mt)