From patchwork Thu Jan 5 19:20:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 39783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp463686wrt; Thu, 5 Jan 2023 11:34:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXv9AwSSp8WL14Dw6QXYJGJMRL43yg/xaJYsmowQaeNMP/MxisMNTLyjfRTjxMX83GfMIb+n X-Received: by 2002:a05:6402:241d:b0:46b:19ab:68d8 with SMTP id t29-20020a056402241d00b0046b19ab68d8mr47526055eda.40.1672947257766; Thu, 05 Jan 2023 11:34:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672947257; cv=none; d=google.com; s=arc-20160816; b=mYSNEDrZGPHCu1YygaxfXsk+i9I6DNW1OY6QcyrAKUxBnbn04kV2rXc6ZpL0KSrRac DnJUepCS2KM3yFLhnPTOm/Sj0Yj1TOwIXXa50rkJYH6LFFsnkKA5p8tqwKTJ3B+ot3ZB redYAoQFrbxJ4QtfTjvskdj8gxVk2VepUy4vds0qRuFnDv8QOtEYJpgj3rClO1C++ckY IbG0jO2Z7dmLxzzKjDvbY47uKtIUU8cK0mtBOp82MQDCKCbJ2bkhisEI0DeBqMRhxbyz 6pvYhFZDSesdLtEDI+7+/2AWWn0hbQjU3hffbUCOHRno4rAel+zgbfepRGQs1SFPyC8V NL7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=97sxfhjaB8PxBR7URrYCExoGnpeZKnrOyMFs+deDqoA=; b=SGvxILCqRKaCR/BBYsKJBK3unSu5FFobJzlFYZtK/6GO4lTqGb4cPPv6TPp/TLsk/C SZ0i9uhKN5VnosYAD6QZXQqpuP1i03txL8oH5a6z39sgNA+u+RsSPBaIDqnN94YiQd2P W2Rgy/RbAh1c/MVCSU2PrcoXIL9fgXAcqOzBh6PgtXT8GJ9bQ6m6yMnaHjN0c9pyksF6 IFJyc3kFIgQrWd3/J6D2Q4odYWR8r3W0hQ9hpHAWkYl3BMLmF0YzE13rQLBGJz4hDSEQ qCZCGAng0/N4abOdruhTo89JPZx21xL8biVXzR5qvOubEVG/ZbcffWh2pj+NkZZIKhnx cALQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IFFFns4m; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a056402191000b0048ccd99d3fasi17763492edz.482.2023.01.05.11.33.53; Thu, 05 Jan 2023 11:34:17 -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=@chromium.org header.s=google header.b=IFFFns4m; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235651AbjAET0f (ORCPT + 99 others); Thu, 5 Jan 2023 14:26:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235880AbjAETZw (ORCPT ); Thu, 5 Jan 2023 14:25:52 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06D13A46C for ; Thu, 5 Jan 2023 11:21:37 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id g20so17828179pfb.3 for ; Thu, 05 Jan 2023 11:21:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=97sxfhjaB8PxBR7URrYCExoGnpeZKnrOyMFs+deDqoA=; b=IFFFns4mTLHYiYPOdpH3k/Z6BfSYt1T8o7KcJMEOb7uldcq+iWk0U8tofOlIyAkpKx Zm2YjpnCHTIqDwutAyZ/t+YGUhFLuddGsBcIAIPJyosjV4qRzQJLBfboku0pRLxE3rwg E92VlWkAp8E1qj7r+WM0hJV4a+/SrUMEFxVSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=97sxfhjaB8PxBR7URrYCExoGnpeZKnrOyMFs+deDqoA=; b=fzUlwyoKWrqnrAP/+8kC/yt2Gui5KMwawumxGAgayWp1I9MCOhXYMp0MPZBNEbRa4i +S1dgZz6B2a7eKXS0lunv2z/oyrnpUdFK36Pm1jfu7FQxfeup+142fcL0sy9pvg4S+Pr 9IcwLXVX1jKqG2f5oWdT+138ag+4aeREDIG74zf23kwghuMyex5l8wO4OQXuV5fOdEt+ 4FjVjePX7xugR133EHCC0xJLhUKgnpE8C+Fw8WnW+wfzGEDgbJ7pZKiy+AF6mzaxWZxv 5K04bAOcUjBdc0XLIi6gv+Jm6vDlQBl5HlVIhZNwEGsJRsNysOoE+0G+Wxa3dc2MekwF jwRg== X-Gm-Message-State: AFqh2kpZdne+2lYoOuTM4QmUwp82lENYcNsLP7U8Wh1mIfPgkIM22aCR A3qizi+ATPnByd0r9Pz36pjFhw== X-Received: by 2002:a62:4e8e:0:b0:583:3d70:3661 with SMTP id c136-20020a624e8e000000b005833d703661mr473651pfb.9.1672946440663; Thu, 05 Jan 2023 11:20:40 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h11-20020aa79f4b000000b00582bdaab584sm5868470pfr.81.2023.01.05.11.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 11:20:40 -0800 (PST) From: Kees Cook To: Helge Deller Cc: Kees Cook , "Gustavo A. R. Silva" , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] fbdev: Replace 0-length array with flexible array Date: Thu, 5 Jan 2023 11:20:38 -0800 Message-Id: <20230105192034.never.249-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1496; h=from:subject:message-id; bh=eBudshCogBtu2xin7cq/2EcDLuR1Ha1dnf+jDA9WM7A=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjtyMFUMFrIl5nzBw/rrohurWWx677rm+9jnFO2OEH EHsCmCCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY7cjBQAKCRCJcvTf3G3AJh39D/ 9JXSePQkOSG9y/c/7C77a7sNLOH6tRaBYFyxy0DqaiEqTL/wMEaWTJIe/TCr3eh5BcFRGkvE9aIydJ k0rjqKkxDAuT1SXy1IBz60cx2VutSvE62Wg6uN3jeM3wPgOHq+ccnA71nY8P8nAsDE0iC/5YR4s0tO e1YWFmLBF8TiWofavtjiQzRN5JArRGAdoSseCu9rM4Agl2OI1Z99fhdxq3LrYJXFVDdZLIlMW8n1DO egCycrggYzOaG114EndKmY7TBCBUfZkAxDU0O/t/YRLEBYqVlpZTGugD+LL0Odn8sgVNk5qwzCabkA A6v2Azd+H1iC5u5tFAoJD01fRv6ehdA4UZP+Alp0cSfooDCbJ8gHvwkVaktKC6pwKotnrI9de/3zpO 46+EcziPobYfUE/n+MG406Cr5/DbX8EH9RPVHvhxCN4tY5nHwpnIrHnelwe0RJOypvREb+N9DWq3hk QV+e8YP2rpKcIn25nevZZYExlnnxRWg+81Eo2n4xhAAtGY0ixR7hSYBOTp3jD1BuSfucmRBNiCuXRL qAMcw3Ygfp9kKDBDxcXrVBF21hRPN0cv45Odmb5Ee2GoQKhWYwpTAqHsctn4r3fhnQU7DNTWYzTjXp EU6fBQVzpe+v4o+gD7iVUj1EdwkxfMj9MlKVTgdtSKn+PDYo58UfpL2zyUyw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754212343419588613?= X-GMAIL-MSGID: =?utf-8?q?1754212343419588613?= 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=3: samples/vfio-mdev/mdpy-fb.c: In function 'mdpy_fb_probe': samples/vfio-mdev/mdpy-fb.c:169:32: warning: array subscript 0 is outside array bounds of 'struct aperture[0]' [-Warray-bounds=] 169 | info->apertures->ranges[0].base = info->fix.smem_start; | ~~~~~~~~~~~~~~~~~~~~~~~^~~ 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 Reviewed-by: Gustavo A. R. Silva --- 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 */