Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp305122pxx; Wed, 28 Oct 2020 05:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLcH8nth111ImgwOtZJjiJfDjVNnv1TR0KNDzNcWDgXEaXI4uffxkdAoE0RXRMMhXil4IZ X-Received: by 2002:a17:906:f247:: with SMTP id gy7mr1938102ejb.48.1603888197069; Wed, 28 Oct 2020 05:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603888197; cv=none; d=google.com; s=arc-20160816; b=tfOwo6omQY/eHgLHDANEumKYzUU2iGbNXVeednSYUXoHd7OxaOokRfCLbFhLKBVN0S q0kr5j82JgM+GwvLRqaFB1k5QGVld9l6l0EOBxIB2rNWhZkbA0zV/tSF1vf/48XZmZM9 WWZSHpusVf2Oms/213IWfWz+ySG3W7q4gBNwMa6eZZyuHVgAu+qfzL9vqGwE2lRTTEDV xQMODnQP33eVtYidcE7VfCNIi7NdGPg+199bjDj0sF6Ja8TiGgzwP/zM7pF1mdlv34vi XtINZ5A0rIErQk2ieOrtM8ohndUA2R1ow6QmiEkhfOTmWbEopCwohbekjVCk0tZtoPgp 4BTg== 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=IEeaz7h5yTRS3gUgD0iUELFOnHr090ynONegv+gJo0A=; b=Dy9Qs0sS+IkBJUhs+TxcVDWCL9h9Y/VZavY0v5EgH78g725ajp69oF0k8K2QSlX4Lh Qv/Sd8kmOmyZTJNunYN59RYXsM0IJRlAszaiSkgH/z/y7owwrf5bnOEc7u9d7PbBbHKh tWMUi2gUqFZI/RC+EQGPG7R3BAydlTkej/C+8UePO8GOCz8gNKkojo2uuhNFW8f0ICGy APC80HFQeP3ylrJGpnbqDSfSciEMlOBmsJ5Eb4H26EqAAxr50gBM5yU/mx/21VG5/mPd pow7x2amKmCvqMxma3t33IbMtaaRDicicypHIpBM7YqNgrmBu5qd5WgNI8DvKIlXRjTC EIPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YtK3Sd+O; 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=fail (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 b6si3402013edu.343.2020.10.28.05.29.35; Wed, 28 Oct 2020 05:29:57 -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=@kernel.org header.s=default header.b=YtK3Sd+O; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1797034AbgJ0PVN (ORCPT + 99 others); Tue, 27 Oct 2020 11:21:13 -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 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 [ 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) -- 2.25.1