Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1875933pxb; Mon, 13 Sep 2021 07:21:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqAguHTIgKJzmHc2YuhybrO+NSQw7tUE5zluZYn9Apd3rBFXMoKhJNHhwoN5G0w27Ctrqk X-Received: by 2002:a05:6602:2c0f:: with SMTP id w15mr9642145iov.106.1631542918452; Mon, 13 Sep 2021 07:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631542918; cv=none; d=google.com; s=arc-20160816; b=cAtEEPlOthpGaJdM7anxF36h62DnEd3UGEDVYFgRBIJmgcs+DPRrtJnA8SXLEMKb7J 3PNpkHIu52kWNx0vIbZD69KgwY72EaRLh2j2hOGfBohc+FrIW/SHZsE0X9CW93tXrpNN bBdsbVriX+9Kh1F3m6DMJiFEgBO0gIipnoGco07qEsA3UTYH3TyX7JLwjzizTJkOin7H bT3y/lSiw9J73L1/G1Adugdt+e9W1kkKOxdi5xDsa+7KwNM2t0L0a+sItnUYiOkWrGy5 evKjKoI6kHFuEwKoWJ0TUymCXZYMyGOWn0dq6FMjr80QDHji2r/pYG82r50CqMGwAgHV 7hUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FNfF0vj/bkHTJGzxYtLvKR73eljfAUbQ6Bxb0wXZTcw=; b=wX18/KYfUHAy8iDh6SGn7pLB3CIBDEPz93JEzpFWY94He5C7T4oEDcsnujFjlKWz3z MccqIM6kJ3oLJDpsxsp19fPE90kjuH/dtekWPj0Uytgr0BbegOCqGTakIGFYiJ7PwGKY vU8BlUyayj4TmrRRc9y6XsjmZkKDomLRDz5K0HRegDgcHVrG4ELqIuHzbI6fd8Nwz2jP hxgkRxBz49BTxzRO1c4n0cZZ53mlTvhYNgsGe0Kj8tTIBegMJO3VEBZ66oxnO8JypxEN LKOlJbbTiYPIhfsv/ASxcL91ysaRW4YoCWc2pDKG3fAc073kxKWer8kXC1PVZybRJXs3 8Q6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RtTs4o7Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si6610719jaf.0.2021.09.13.07.21.46; Mon, 13 Sep 2021 07:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RtTs4o7Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346215AbhIMOVS (ORCPT + 99 others); Mon, 13 Sep 2021 10:21:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:37126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343581AbhIMORM (ORCPT ); Mon, 13 Sep 2021 10:17:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4D2296147F; Mon, 13 Sep 2021 13:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540695; bh=/g+trBMoQm5LAjyoHsSB+HdF4wGta3FusR7hgMEIbGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtTs4o7ZUKbPLdHec/3ck4PfZYihrNHUf+LD6QcMKgYXdVkrBOUFH0REWf3Cmxj1P vFDri31mLFtU/qKHJhqGgGqyPNgXmgcSpq7lWlbZ6Irbvnhf6zM/19OJM5lP+eAhYh 6TVACyCbHRw2fsQ24H149oiXd9VXvL9Z022133vE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Tetsuo Handa , Geert Uytterhoeven , Daniel Vetter , Randy Dunlap Subject: [PATCH 5.13 297/300] fbmem: dont allow too huge resolutions Date: Mon, 13 Sep 2021 15:15:58 +0200 Message-Id: <20210913131119.388860528@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tetsuo Handa commit 8c28051cdcbe9dfcec6bd0a4709d67a09df6edae upstream. syzbot is reporting page fault at vga16fb_fillrect() [1], for vga16fb_check_var() is failing to detect multiplication overflow. if (vxres * vyres > maxmem) { vyres = maxmem / vxres; if (vyres < yres) return -ENOMEM; } Since no module would accept too huge resolutions where multiplication overflow happens, let's reject in the common path. Link: https://syzkaller.appspot.com/bug?extid=04168c8063cfdde1db5e [1] Reported-by: syzbot Debugged-by: Randy Dunlap Signed-off-by: Tetsuo Handa Reviewed-by: Geert Uytterhoeven Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/185175d6-227a-7b55-433d-b070929b262c@i-love.sakura.ne.jp Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/core/fbmem.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -962,6 +962,7 @@ fb_set_var(struct fb_info *info, struct struct fb_var_screeninfo old_var; struct fb_videomode mode; struct fb_event event; + u32 unused; if (var->activate & FB_ACTIVATE_INV_MODE) { struct fb_videomode mode1, mode2; @@ -1008,6 +1009,11 @@ fb_set_var(struct fb_info *info, struct if (var->xres < 8 || var->yres < 8) return -EINVAL; + /* Too huge resolution causes multiplication overflow. */ + if (check_mul_overflow(var->xres, var->yres, &unused) || + check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused)) + return -EINVAL; + ret = info->fbops->fb_check_var(var, info); if (ret)