Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2158315pxb; Thu, 3 Feb 2022 00:02:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxRP6bGfaV0U19JJ9qbL4ezZ/JP7untcfMb5kjIAAIY8S7TRUZLhqAlHZGWTiycyES56BB X-Received: by 2002:a17:902:bd0a:: with SMTP id p10mr34881273pls.159.1643875354802; Thu, 03 Feb 2022 00:02:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643875354; cv=none; d=google.com; s=arc-20160816; b=h4JWA7B1C+biI0Z8Wgn2SoYCE9PT+JM0HjeDIWyUFZRipmbDKEXcx6qxrc3mPYRFOz JDc0LNKVy6VmBsifJMYkYqodFpv15KsfcovdnAffBJNkHITE/sYcNDL42tB6gJBmo6Qd ys4BqbfFIhru18iDzhBsswYJhajMzgQIZC0/bPsvXfYJy5Ap7KAFuaa3tlaEucnvMveA 0fBaK4G4DuM0bfJWCNYdxWHvZWRdTwNxoAAgiyCQs+rS+WjISexCRdfHE6QcwZOZeAuo 8at4sY2VMjAhAwe4BVWs3xEo59LgFOqA+k99yuvCmc1X1hR+ZWF2CPVzID0o5xETnFWQ eR2g== 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 :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=zpEuspKbohlo8aV6Pz7tfS2eP+DskvMgvksS3xkhToY=; b=mR4DaQ32ZQILBaGBwVnpUGM2gsneDQZGzNkLHGSSTGSrUsnlWSD7hq6oHnqM7mVLx/ oTkuiTg08es340aspwtagzBNHPwHDcsIdhbzq0y5dqIfLQe/oJevAv/t7F6HXP6Bzk4M n32vQ4a1r+GvS4pVmfIjPiMnu1E903HnJy9FBDy8QVsjGjg3OU4qYYe1kSWUncSs4tM0 9Oa111g4aS1bkBF7XBtM0FCZrMVsP5pnjOwuMe6VEIvSKQoNLBERpp8zieQiScJWYGcG yJZRoOW2lYt0zZa70Pg1cBxwW1+3E4JNenB3P5oSX+wt2h9AExBSIsVbMMI3/qcd3N6Q bzow== ARC-Authentication-Results: i=1; mx.google.com; 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=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16si25275919plh.154.2022.02.03.00.02.22; Thu, 03 Feb 2022 00:02:34 -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; 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=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242982AbiBBJC7 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 2 Feb 2022 04:02:59 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]:36041 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242242AbiBBJC5 (ORCPT ); Wed, 2 Feb 2022 04:02:57 -0500 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-286-fMc-AKToMMKAIaDfh45yHg-1; Wed, 02 Feb 2022 09:02:54 +0000 X-MC-Unique: fMc-AKToMMKAIaDfh45yHg-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Wed, 2 Feb 2022 09:02:52 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Wed, 2 Feb 2022 09:02:52 +0000 From: David Laight To: 'Yizhuo Zhai' CC: Helge Deller , Daniel Vetter , Matthew Wilcox , Sam Ravnborg , "Zhen Lei" , Guenter Roeck , Tetsuo Handa , Zheyu Ma , Alex Deucher , Xiyu Yang , "linux-fbdev@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2] fbdev: fbmem: Fix the implicit type casting Thread-Topic: [PATCH v2] fbdev: fbmem: Fix the implicit type casting Thread-Index: AQHYFxVn+cS+fUmzMESHo6Syg/F7Wqx/+Mmg Date: Wed, 2 Feb 2022 09:02:52 +0000 Message-ID: <5286c6acac7c4ee598f6fa4a7ea04b86@AcuMS.aculab.com> References: <202201311943.VXU6K1gH-lkp@intel.com> <20220201023559.2622144-1-yzhai003@ucr.edu> In-Reply-To: <20220201023559.2622144-1-yzhai003@ucr.edu> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yizhuo Zhai > Sent: 01 February 2022 02:36 > > In function do_fb_ioctl(), the "arg" is the type of unsigned long, > and in "case FBIOBLANK:" this argument is casted into an int before > passig to fb_blank(). 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. Fix this by adding the check before the function > call. Doesn't this convert invalid values (> FB_BLANK_POWERDOWN) that should generate errors into valid requests? David > > Signed-off-by: Yizhuo Zhai > --- > drivers/video/fbdev/core/fbmem.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c > index 0fa7ede94fa6..f08326efff54 100644 > --- a/drivers/video/fbdev/core/fbmem.c > +++ b/drivers/video/fbdev/core/fbmem.c > @@ -1162,6 +1162,8 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, > case FBIOBLANK: > console_lock(); > lock_fb_info(info); > + if (blank > FB_BLANK_POWERDOWN) > + blank = FB_BLANK_POWERDOWN; > ret = fb_blank(info, arg); > /* might again call into fb_blank */ > fbcon_fb_blanked(info, arg); > -- > 2.25.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)