Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5870705rwl; Mon, 9 Jan 2023 00:33:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXu6Bh4yBfTVt5DiVD5BsNXhVn491w7EXLio3QbJBcIWic9Daqv8fPe503OrORp+jxsAn+Vh X-Received: by 2002:a05:6402:2b89:b0:461:ca30:653 with SMTP id fj9-20020a0564022b8900b00461ca300653mr69013158edb.31.1673253211157; Mon, 09 Jan 2023 00:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673253211; cv=none; d=google.com; s=arc-20160816; b=bJxkv3FjE1OraU/C12Bv9lUBpoowCOwO1mS54eNDEH5xMPIeqcvVzYq6HT11HO2UtX pg7ohpv2QaREb1LBjmWyStN168PDHfxzfMsPhKAbwU47TZpCPpkTgV42J+dkbEA2iRnw fuF5b2cNZfQW7OlboCqHKs7yf6YWH0t76nbI/d2dC56w30jVEym4Ou3U3lNjp4MwuI6J TTnK13mknBt/twNyzjthHp3Zq5zwhL0dTNHXFxTakb9lFSef7BIRVAgxBZ7jTjiWQSyn a+KCCUQDj1jfo4zuSGlf3K1sjcZfc46qBDkqZsZfFYAZNiLbfg5chS1JBgzVXA14zd0I 3BqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=Uvx7dS4vEMhAUQ+J1atoKtcgIfkSGnk5fYkZbBh2GI4=; b=EjWCTdK6aI+lUCjn6OLEMJJS8iWx2DSKgAyssJhbkSARPuydIjNcGeNif2DysTgLWl LJMrfgyaE5FfyAG9EFmgnhrg+VzetF9GCvpJXZmJT4wxk/ikhztLiV7mIYjVcSTWHIC/ /UgupeSaSteX9dIIcS6jgM44Qr2wuNSDkPDOPp23JqikZaoX13QOtsQcBXFgjFsSSD/K ihHcHEpIJrJBmXW5kvfS6/rX5SELXh96ERQvYj2D5saGWDevejXssd5YuXCPw7rIzMIp +aY4st3GkxP0rE3kROIDH6nBFo1JfJPpXLM+ve0tTGce33vrBcPziSulGGB2RfqNE0Vr JmTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=smzHY8PN; 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=pass (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 v7-20020a056402348700b0045c31d9643bsi11136690edc.2.2023.01.09.00.33.18; Mon, 09 Jan 2023 00:33:31 -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.de header.s=s31663417 header.b=smzHY8PN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233339AbjAIIDP (ORCPT + 54 others); Mon, 9 Jan 2023 03:03:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233106AbjAIIDN (ORCPT ); Mon, 9 Jan 2023 03:03:13 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D850DFCDA; Mon, 9 Jan 2023 00:03:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1673251383; bh=qozjcx4hTpr3jaYdT2eKjDnLhPkqHFw+E4wFsV+KjBo=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=smzHY8PNV3Owc520Tr9p8IXQNBB9KKe4GYCYgmoeCwe6bz71EZc4DA6nOyUvP8bVf 1nT6FchfvuH/idf4w/pYs8IYRPsRNvPTCdbsk9RdPZr164FKH5gvVOJPredv5RruCz 1uYcoj1ypJRVK3w3dvdktbAe6C+XMQmY87PTaG2jIvQZGpDB8R7v/3mqwsdPJLEtZU B9YI4MPAm0O1F8NJYMp+FwU9rrftW/l1QQIMiUnnfykkiniFWe8dLCN2xFlKAOkdYT IcPvik70XX9eKiXjk1dF0+VAJ30kRtHcZbaPXO2K1rRgRBBxXsjD13WvxRV9Evn2BE 4fwlcf4j0NiDQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.20.60] ([92.116.168.5]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MwfWU-1opqNY4Aig-00y8zI; Mon, 09 Jan 2023 09:03:03 +0100 Message-ID: Date: Mon, 9 Jan 2023 09:03:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH] fbdev: Replace 0-length array with flexible array Content-Language: en-US To: Kees Cook Cc: "Gustavo A. R. Silva" , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20230105192034.never.249-kees@kernel.org> From: Helge Deller In-Reply-To: <20230105192034.never.249-kees@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:9YTJmsZjsjckd6I9le8J645mr0N28l3SdIAvOuyOXzXTuxHoKTG qoIQNW6zyu1FP5X6N850VSLQj1Yw9UebNucTTQJta3AtHaS+teEAiFne08YoJwisaVxSDKz N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7SLbaJLH1KJI5FzdZfI1biLpG8jS8 5zHJ/A== X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/5/23 20:20, Kees Cook wrote: > Zero-length arrays are deprecated[1]. Replace struct aperture's "ranges" > 0-length array with a flexible array. (How is the size of this array > verified?) Detected with GCC 13, using -fstrict-flex-arrays=3D3: > > samples/vfio-mdev/mdpy-fb.c: In function 'mdpy_fb_probe': > samples/vfio-mdev/mdpy-fb.c:169:32: warning: array subscript 0 is outsid= e array bounds of 'struct aperture[0]' [-Warray-bounds=3D] > 169 | info->apertures->ranges[0].base =3D info->fix.smem_star= t; > | ~~~~~~~~~~~~~~~~~~~~~~~^~~ > In file included from samples/vfio-mdev/mdpy-fb.c:21: > include/linux/fb.h:510:19: note: while referencing 'ranges' > 510 | } ranges[0]; > | ^~~~~~ > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-= length-and-one-element-arrays > > Cc: Helge Deller > Cc: "Gustavo A. R. Silva" > Cc: linux-fbdev@vger.kernel.org > Cc: dri-devel@lists.freedesktop.org > Signed-off-by: Kees Cook applied to the fbdev git tree. Thanks! Helge > --- > include/linux/fb.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/fb.h b/include/linux/fb.h > index 96b96323e9cb..bf59d6a3590f 100644 > --- a/include/linux/fb.h > +++ b/include/linux/fb.h > @@ -507,7 +507,7 @@ struct fb_info { > struct aperture { > resource_size_t base; > resource_size_t size; > - } ranges[0]; > + } ranges[]; > } *apertures; > > bool skip_vt_switch; /* no VT switch on suspend/resume required */