Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4149924pxj; Tue, 8 Jun 2021 07:36:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkX8tt8EtEnvB/Uq7mo7hg2vi/qBTTNE/FuZdLdcj7uquwSKbOc2I33Ewn/bRkiM4q3obU X-Received: by 2002:a50:a446:: with SMTP id v6mr26118396edb.254.1623162994229; Tue, 08 Jun 2021 07:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623162994; cv=none; d=google.com; s=arc-20160816; b=VSl1MiZd1g9MuKx57Bpu2X0kJ4XLtrzZ6Y7GD59MxzQT9bCp9KCC6yddXY+MScyn36 6fQP0mxBc7jIP223N9+C05ykgsdmEl2/d7sBzcQwG2ALK7PdcMMqx/qRcmx4zKUqYU+N r1NE4+vob1wL7eo/iP3BH62pYVhsQeUDWTYa1Fz4OZ3AykICp9n/hkrwqpfsp3MkZmHi f+ROv0SsujSLepEP4tN3rZ7hnQiOgqqi4+ZnHZl13tSMnPWL9OquOZCGPWxGaXfMMfIz xaIxLNlb+3FJ4EgkR0rD/kLT2MpAO5LJbapxkpkSi+TaKVRE2QdBcpdscQb4Njar3EEW HdXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=85gfhyhaPICE6JruxReW5bLHIP9PAbtsoqQJ5UZBDsk=; b=JEW0Th+Vm90nu5+lpUimSafmOTi85EhPPScvZsDjfKHoa/B7HgPgHIOZ0xfmgoD6zV 2NvAMSIVME2bvFoBv78F8wXZxaoRAX9GR4Ryk1poYGV+G1Z7BskAQi9EEy056KcpiMQh 3wgUuxkMSuC5PdK4mpdUNg8Nd7fI3G38OeAVe/OWbSRIymE1+9rKH7Mg6OtXoQ3XxqI1 OoC5hJjgQpQpKVMLsxOsfdEQ5noXCMSAg8zFfK4RWKTzikJB+QXII/FBW4VWo7V2Ih8I ufh4Plp/PFVPgBy1JmSTIgTYSedw2ArkNf+LWGqcGsOlgYg9fOcIDH05HXQktE1zKaPo s10Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sp7O2Zt6; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ka11si16222177ejc.367.2021.06.08.07.36.10; Tue, 08 Jun 2021 07:36:34 -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=@gmail.com header.s=20161025 header.b=sp7O2Zt6; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233374AbhFHOeK (ORCPT + 99 others); Tue, 8 Jun 2021 10:34:10 -0400 Received: from mail-qv1-f53.google.com ([209.85.219.53]:38632 "EHLO mail-qv1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232911AbhFHOdy (ORCPT ); Tue, 8 Jun 2021 10:33:54 -0400 Received: by mail-qv1-f53.google.com with SMTP id t6so4988192qvp.5 for ; Tue, 08 Jun 2021 07:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=85gfhyhaPICE6JruxReW5bLHIP9PAbtsoqQJ5UZBDsk=; b=sp7O2Zt681hV3TBbSN6U5r0xwrEt8LVni6I6bimoBocl22397YlDqjWWL6QkcTnhl1 Dp2ihHVAROAhoZWqnfxUYkf9jtNVbFkMYhi61RFrUZh2T6W4e2ne7d0roVa2fLrEAsmX NBE6MiVW+q2lUCQkbaqYdKeY6SCjE9y+cvegAmFSunVl8aD2G80BueXbwSozW0s3+XYG A4lJxnqwn7cLO2z2leDODvv0r4JU3nxpA3l1QE3S/Aw+X2LWEYB7LW1YtK+o/f8d+y1l zRS2MptD4bYS5DF1Zqk0FUefR8T9D60GVlelQ5da9juJuOSBMO5KrabFzL94qDX5Qjck 94tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=85gfhyhaPICE6JruxReW5bLHIP9PAbtsoqQJ5UZBDsk=; b=XKQDs7/TdUJYGBdh/0IUnguu1p09nkOP0uO6WCSBA/VDgMzbwlMjJAP68EfgULNEMB KmKQUgrnhQK9ZxgTv041Ih5UW40MByYXCOdXZcFcEJmylkDBuTmYk2TYiODwJmLoSshd 0fgAI93GDweBlq+9XEL9eHoHKAQR9pXa7hEFbt5kTKTy6G0QjqbCA/tgIwyO6ZXBR0to ArG13x7F0d68t41N5OzupzHUihDq8H5oRMil1Z3PrEql0ziATslS7IvkPdWx8UstB/Mc /f1w7Bajb/33VSuzztgbMj74l8nsjtVzTGQS339M1M7HQt1Lp4hc0ZVRFfKsRPMUvl+i cdgw== X-Gm-Message-State: AOAM532x4OHOjoBykXFMjJpF9qpWHJoas0RhVqhZ36wThcAtG4R0KFvs ltm7Ny+cafwEahu93FdThx0= X-Received: by 2002:a0c:cd87:: with SMTP id v7mr5514851qvm.42.1623162661548; Tue, 08 Jun 2021 07:31:01 -0700 (PDT) Received: from ?IPv6:2804:14c:125:811b:fbbc:3360:40c4:fb64? ([2804:14c:125:811b:fbbc:3360:40c4:fb64]) by smtp.gmail.com with ESMTPSA id o10sm12219837qki.72.2021.06.08.07.31.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Jun 2021 07:31:01 -0700 (PDT) Subject: Re: [PATCH RFC] tty: Fix out-of-bound vmalloc access in imageblit To: Greg KH Cc: jirislaby@kernel.org, linux-kernel@vger.kernel.org, syzbot+858dc7a2f7ef07c2c219@syzkaller.appspotmail.com References: <20210531124713.9048-1-igormtorrente@gmail.com> From: Igor Torrente Message-ID: Date: Tue, 8 Jun 2021 11:30:58 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/4/21 10:19 AM, Greg KH wrote: > On Mon, May 31, 2021 at 09:47:13AM -0300, Igor Matheus Andrade Torrente wrote: >> This issue happens when a userspace program does an ioctl >> FBIOPUT_VSCREENINFO passing the fb_var_screeninfo struct >> containing only the fields xres, yres, and bits_per_pixel >> with values. >> >> If this struct is the same as the previous ioctl, the >> vc_resize() detects it and doesn't call the resize_screen(), >> leaving the fb_var_screeninfo incomplete. And this leads to >> the updatescrollmode() calculates a wrong value to >> fbcon_display->vrows, which makes the real_y() return a >> wrong value of y, and that value, eventually, causes >> the imageblit to access an out-of-bound address value. >> >> To solve this issue I brougth the resize_screen() the >> beginning of vc_do_resize(), so it will "fix and fill" >> the fb_var_screeninfo even if the screen does not need any >> resizing. >> >> Reported-and-tested-by: syzbot+858dc7a2f7ef07c2c219@syzkaller.appspotmail.com >> Signed-off-by: Igor Matheus Andrade Torrente >> --- >> drivers/tty/vt/vt.c | 12 ++++-------- >> 1 file changed, 4 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c >> index fa1548d4f94b..1b90758d8893 100644 >> --- a/drivers/tty/vt/vt.c >> +++ b/drivers/tty/vt/vt.c >> @@ -1219,6 +1219,10 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, >> new_row_size = new_cols << 1; >> new_screen_size = new_row_size * new_rows; >> >> + err = resize_screen(vc, new_cols, new_rows, user); >> + if (err) >> + return err; >> + >> if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) >> return 0; >> > > But now if any of the checks below this call fail, the screen will be > resized and not "put back" to the original size, right? That could > cause a mis-match of what is expected here. Right, this will probably cause problems. :/ Thanks to point out, I'll work to find another solution. > > thanks, > > greg k-h > --- Igor M. A. Torrente