From patchwork Tue Oct 27 13:55:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 312665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33195C5DF9E for ; Tue, 27 Oct 2020 15:18:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF16F21527 for ; Tue, 27 Oct 2020 15:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811922; bh=gso6STyjOqktB9BpQ65BQqrnebgWWcHpYowKIcR6/BY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RiwThNbicNLbUWB2CUY5kuLDat0axjJh2lLy0UbMQF91+ygX3oTV6lIyA9BmWZ7Tx VJChDqNs9coy71d7NC0qwQLMPgMZG0NqdrqSlmM+CkxHUxUq7Nxng8pQFAgnsMyfl/ 6boH5g+u4D5Dps0J4I72iF3GRLEYf1TY0jwlzaDg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1796446AbgJ0PSl (ORCPT ); Tue, 27 Oct 2020 11:18:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:52642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1796144AbgJ0PP4 (ORCPT ); Tue, 27 Oct 2020 11:15:56 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2103220657; Tue, 27 Oct 2020 15:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811755; bh=gso6STyjOqktB9BpQ65BQqrnebgWWcHpYowKIcR6/BY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YtK3Sd+O3JL9iI2/T4bZwahyqAdwOHR9O+4t3BvTIiKB5+rO/35UjIYQq+xpYl0qe Zeek3AbjVrm44JVZteINdI6tUj77bQ6lpm9guslkC0e4XckZiQIAAHkdLKCwmz8Ypg UYjMdTMLY1bDFVoKczH4OZEuYvQafCCmJ1naFjvA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, George Kennedy , syzbot+e5fd3e65515b48c02a30@syzkaller.appspotmail.com, Dan Carpenter , Dhaval Giani , Bartlomiej Zolnierkiewicz , Sasha Levin Subject: [PATCH 5.8 605/633] fbmem: add margin check to fb_check_caps() Date: Tue, 27 Oct 2020 14:55:48 +0100 Message-Id: <20201027135551.195819272@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: George Kennedy [ Upstream commit a49145acfb975d921464b84fe00279f99827d816 ] A fb_ioctl() FBIOPUT_VSCREENINFO call with invalid xres setting or yres setting in struct fb_var_screeninfo will result in a KASAN: vmalloc-out-of-bounds failure in bitfill_aligned() as the margins are being cleared. The margins are cleared in chunks and if the xres setting or yres setting is a value of zero upto the chunk size, the failure will occur. Add a margin check to validate xres and yres settings. Signed-off-by: George Kennedy Reported-by: syzbot+e5fd3e65515b48c02a30@syzkaller.appspotmail.com Reviewed-by: Dan Carpenter Cc: Dhaval Giani Signed-off-by: Bartlomiej Zolnierkiewicz Link: https://patchwork.freedesktop.org/patch/msgid/1594149963-13801-1-git-send-email-george.kennedy@oracle.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/core/fbmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index da7c88ffaa6a8..1136b569ccb7c 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1006,6 +1006,10 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) return 0; } + /* bitfill_aligned() assumes that it's at least 8x8 */ + if (var->xres < 8 || var->yres < 8) + return -EINVAL; + ret = info->fbops->fb_check_var(var, info); if (ret)