From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1514C54E94 for ; Thu, 26 Jan 2023 09:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236680AbjAZJIO (ORCPT ); Thu, 26 Jan 2023 04:08:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbjAZJIM (ORCPT ); Thu, 26 Jan 2023 04:08:12 -0500 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B2443EC40; Thu, 26 Jan 2023 01:08:11 -0800 (PST) Received: by mail-ed1-f53.google.com with SMTP id y19so1272499edc.2; Thu, 26 Jan 2023 01:08:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hMr0xC0YhrqgD1viBDPP26FWvFPbPdmQWji8YbWNKZM=; b=0X8L9XYz/Rmg2XuT+4nhIcHlumh9Tktx6U7JNIpS4wwqm/KeFNC1jX30GKxeEmWXYy /C66Nc7/+kNypk1zDQJqEbidgd6FmCzFns3ctM7ZNMqDxRNOSeMFdg/BDwV+okwfrnz0 xSYT6M2oS9S0q4KSP39H5+id18BMLpl8aNyzDYXsMyuWMbHlZNz2PfVXiyG00FNS15Rc qTwan3+LoROfMzqALPvfRJJF6OJc92zpA02i6W3iUXd/HX6x/zqyI63NIIYf4i+xYaAk K+Z5larS6SWLLLOIXxkiLJRiuDlfAnXZqFwUQyXwi6SdlP7V00QfKYN4c0vpLP2/FwOl VNSw== X-Gm-Message-State: AFqh2kr6wPP9B6K1mCd1MIiWWeSfpXZNUTnyWdP4FmXBGhjFp7DtrXv+ C6ccmfndrmzNcCs9LVkbSQ0DSoW0Xkg= X-Google-Smtp-Source: AMrXdXs7LccmnB0bZcinEZc6Pyw0tuNtDY8p4RYr8ArU3wqk/0+yiT/jtfRNjdsb9EbsAtxehuiZ3g== X-Received: by 2002:a05:6402:524f:b0:49e:498c:5e16 with SMTP id t15-20020a056402524f00b0049e498c5e16mr43666895edd.30.1674724089094; Thu, 26 Jan 2023 01:08:09 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:49? ([2a0b:e7c0:0:107::aaaa:49]) by smtp.gmail.com with ESMTPSA id y11-20020a50eb0b000000b00467481df198sm434295edp.48.2023.01.26.01.08.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Jan 2023 01:08:08 -0800 (PST) Message-ID: Date: Thu, 26 Jan 2023 10:08:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] fbcon: Check font dimension limits Content-Language: en-US To: Greg KH , Samuel Thibault Cc: Daniel Vetter , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sanan Hasanov References: <20230126004911.869923511@ens-lyon.org> <20230126004921.616264824@ens-lyon.org> From: Jiri Slaby In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26. 01. 23, 8:43, Greg KH wrote: >> --- linux-6.0.orig/drivers/video/fbdev/core/fbcon.c >> +++ linux-6.0/drivers/video/fbdev/core/fbcon.c >> @@ -2489,9 +2489,12 @@ static int fbcon_set_font(struct vc_data >> h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres)) >> return -EINVAL; >> >> + if (font->width > 32 || font->height > 32) >> + return -EINVAL; >> + >> /* Make sure drawing engine can handle the font */ >> - if (!(info->pixmap.blit_x & (1 << (font->width - 1))) || >> - !(info->pixmap.blit_y & (1 << (font->height - 1)))) >> + if (!(info->pixmap.blit_x & (1U << (font->width - 1))) || >> + !(info->pixmap.blit_y & (1U << (font->height - 1)))) > > Are you sure this is still needed with the above check added? If so, > why? What is the difference in the compiled code? For font->{width,height} == 32, definitely. IMO, 1 << 31 is undefined as 1 << 31 cannot be represented by an (signed) int. -- js suse labs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FDFEC61DA0 for ; Thu, 26 Jan 2023 09:08:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C597310E183; Thu, 26 Jan 2023 09:08:13 +0000 (UTC) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id AEECB10E183 for ; Thu, 26 Jan 2023 09:08:10 +0000 (UTC) Received: by mail-ed1-f41.google.com with SMTP id x10so1240624edd.10 for ; Thu, 26 Jan 2023 01:08:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hMr0xC0YhrqgD1viBDPP26FWvFPbPdmQWji8YbWNKZM=; b=npLsj5ahAG+gasrIKQGikib9z+u4NRjrb+Cwc4OuEfugW//RZalNFc06wP9MgPvyeF TN377jEe/WE6muLbMH3Jydu8Og9cCyeBaR9xfgXxW6ni+QnxJ04ULyT8spFykqgeg7Ed laHoCtVWHOIXJHdmZ7e42hD5uSpKdsvPqlcm+KhXDO745EcHJft/9Gen2d7wP3YpfG7c qtQ0UG1Q3LIp8J/OH451SfUlJ8dMtMLQDmEDYdlx7uoYR7G+2cGq5MZ8mTjqCMurHln8 NnSI3LYUgGebr8fdTOQjoIL5CHv8+EsA3xru8mVDdgTdSvgaT3ALcZOkdcpF5UhjD2uF mVvA== X-Gm-Message-State: AFqh2kpnHTOlt1nUhPZ2hHTh+IU8h+aU4wYHKr3lI8W3ENZ46LiECS6g CATomTtMBb+gnir45JAU62E= X-Google-Smtp-Source: AMrXdXs7LccmnB0bZcinEZc6Pyw0tuNtDY8p4RYr8ArU3wqk/0+yiT/jtfRNjdsb9EbsAtxehuiZ3g== X-Received: by 2002:a05:6402:524f:b0:49e:498c:5e16 with SMTP id t15-20020a056402524f00b0049e498c5e16mr43666895edd.30.1674724089094; Thu, 26 Jan 2023 01:08:09 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:49? ([2a0b:e7c0:0:107::aaaa:49]) by smtp.gmail.com with ESMTPSA id y11-20020a50eb0b000000b00467481df198sm434295edp.48.2023.01.26.01.08.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Jan 2023 01:08:08 -0800 (PST) Message-ID: Date: Thu, 26 Jan 2023 10:08:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] fbcon: Check font dimension limits Content-Language: en-US To: Greg KH , Samuel Thibault References: <20230126004911.869923511@ens-lyon.org> <20230126004921.616264824@ens-lyon.org> From: Jiri Slaby In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Sanan Hasanov , Helge Deller , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, stable@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 26. 01. 23, 8:43, Greg KH wrote: >> --- linux-6.0.orig/drivers/video/fbdev/core/fbcon.c >> +++ linux-6.0/drivers/video/fbdev/core/fbcon.c >> @@ -2489,9 +2489,12 @@ static int fbcon_set_font(struct vc_data >> h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres)) >> return -EINVAL; >> >> + if (font->width > 32 || font->height > 32) >> + return -EINVAL; >> + >> /* Make sure drawing engine can handle the font */ >> - if (!(info->pixmap.blit_x & (1 << (font->width - 1))) || >> - !(info->pixmap.blit_y & (1 << (font->height - 1)))) >> + if (!(info->pixmap.blit_x & (1U << (font->width - 1))) || >> + !(info->pixmap.blit_y & (1U << (font->height - 1)))) > > Are you sure this is still needed with the above check added? If so, > why? What is the difference in the compiled code? For font->{width,height} == 32, definitely. IMO, 1 << 31 is undefined as 1 << 31 cannot be represented by an (signed) int. -- js suse labs