Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp998283pxb; Wed, 1 Sep 2021 14:54:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVugRYgmggEhsPCG1pVjdbq0hpmtsq650IeUV/EVhdv79kwS0VmMQxlQjKYtWQHe4CHUN0 X-Received: by 2002:a17:906:1f81:: with SMTP id t1mr1767099ejr.510.1630533277954; Wed, 01 Sep 2021 14:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630533277; cv=none; d=google.com; s=arc-20160816; b=dgEyib6rK4NGPRnMB7moDDYoJ2xKE+IZMdXmIffZkXT/8WzPOi/h3ha0Cuab6zZLBx ifLjip1+W08DcBURk6tmQfeVZJQq8rjK5C6YKnV2wk4C/ewymt0n4FzFIv6J1we6fYho Dckqxm8v7eks+tmz47tfh7+qN5uYF9LYaZq/RYNa5nAsL7peXZLWo6ow7nBzmLkxI1Le a4RishtgM2xl8PTygfYFU3areeDAy5vQhySUb9hju9E2lo+YZ8/iHbN2mCNoYRk1nJIt HV+8rV134NQ3dBDV4f5d0hvqcek3BZA4Vj/PuMm8TgbF1YVw1Q90CMuD8A/0DUTKMPWy r4og== 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=IxlFFelIxXstUZqJZSJFqFlLAuCbVVxqVerb9vROWHE=; b=Pntyi6CpktS7VF6iW9E0aH6mLNOUtLFUFrCh2JbgyRzB5OXVx4HlqxSJgb4xaUEsO7 cRbTOhDs6B6OAx/qI9j6EyOF197h9HclF3uzGsozbPHlQ0bkzwRTqhPkxXNFnsq+wHQh NC5gzvkgeTLpkUDp3hxjFKP9obxcGIG2NzoNpGan0QW1I8jtkrMD3sTCejXdkO0HTpHq mdzKz1Il6G0OPImzEuPnIAdO98dlH/0gosX0SAKeYFaXmB74Do1wBgRwemxUm5mmNHXf WW/rkig/JaLipNA4sn1uP1YACaptJE8Q86tiXViJZh6JTUnwTqOUDIaqHRuvhTppIMBv wKyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VAQbBeL5; 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 a2si900edx.80.2021.09.01.14.54.13; Wed, 01 Sep 2021 14:54:37 -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=VAQbBeL5; 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 S244604AbhIAMaF (ORCPT + 99 others); Wed, 1 Sep 2021 08:30:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:59364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244443AbhIAM3h (ORCPT ); Wed, 1 Sep 2021 08:29:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 143C161027; Wed, 1 Sep 2021 12:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630499318; bh=Nfk3RPskRdoiN48+28zRy2RotGVeE46kGkdT327DbxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VAQbBeL5Y1++IyVr7FkPFJ7LxLYqx3D2k00hFOflYgqS9/U8ZnrQJaYOGCXp+mG9X rN73GTm1fO9mzh/K4AuucY1ZAQQ7O6wdBK81P2Ul4IHsdHUreLNqEBaLHXmt5bG6NV j7TsnZ/DTtAUZ++QKeHPdEjnnhCXnKoIv3o14lU8= 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 Subject: [PATCH 4.14 20/23] fbmem: add margin check to fb_check_caps() Date: Wed, 1 Sep 2021 14:27:05 +0200 Message-Id: <20210901122250.435100302@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210901122249.786673285@linuxfoundation.org> References: <20210901122249.786673285@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: George Kennedy commit a49145acfb975d921464b84fe00279f99827d816 upstream. 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: Greg Kroah-Hartman --- drivers/video/fbdev/core/fbmem.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1003,6 +1003,10 @@ fb_set_var(struct fb_info *info, struct goto done; } + /* 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)