Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1121552pxx; Tue, 27 Oct 2020 08:44:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjMw/6uju7sgN+A+yvZ9HJx/1vfZ2qFm3J1hbbsYAHYlcYvjN13xTo6DVQpdJZRcS1VHoO X-Received: by 2002:a05:6402:396:: with SMTP id o22mr2860262edv.361.1603813477847; Tue, 27 Oct 2020 08:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813477; cv=none; d=google.com; s=arc-20160816; b=iO+YM8zmuNg9aUCu1BaSHmrD/tKedFO9u7VMG+ga8K3KAoedZ2sRKPG9PfYMP4NwlT dcSUVqQo1Di0+HKjwM2JE6mTs06+elT4tEU2TkwSWgiCJxU/mP+unvfEruhluVveSk53 6piVAscIsK+UWye6mXYTSQaXY3z8ggvMrkl5jNkLxpBZ7eo9eDxYvJTHM/itj+i4atI6 4DCGtLF5QsDaaM/BzKRfzBDlqxilWkTcFVIVjecF4ZzX6xaBrXn5QxKGQ7wE6lesouCv dScUQl7QgzF8NI1W5jAf1QhEs43v5t9koSjQtvqDhxwBe7CzqEtQo6s51XtIAhbSUE0y q6mw== 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=643yt7521UtFepas1c8od+bGoOo+cKjcXmgLl4gZ9r8=; b=SwiLrquEdut7xsTmk1nxcge2qD+sJnJztOefeehl1wBkADqgxCd1eMEAL6uKG0w5L2 jZZ5BqMu/4zPQ8SgrAqo8+KQ6XR1zQcReEmVMXKcmckCJIAWDUSaev1a9PFax6yv/4Dq KZV50H4WHGgSPGeTZjnNYa4mz1/IyIVLjWD7gjtSqz3e5BL4pKMTu4LSMYE68s/KIP29 Q0txk/ynkHY83scG/JJWvrLSQxfJkC0w6QnS/VZJFG+DoWOEFhUfYDpAaT4Q4Bus9NmS KpBq9VNtRW5Ltc4yhypaIv6JPMIwkXl+9qmLp0shLFDT6UQmNd/afNIr6tICiRMFFmfA uH+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SLHYWyg2; 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 bm2si1165255edb.310.2020.10.27.08.44.14; Tue, 27 Oct 2020 08:44: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=@kernel.org header.s=default header.b=SLHYWyg2; 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 S1765125AbgJ0Ork (ORCPT + 99 others); Tue, 27 Oct 2020 10:47:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:47422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764928AbgJ0Orc (ORCPT ); Tue, 27 Oct 2020 10:47:32 -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 425E0206E5; Tue, 27 Oct 2020 14:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810051; bh=MoBhK/7Ht9x5KVldjiEmNJ4N0GxtlmSpLJsWAMgpVXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SLHYWyg2tMuOPktPZmjScuhMd8mIdA4FM7cPUEqrr52QVN5/vGr+IlPxMBT2ETRor z1//rLH0PdyOfERP6hqwLqhUuSPC1XxOuAFiguF6kTLcmLb0GIeOxxu28uKuyfbHDf OdMUpgvBxAuhYWKIaxu9XRVUpAou0q9krEUOt8ws= 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.4 385/408] fbmem: add margin check to fb_check_caps() Date: Tue, 27 Oct 2020 14:55:23 +0100 Message-Id: <20201027135512.858127619@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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 97abcd497c7e0..bf76dadbed87f 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1001,6 +1001,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