Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2563893lkm; Mon, 20 Sep 2021 18:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmxelmxncf8EUeNUz1zW8X34aCFTl46af5PrugbCU4IcE7z4N23BSE5hssu0Amt/Mvk+uI X-Received: by 2002:a6b:6a14:: with SMTP id x20mr20423478iog.177.1632188980781; Mon, 20 Sep 2021 18:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188980; cv=none; d=google.com; s=arc-20160816; b=qGR7pCehpyyCwEqLMTAYFDbLwuAz1ucl4ej7Epdi+ds+MfS92h9+qfGFRmrlODX/gH M/I8/ArwqTAsYM2bltgpArhu8ur+pEXSSh7RxP8sS1lTqZX8cPQxFu6UugBxZBjjdjgM IY+scHKjbNbeLArVifJTXEZbH//RWaR5p/KhlbQRSM+ozM7wWVrSMH6CekC75FwlqCxl TseA96KU1za/26d05PINzFZMN9I8VvlCaoMzeU8K7K0NfQG52P1Wrm+DXmVGegv4PjM/ CQ2ROJOkcdBbg2lCVapKcDlABU7hscesCkMBfOsean7FBP4Xe4aez3lbZsVYHQdiIfg8 wT3w== 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=CwiAwp9XI/Q7yaB88tVQryNuNCr6UyQRATLyYo/uCo0=; b=qTL28AtvMANcPvBor3Jy/LRJohxatSrRPVgjjA/wjbI3ODRTKOOzNQHmM93qF1nQIm jdU/TVCyoJYGSNBos6I3Ydv8gYcCaMtWrboRnFMRobZM6Jui3EzCtnf71YAmELfRt1Xc 56ukwgjI+YPU6L6EFFwNoHQlDxpDbRCa/5/zQc5ai0IwZcR4COoTOBqVRpeDD/y7i3E4 OHaaJnitxZHnQYtc/n+DRSLw2iW+9d+/FJfHUMwW4xFTPT6Q84RLFcMgao/NBH7S18pp mhSVEZVhAwzOeg9wzIYqMNEwt9G/to/XxOdD83eHEqmFTuAIacTd05EWPefj8zelR3NZ dMbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KvYeGAoS; 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 z11si8750469iom.108.2021.09.20.18.49.29; Mon, 20 Sep 2021 18:49:40 -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=KvYeGAoS; 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 S1347094AbhITRna (ORCPT + 99 others); Mon, 20 Sep 2021 13:43:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:48098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244992AbhITRlQ (ORCPT ); Mon, 20 Sep 2021 13:41:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB2CB615E5; Mon, 20 Sep 2021 17:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157707; bh=QAkiW0j9FDC2GK+4VwoGQezOxK8A7xV6DVuPijxvWas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KvYeGAoStSchHlmb8ng1UoFjpPmnuFOyZ0TML84i7kc5gV3T0gwPwTjdWWbzMcbnA NOxiHZkPsLtlW143V3+gdmttCiG6VGvKxgh7mkLIU4qULMeS7xcKnJCZWxHZKQz/Zp 3x60heGNcxw75jD1nHyvpce8KFwSrXkMBtN+rinw= 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 4.19 115/293] fbmem: dont allow too huge resolutions Date: Mon, 20 Sep 2021 18:41:17 +0200 Message-Id: <20210920163937.196443554@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@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 @@ -971,6 +971,7 @@ fb_set_var(struct fb_info *info, struct if ((var->activate & FB_ACTIVATE_FORCE) || memcmp(&info->var, var, sizeof(struct fb_var_screeninfo))) { u32 activate = var->activate; + u32 unused; /* When using FOURCC mode, make sure the red, green, blue and * transp fields are set to 0. @@ -995,6 +996,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)