Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp392673ybh; Wed, 15 Jul 2020 04:58:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuQAKYSb+fxh47LIu3VkL7VqLMvGwmtOFLOS2ZjRfOVt0tut3WQTBsJYF3idiiMpTWya25 X-Received: by 2002:a05:6402:c06:: with SMTP id co6mr9233312edb.142.1594814310232; Wed, 15 Jul 2020 04:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594814310; cv=none; d=google.com; s=arc-20160816; b=UP95jkaDxLQ3NSW2xL/D538Es/edxhn8tPiUrWeUW9FA7sLxcDW6zZrJrwO1K0hMls AWQKOE8ynAg8J+f7POAqhYzhU6UHPeJW3pesGH4NH0G129bO49nUVHmOlia+MESC41VJ H5IE774YbkZjHQavCWff5KaKkGDpaBrgjpLbPBFq1I8h56DF4b0JYkz3Ezd/oZ/Vpf3g oo15DItT+7N7Rcy76ttFTvCEl0V0AgRZwnlGk1/dGPaCrXo2XDVOgD3E6FurTfIuRPSx bCrJwZme6MHJuMu4C8bsK1J379ZoAbiOvSDTregJRRvvlEkLlZHha6unlHTODBaX9vLV Kdng== 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:references:cc:to:subject; bh=Uw2DnyMEdl6FKXdiGdg7osDT2pDsinh5h80MXinZDgY=; b=rUdWDtti8AyQOTc0ma2XtAgKf/isrBeNCmh590acjvopHwNfx0TBGjLx9QRhfF6eIQ DhBw3XEQLNI+nEBlVo+BebWYDYIlugZXQ+fLutLJuVkqBIb+dTxQH68RsIic13/L05y9 DHDh5TTPzTFr3fLJSMZImJOtILkOCPqdXw0QRxN0GPfHD7r4OxczY4VOlPWPB5859AbK WpaiL25K8zt+4NlfWf3dmxMGzCLpiYAnPOzLk93BoGoGFLHgk4ohZcr8vn/9WXP++69T Dptc4l7kAEquugXbAR13iYL3C8jfXaY9eyQ5ofA9OYvfTTs0LHyOZ070WF+x4jGhOnne 4OFA== 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 d5si1117216edq.206.2020.07.15.04.58.07; Wed, 15 Jul 2020 04:58:30 -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 S1729371AbgGOLRv (ORCPT + 99 others); Wed, 15 Jul 2020 07:17:51 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:61626 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbgGOLRu (ORCPT ); Wed, 15 Jul 2020 07:17:50 -0400 Received: from fsav404.sakura.ne.jp (fsav404.sakura.ne.jp [133.242.250.103]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 06FBHk8c074032; Wed, 15 Jul 2020 20:17:46 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav404.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav404.sakura.ne.jp); Wed, 15 Jul 2020 20:17:46 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav404.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 06FBHk6A074027 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 15 Jul 2020 20:17:46 +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: Dan Carpenter Cc: Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman , Jiri Slaby , Dmitry Vyukov , George Kennedy , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot References: <20200715015102.3814-1-penguin-kernel@I-love.SAKURA.ne.jp> <20200715094836.GD2571@kadam> From: Tetsuo Handa Message-ID: <9e6eac10-c5c3-f518-36cc-9ea32fb5d7fe@i-love.sakura.ne.jp> Date: Wed, 15 Jul 2020 20:17:44 +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: <20200715094836.GD2571@kadam> 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/15 18:48, Dan Carpenter wrote: >> @@ -216,7 +216,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, >> region.color = color; >> region.rop = ROP_COPY; >> >> - if (rw && !bottom_only) { >> + if ((int) rw > 0 && !bottom_only) { >> region.dx = info->var.xoffset + rs; > ^^^^^^^^^^^^^^^^^^^^^^ > > If you choose a very high positive "rw" then this addition can overflow. > info->var.xoffset comes from the user and I don't think it's checked... Well, I think it would be checked by "struct fb_ops"->check_var hook. For example, vmw_fb_check_var() has if ((var->xoffset + var->xres) > par->max_width || (var->yoffset + var->yres) > par->max_height) { DRM_ERROR("Requested geom can not fit in framebuffer\n"); return -EINVAL; } check. Of course, there might be integer overflow in that check... Having sanity check at caller of "struct fb_ops"->check_var might be nice.