Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp949512lqj; Mon, 3 Jun 2024 06:06:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTHHjaCzWF25YmKxIPA0t3gtJD1h+HgH0LNTLY2/Nca/hbaXt/m9UTdWfZBvhcbBOgwlXMMB4eaKU+IKPoWC8wobE8cWGQWgXZl0Uy7w== X-Google-Smtp-Source: AGHT+IF9AFs778LlJrW43Jh6453o/gtd+TL6pR7h6bQoc7EJKpPLZFavLce2XmyReQRqh9G8dBqH X-Received: by 2002:a05:620a:1907:b0:794:fa90:4045 with SMTP id af79cd13be357-794fa9040dcmr747547285a.29.1717420016968; Mon, 03 Jun 2024 06:06:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717420016; cv=pass; d=google.com; s=arc-20160816; b=M2wV/cA6ohPUbwClpTSSbxq7aktR/LMth1UKz1uObwIjp8w+SWZemSvWqaLEszwCmA K9Yb7YAswblRs+0zWhMxvFUglcJnUv/uVR3nyuFgo4nyigTgvOpbDVsJYDvzBL4/wwdk 4G8STAPRBdNI0A4kq7BAwoUQi4W9fGbb4Mjlv9jKvV+u/TDTTXICwghHQQ1l9/IEgU2j DBgEVZx+Z3pcNhrdmPRWCGOyi31LC9F8sriomhpSSKFsKZO/VKccvQ47PzENzg0QRHLc dmgZ+G5v0AUXjc4FNMvmLDGepmYRwI8/V9jfNMTil0lo/ia+2cDb6OvY41wN+Zp0wpbv PCkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=QYKaPAvWrHZWZO1zaUSYjSJitAkfKbws1N+7wWHnIzU=; fh=RZkaJUFmKFdIBiZZqUYt6JgFUW54cUfYutKYT80tCzc=; b=lSY2xbBm6h+B9SqgRc5voJ/mL8ryLOkkvqrl++A0ZjOIMdFxZWZLa6b2EbRcnkpsrk 7Nl+CBbXQILp/yANmlaeBuxhfOBfp7PoUcd2oFzh3/DoABUnDfB0egJ39lb80lBNMXNV 7dwOPoTsFJdJnvYebeT0fsqIvVTpN3piv6lxuqVKWbdxpVWgzZZQ7G5xG9bt47WGU4BG cqLU5FiN1Kj7B8Dp1zqu0q7Ui2F91Jj8vD+lQ37kIiD6k6q1D4Pa5HMGg1530T4LgKIq fUvfZPHrGTqEqoUtBkWe6OnFUDgHDnV1OA6YX4Xg+nlVQfn33nBvPFBrNnAlZZdy+aoy oYpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=i-love.sakura.ne.jp); spf=pass (google.com: domain of linux-kernel+bounces-199169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199169-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794f32a6e71si825936785a.667.2024.06.03.06.06.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=i-love.sakura.ne.jp); spf=pass (google.com: domain of linux-kernel+bounces-199169-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199169-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7F98B1C2451A for ; Mon, 3 Jun 2024 13:04:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A83BE12F375; Mon, 3 Jun 2024 13:01:50 +0000 (UTC) Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) (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 412CF137E for ; Mon, 3 Jun 2024 13:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.181.97.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419710; cv=none; b=Aeb9dGbjsIllPDLsiZLUa3E4DwiW1RAkAorux0i91Hx+8hUK5U9U4KIHiwAg5gPoMQKDnlV66OLIc4irDjOFgaWu9y5OwYTnR9ay9udSg7mQFDI3ocjoDRQAzuwGFtkuP2tQHg4DhjNnY63C2VMkzjOkGxZdFXMsSBEEmQHxLk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419710; c=relaxed/simple; bh=GB8u12djRIME1B6PDT7eW1YyY3V8yemgIyYdDJiwli4=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=AnEUKI7ML2E0ZZ0zoxIR1IdUUYHXyW3WWLXIEz1mYGPcuqMrMmUZiIxhgvVxrVjDyzhZ3ihQpgTYn5TLXU5At0GhqhRGEDpXjFIuJzGkH1oUxQCjBtw/WuAESZMe6rnulscnMjFTFpbCYGa76KCNL+1QCLQH2J0F3XtlOG/C5uY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp; arc=none smtp.client-ip=202.181.97.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp Received: from fsav413.sakura.ne.jp (fsav413.sakura.ne.jp [133.242.250.112]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 453D1iWP085054; Mon, 3 Jun 2024 22:01:44 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav413.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav413.sakura.ne.jp); Mon, 03 Jun 2024 22:01:44 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav413.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 453D1ilx085050 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Mon, 3 Jun 2024 22:01:44 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Mon, 3 Jun 2024 22:01:43 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2] Input: MT - limit max slots From: Tetsuo Handa To: LKML , Greg Kroah-Hartman References: <000000000000de2f4f05b8942be9@google.com> <6d878e01-6c2f-8766-2578-c95030442369@I-love.SAKURA.ne.jp> <03e8c3f0-bbbf-af37-6f52-67547cbd4cde@I-love.SAKURA.ne.jp> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 --- Changes in v2: Limit max slots instead of using __GFP_NOWARN. drivers/input/input-mt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index 14b53dac1253..6b04a674f832 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c @@ -46,6 +46,9 @@ int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, 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) -- 2.18.4