Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4312611pxb; Sat, 5 Feb 2022 09:32:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOxy6dQPkL4cxehmnWq2on45rTkoTIQNKw82pTZuoSJZRPtaruTaaOY1WGXqpzne1Aalvk X-Received: by 2002:a17:902:d4c6:: with SMTP id o6mr8670679plg.83.1644082358815; Sat, 05 Feb 2022 09:32:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644082358; cv=none; d=google.com; s=arc-20160816; b=FfkYz8Zd29c8UCJU8Ek1Nlpsm9Cy9m+8MMxyfPvqrygbg4TZI4R92FrcPj4hb6U8HQ 5e5cMOQyUslgVgoiVVhFqmkv6KVidyiTBQ1EBDbj8TKjP8CyyV60KTQLWAIpK1Ro5hEn PpQzS7EdmailJLqkE4DwqeKBxQ7xldOoi48fbOR1znSzv/zKe+E6RbU4kaKP4YHD9nhc ZuFoYEIcE8kUcpUJ1lPBih/EA19kMbBnTZJwzCKH9Yq8wexV4CWwwwN3o+xP1Ejbrzi8 nZnt428jxQzMivDrUI+BhpGyl+EGCkzUuMoGlk6nggeXsWR5CFd+GLpXTUZU9xqFroaB F5Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4dAkXmsVvrI1KuLL/chqCTg7Uy90qYoP8RQL94Xf478=; b=yiYUjaBX5jG0wI47mARhSws7Hy6B5gb59Z/FxdpxaWqgBsN5DlvLs2x7Kn9UPw1uc1 pYkSDgfdGwr98scqmuF2Gr7vrD/LqmFREMJm8QsMWHjZYvma4I+m5lVdRVW56tlP4v+E eXnK1BOaJK64uMW3wSBKngml9wXf+GNNOkngOZKyzcQLxS6xQ47hrk8/veXjG/l7HCu6 qv7DCIqEGm/28qtV1JGXDNYmuiUsooQxWgNvJGYCwvQr+l8+HOyf6pOhd4j8zQDdHyuL 8XiAfX8Qd7MVki/sdSSejS3wdqlbMWK7tcJpDKE5G/Bfxnt+8PFytFNNiI8a/cBBr5ay +hzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=UgorUlyf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3si4485813pfw.53.2022.02.05.09.32.25; Sat, 05 Feb 2022 09:32:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=UgorUlyf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346294AbiBBRhJ (ORCPT + 99 others); Wed, 2 Feb 2022 12:37:09 -0500 Received: from mout.gmx.net ([212.227.15.19]:55535 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiBBRhH (ORCPT ); Wed, 2 Feb 2022 12:37:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1643823377; bh=nuthtyGtekh1QQHr3+HkARKWphnDMvJGe0AUmpkrc7A=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=UgorUlyfz1L7WX1XD13Rv/Kw0rRnC9vqv2dHLJvt/P/wv1/f+JJtRmZjPr04+y3pj FIQDAjc1uBefyweGFLCsd0LpgYX8qFACQ9ZHgdeGgMn5hNN+rfopzVyDjBsmgPYdqo pcxVJwU+35jRbzkqIZdGBMA/Jx3omzQ7H56ifRck= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.163.171]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MWRRZ-1mi2Bu1TXH-00XvtJ; Wed, 02 Feb 2022 18:36:17 +0100 Message-ID: <882bfe4e-a5b6-2b2c-167b-eda8c08419e3@gmx.de> Date: Wed, 2 Feb 2022 18:36:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] fbdev: fbmem: Fix the implicit type casting Content-Language: en-US To: Sam Ravnborg Cc: Yizhuo Zhai , Daniel Vetter , Matthew Wilcox , Tetsuo Handa , Alex Deucher , Zhen Lei , Zheyu Ma , Xiyu Yang , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20220131065719.1552958-1-yzhai003@ucr.edu> From: Helge Deller In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:VX0YPkte7zZH09cDCCwSMR6sYdUsNWLLA8YgeJOkgJgQF/e0Hdr ulgvAE4VODuPwDya1YKqtltqlyixywIGsh3K/ABDEZWxl2aUbWw7MesYYL0dyZsEFoyBzY4 fMXhQKFj6nB7PIZMmz0F44mQGcF3UKOml4d/JksZQguJNYL4ityt/xqwcFWn46dkY8dISrc k4ju0v0v+e5pmBFX/T6UA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:S5DAjWZKd3M=:+qoyAW62vM1CXB8ZyHhb5o oIVMSe7TaTUcNwMjlf9qGfxSkF3iJc4s8xuXYgd/Yap6jWcNAIdZBj055VI5t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: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/2/22 18:27, Sam Ravnborg wrote: > Hi Helge, > > On Tue, Feb 01, 2022 at 04:02:40PM +0100, Helge Deller wrote: >> On 1/31/22 07:57, Yizhuo Zhai wrote: >>> In function do_fb_ioctl(), the "arg" is the type of unsigned long, >> >> yes, because it comes from the ioctl framework... >> >>> and in "case FBIOBLANK:" this argument is casted into an int before >>> passig to fb_blank(). >> >> which makes sense IMHO. >> >>> In fb_blank(), the comparision if (blank > FB_BLANK_POWERDOWN) would >>> be bypass if the original "arg" is a large number, which is possible >>> because it comes from the user input. >> >> The main problem I see with your patch is that you change the behaviour= . >> Let's assume someone passes in -1UL. >> With your patch applied, this means the -1 (which is e.g. 0xffffffff on= 32bit) >> is converted to a positive integer and will be capped to FB_BLANK_POWER= DOWN. >> Since most blank functions just check and react on specific values, you= changed >> the behaviour that the screen now gets blanked at -1, while it wasn't b= efore. >> >> One could now argue, that it's undefined behaviour if people >> pass in wrong values, but anyway, it's different now. > > We should just plug this hole and in case an illegal value is passed > then return -EINVAL. > > Acceptable values are FB_BLANK_UNBLANK..FB_BLANK_POWERDOWN, > anything less than or greater than should result in -EINVAL. Yes, that's the best solution. Yizhuo Zhai, would you mind to resend with that solution? Helge > We miss this kind or early checks in many places, and we see the effect > of this in some drivers where they do it locally for no good. > > Sam