Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2435089pxb; Thu, 3 Feb 2022 06:40:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdw2RneleEVj1f0vABRQ7iKpwA5Wc1THUsGZtUJvYIHG/atzSIQUrAWDcGoLtVdgNaPZ0z X-Received: by 2002:a63:d1:: with SMTP id 200mr15915937pga.402.1643899223778; Thu, 03 Feb 2022 06:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643899223; cv=none; d=google.com; s=arc-20160816; b=uBYo+8OvzS6qhkl4SszZ4HuPEgcyCgYYbOIQdyM71eUjCBy8v+ayqHT/AtELDUcAAy vrWZht58JElpzdNWQiF96PMimVb4qdK4ypBpzkIbmq16BgtH+5d6f08nboDU25XabOGx 6y0vHDUI+Rgp9W/hZxLurg4OafU0jQqrI9H9EN89SKWEIh7o+Jzz/eg2MlXJJE/8KiPI kuj0esRNg+YDwUekRt6MK1F/CoEOHQkjcEEfNWWD6POulyi53yvnbZcLI4g8YFVVgHET MU2hkhws3i9BOARMpXyjnJr7WJ5P9nbdhsJfwoFHx4A3WIAEAQDoWUbzZBsRRor5y7qo yBpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature:dkim-signature; bh=x0gpjDLXaul+KimMP/te05qJYZBYJvmQ+lbw67iuhZI=; b=QoC2bjZEu1V7xoc5h9WE4kFC/KjVkuu1VhXbueu41j9A7Rq7HzKQE6+FZxCblnD2ok yah7Ho1G8ukIOmafxxY2C87o3/wVRDGjr88zPEUvNyneIs5NRt61D54+LCCe2X+6UYS8 T8Hu89UH+RmyQE7L67QRGxjydcGJTrZyzT7NHRzlmnuCXgTpLIz4m/Ntsc4AoTI6I1E2 XBKFdvXAlatZ3nfKCijE//ygcFMRg5S0tviik8IGmmVqBKsHySEVvourt4Zjr4Cf3H1g kN988GLqelhVn0kx0x0V4duovE5WbsflikUsj8HBocx4R4aPejhIPGVOwznNSdvNueVU syhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ucr.edu header.s=selector3 header.b=UJWUhAZr; dkim=fail header.i=@ucr.edu header.s=rmail header.b=iG0hqIoj; 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=ucr.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pj6si4522544pjb.63.2022.02.03.06.40.10; Thu, 03 Feb 2022 06:40:23 -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=fail header.i=@ucr.edu header.s=selector3 header.b=UJWUhAZr; dkim=fail header.i=@ucr.edu header.s=rmail header.b=iG0hqIoj; 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=ucr.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348059AbiBBXRa (ORCPT + 99 others); Wed, 2 Feb 2022 18:17:30 -0500 Received: from mx-lax3-2.ucr.edu ([169.235.156.37]:57261 "EHLO mx-lax3-2.ucr.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348060AbiBBXR1 (ORCPT ); Wed, 2 Feb 2022 18:17:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ucr.edu; i=@ucr.edu; q=dns/txt; s=selector3; t=1643843846; x=1675379846; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XA4HzDe0AEvwI/VRCaorqRe1KBJyowOMBeCxGfa6hn4=; b=UJWUhAZrWyXAP+iT7Hu1cZeUORsgK3W4Aa6F3Dp+HPb4XbJWYsDMFSA6 afS+nLWDE3dGenebC7rBjhWqpop/aQSHAPmMUsBNvQmdxDMQYDaz+nw26 6YF+ay62FaFXr8ALF72+RUvniH4lUxvRyPS52A0eI+BHiHGpuwTBfYpux 8cfFORojDAT8sMOSv2VBDCEIVIRAF8heUNR53ASnxiPCfCiFUzl9xwrIM EkId7y/pzYVctHaKQ1I3JviIL2T3YIVfXGuDxIGDzOonhzR5n22jpBgs/ 2zv3deDxVFS6KmiZqA8JR8kKIQ1pSQbIhEJttbEX3kU3KFyGkiPc1AVVh A==; X-IronPort-AV: E=Sophos;i="5.88,338,1635231600"; d="scan'208";a="102063261" Received: from mail-pj1-f72.google.com ([209.85.216.72]) by smtp-lax3-2.ucr.edu with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Feb 2022 15:17:18 -0800 Received: by mail-pj1-f72.google.com with SMTP id f60-20020a17090a704200b001b51d88e887so3415094pjk.1 for ; Wed, 02 Feb 2022 15:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucr.edu; s=rmail; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x0gpjDLXaul+KimMP/te05qJYZBYJvmQ+lbw67iuhZI=; b=iG0hqIojQ+Btn3YyfJz0zIh+ids2UdHlcdajOgKekWODbOVBE25xUjQthNVNVCYJZL ziLiUrKHuhoXAKfwZ6C7H0nGSqSQhiN5jcNjOymYda/yMkGSCQpR8Jg0jBCRvZRWu7Ly FY1UCAwviBYMivvY4GLNBbBng5j7VlxTHZzhM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x0gpjDLXaul+KimMP/te05qJYZBYJvmQ+lbw67iuhZI=; b=0GbmxhSm7hsEwuVrY10E99sfYEY+fPuWxL7rPMNU1/gq6rjXf/HIaUwu0/hHQhi0Oo SYOuBlHpxiWM/Z8yRyJ1/6Bw7UyAmRXrshAjkXa9dDDHeVF2VlXmE80adqQlZbG1csXS MpBKyy2Brm7SgcUbVUCa2HZHQty7PwKnxH5exI4PqXO3q5cmslON+G9I+0C3enQVYJ/o exhGPpITnnpaP0vlmYF2z4RQVYRhzFjTAZtBHPUGPVuJFOStC2Dhu4Yl0T4abBFFqgpa ibYeES/x9mwEPhEO7V4SAwuRPthMP3mgfmYp9+wHmC3lr5KCDRd21d32bF89xmYr0IGI YnmA== X-Gm-Message-State: AOAM5315w1w4FRWIN1Eri+A1Or9IbG1Im/mDnTieT9rtDVp0to72L082 0ooU7wLTV/dzNQNenGihmGigtlDvJZ8KVPWsggygbi3vYxGXzXg/uUW6ryIsReyhx09UNPuXrVD 5qS5pZajtDK0sVtOHMPanVmEKYQ== X-Received: by 2002:a05:6a00:114e:: with SMTP id b14mr32122975pfm.31.1643843838877; Wed, 02 Feb 2022 15:17:18 -0800 (PST) X-Received: by 2002:a05:6a00:114e:: with SMTP id b14mr32122959pfm.31.1643843838640; Wed, 02 Feb 2022 15:17:18 -0800 (PST) Received: from kq.cs.ucr.edu (kq.cs.ucr.edu. [169.235.27.223]) by smtp.googlemail.com with ESMTPSA id j14sm27383525pfj.218.2022.02.02.15.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 15:17:18 -0800 (PST) From: Yizhuo Zhai Cc: Yizhuo Zhai , Helge Deller , Daniel Vetter , Matthew Wilcox , Sam Ravnborg , Xin Tan , Guenter Roeck , Zheyu Ma , Alex Deucher , Zhen Lei , Tetsuo Handa , Xiyu Yang , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] fbdev: fbmem: Fix the implicit type casting Date: Wed, 2 Feb 2022 15:16:33 -0800 Message-Id: <20220202231636.1433050-1-yzhai003@ucr.edu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <882bfe4e-a5b6-2b2c-167b-eda8c08419e3@gmx.de> References: <882bfe4e-a5b6-2b2c-167b-eda8c08419e3@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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..b3352e23caaa 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 (arg > FB_BLANK_POWERDOWN) + return -EINVAL; ret = fb_blank(info, arg); /* might again call into fb_blank */ fbcon_fb_blanked(info, arg); -- 2.25.1