Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1142184ybh; Thu, 16 Jul 2020 04:28:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxddlZFvzW3b2hophtUGEZK2u6xoef9xsbrHIa5qANwMQR1GFBWsfx5aA6zzSEHNZUSSua+ X-Received: by 2002:a17:906:dbe9:: with SMTP id yd9mr3336939ejb.75.1594898884824; Thu, 16 Jul 2020 04:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594898884; cv=none; d=google.com; s=arc-20160816; b=rp5nbyH6re+vExUXLqzRd3kcYf3F3lXt3jbiXklTYHzynMYS6nnWbFH4ewTtZB0ScH cbq602JxExf3gHcpL0k0xGMhks/iGMmJdJYRf+zp7LaPxsPEOnP8S+nrXC1CkWAuNG8M dWwwuEV1pK/HMLrsrBVZRP3wj+iWuIDndD/ZjfIYRa9UpNCS2WuLjbTCs6yV7gyrq3Cu BhDx8J4TvjC/XSDJPPJnEqW3kN6700yBIDyizcUWjMwXhiuTv0nhrnzhL8R3gVVpSgah A7RQq8rrH7teAYc6RbRQGYQehKNDbR9mNWD7TcZRh+I9xLU5HyGBJXM4I23HDB9h7tJv UXGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject; bh=1hovBSTIuZRrP99Fkzpbx2RD3Jiu/HYfuXIlk9LyUkg=; b=sxTKtya7ZfbRJAtQvmBl0mIqebxTw/UWhqGvW+nbBDrXh8sXJvDLziGVDCZStmdQXR 2dGXvOBgUS10+/dMjLo9VJefpvjHDV26DWF52A8hAMsXr2l+lbuvDOQ6wOXcdG4DSBcN d7rKRZh+fiI9s9dcrWBjCh2liplkTKHxU9LloLYx+HHUvv7aMlrgNkbYO3NmEwsoZ3yY SsdfhyiS1Zcwmf7Sa8rX7wGtIY+kaKE51hUXWU4y48aXHGFGh7Ki0Aewa65AiLiUgKV/ GWLXNDYTq9dISK7B1AyIJarrtPcrqxjefoYQo4r6kDT8aash7QpKxWZFivS00Yp7Rng1 knmg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw14si3046596edb.419.2020.07.16.04.27.41; Thu, 16 Jul 2020 04:28:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728032AbgGPL1Y (ORCPT + 99 others); Thu, 16 Jul 2020 07:27:24 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:61068 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726350AbgGPL1Y (ORCPT ); Thu, 16 Jul 2020 07:27:24 -0400 Received: from fsav103.sakura.ne.jp (fsav103.sakura.ne.jp [27.133.134.230]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 06GBRL97041795; Thu, 16 Jul 2020 20:27:21 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav103.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav103.sakura.ne.jp); Thu, 16 Jul 2020 20:27:21 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav103.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 06GBRLEi041792 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 16 Jul 2020 20:27:21 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH v2] fbdev: Detect integer underflow at "struct fbcon_ops"->clear_margins. To: Daniel Vetter References: <20200715015102.3814-1-penguin-kernel@I-love.SAKURA.ne.jp> <20200715094836.GD2571@kadam> <9e6eac10-c5c3-f518-36cc-9ea32fb5d7fe@i-love.sakura.ne.jp> <20200715151220.GE2571@kadam> <20200716100006.GN3278063@phenom.ffwll.local> Cc: Dan Carpenter , linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman , syzbot , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, George Kennedy , Jiri Slaby , Dmitry Vyukov From: Tetsuo Handa Message-ID: Date: Thu, 16 Jul 2020 20:27:21 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200716100006.GN3278063@phenom.ffwll.local> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/07/16 19:00, Daniel Vetter wrote: > On Thu, Jul 16, 2020 at 12:29:00AM +0900, Tetsuo Handa wrote: >> On 2020/07/16 0:12, Dan Carpenter wrote: >>> I've complained about integer overflows in fbdev for a long time... >>> >>> What I'd like to see is something like the following maybe. I don't >>> know how to get the vc_data in fbmem.c so it doesn't include your checks >>> for negative. >> >> Yes. Like I said "Thus, I consider that we need more sanity/constraints checks." at >> https://lore.kernel.org/lkml/b1e7dd6a-fc22-bba8-0abb-d3e779329bce@i-love.sakura.ne.jp/ , >> we want basic checks. That's a task for fbdev people who should be familiar with >> necessary constraints. > > I think the worldwide supply of people who understand fbdev and willing to > work on it is roughly 0. So if someone wants to fix this mess properly > (which likely means adding tons of over/underflow checks at entry points, > since you're never going to catch the driver bugs, there's too many and > not enough people who care) they need to fix this themselves. But I think we can enforce reasonable constraint which is much stricter than Dan's basic_checks() (which used INT_MAX). For example, do we need to accept var->{xres,yres} >= 1048576, for "32768 rows or cols" * "32 pixels per character" = 1045876 and vc_do_resize() accepts only rows and cols < 32768 ? > > Just to avoid confusion here. > >> Anyway, my two patches are small and low cost; can we apply these patches regardless >> of basic checks? > > Which two patches where? [PATCH v3] vt: Reject zero-sized screen buffer size. from https://lkml.kernel.org/r/20200712111013.11881-1-penguin-kernel@I-love.SAKURA.ne.jp [PATCH v2] fbdev: Detect integer underflow at "struct fbcon_ops"->clear_margins. from https://lkml.kernel.org/r/20200715015102.3814-1-penguin-kernel@I-love.SAKURA.ne.jp