From patchwork Thu Jan 5 22:01:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13090581 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC26AC54EBC for ; Thu, 5 Jan 2023 22:02:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11B378E0002; Thu, 5 Jan 2023 17:02:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A3628E0001; Thu, 5 Jan 2023 17:02:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5F398E0002; Thu, 5 Jan 2023 17:02:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D2C6F8E0001 for ; Thu, 5 Jan 2023 17:02:00 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 83D1A1C6400 for ; Thu, 5 Jan 2023 22:02:00 +0000 (UTC) X-FDA: 80322118800.30.3A49BCD Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf11.hostedemail.com (Postfix) with ESMTP id 445764000B for ; Thu, 5 Jan 2023 22:01:57 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=mTH+Pi3R; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf11.hostedemail.com: domain of keescook@chromium.org designates 209.85.216.50 as permitted sender) smtp.mailfrom=keescook@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672956117; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=GU4F0A6CghntlAPFlpuG7hCmUocPla4d2Q4HBiVaB3k=; b=2+rKsvzv7gr/FXb65Zc3Z/XBy5wo90tZgXOnMC6sAXGyr/X9NgYzeeb9L6NpwwE8+oS6EQ 5hgg9+hjp89AafNLxenIhSCONbs0CQePpcEqiHWLlUDsH+sw2ghc6xSYKt2us6vhNFJclQ zL6NDnq0BFMRg8ZAe+35mCTkawdgsKI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=mTH+Pi3R; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf11.hostedemail.com: domain of keescook@chromium.org designates 209.85.216.50 as permitted sender) smtp.mailfrom=keescook@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672956117; a=rsa-sha256; cv=none; b=OvDh/zr9ePaArZ0bb1jFyasMii8/DGCQ8JoE5xnmhhRAZBf64KYLt96PhF0Ra8ChPHoBcK almu4NVt1Nui4zvueRW0PBOmneAKKzgQOO/sr/ymvSMRahr083m1MvzjYEHhpdtzEQYQ+R YY8BcunisSGEq/2oaJ0gV7NZ7KmYZ6A= Received: by mail-pj1-f50.google.com with SMTP id n12so28400738pjp.1 for ; Thu, 05 Jan 2023 14:01:56 -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=GU4F0A6CghntlAPFlpuG7hCmUocPla4d2Q4HBiVaB3k=; b=mTH+Pi3ROqEsjK25XUv/HIFl/ZZBPEhOQWIk/soZxwErT2IfckDSCYXjlhJWs9ypug hfyPaZoxRTq5zBvRSgv3VMmw3jJyytXAts59+xEQbtr3bpXqq23Zv+V/RK2WBLXPqYCt fRDRg4gQgtlwgBJ3z3ia4doa5sW8Sr8N8M5GM= 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=GU4F0A6CghntlAPFlpuG7hCmUocPla4d2Q4HBiVaB3k=; b=DIM+c3F/8C0iWbgvRvDcLiVcHbf0t1cmm/knl9HfZ7AwrakK/ed4Ur/66F83WQ4+FM 3ll62VpkPDKoEZsmwBKdmXFMuclqLJh5EK31aRFOy0SqRdIblysmERupULyGmObcYZVU BwWVNYLmPZn0m85uUDUIzmU9/ddHTdugd5N1QTM1M8Jxu4YaQaxrdmP4EQEoy4GFTli9 D+fkCwQTSxC2aEhKoMQQzsxZY477gU/inFHa+k0l0EJq6Oe+pHQUzJkVdQkRkTrOd9ox IKoyQvdigZxgZFuI0bpxNph/Dh6G0eG6w7fIqYUbkxswkKyCqhAzOFgJL81VPUuoIa7J InJA== X-Gm-Message-State: AFqh2krc0I/sY10gKGySXDONuw+0andOAeNcok5UbX8QjYTpLM19mDLO vrbX73/PLyozhYkw7f/BOZViOA== X-Google-Smtp-Source: AMrXdXvKdh7czZvM4eVFJAWSkqYwNmvkFxmvgsEkW2lV2vNnboIARMc1tuPcgig4piCwbTioPww16w== X-Received: by 2002:a05:6a20:1e5a:b0:9d:efbf:48d7 with SMTP id cy26-20020a056a201e5a00b0009defbf48d7mr56663117pzb.27.1672956116121; Thu, 05 Jan 2023 14:01:56 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h9-20020a628309000000b00574db8ca00fsm7924258pfe.185.2023.01.05.14.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 14:01:55 -0800 (PST) From: Kees Cook To: Andrew Morton Cc: Kees Cook , Dan Williams , Alex Sierra , Felix Kuehling , "Matthew Wilcox (Oracle)" , Shiyang Ruan , "Gustavo A. R. Silva" , linux-mm@kvack.org, Alistair Popple , Joao Martins , Mike Rapoport , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] memremap: Replace 0-length array with flexible array Date: Thu, 5 Jan 2023 14:01:53 -0800 Message-Id: <20230105220151.never.343-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2644; h=from:subject:message-id; bh=wqATlM0Wy6ZUz1F3TRvkHL3pT03iLnEph/fbgS+sn5g=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjt0jQGs4GvKcEISh+DUGAS/MBAXty4zobHGXMnncR wkthQ0WJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY7dI0AAKCRCJcvTf3G3AJpIqD/ 0YTMOnoLIq2BdwO/Kzukw8r0GthNIuwD/Zs4fYENGzt1pw16sh9gFyie7bQ9uuvzOzUImgfcoqMT6l GYcn9cU9VCKcv45dtSw5NWxTt30I4Naok6sZ2KEQJyyNxiYs0mXfv/j6ame8zdFCaeSuJjzF1NsC/s JlIyl2OcHHXOHr9AQk+YHlzhwhQ4PLxfPqHVgsSQaU6ygOsUbUqdG5cy8lNg+EmMLuDSzudI/7hBZb CYzdqdsFHDDTjBfivfpo5wG9vwf/+puOdddLEoAK/eL75zvcxVDDkqw5knpCpAU+MQTeJpJkBQqdsz by3KrnXaoaA5xdjveU+mqp+mOdadd/a4SgOwTYdHOvAfuvPe9P1VEkSVDUkp+7nRZQwZwc8PVeBGBX wMOs7ZlUgJvIBCx1DqAsRQUz9Hi7xxnRZPoioyVrPyV4GNPed5bYNnXk/wN/N/7Tw7A1z/dVR3N+DN 7uZmQK7Op1FR7MCa6dP5jCo3FtQ+lgMLWEr7F2xl54WLuDuXt5yhfyCScdHYArvJ95XcXODACD4xN2 W6mQXNFy2+m9yPbmzWZDs+cjL3Jp0l+NAC5l5cjnyXh1nGTm/aF9aeQYblYDl5yYyqDRGHBM+8hPi0 4h8drdjiWhgZEfmJEaq5pk+27Tr4r71W3y7BwztdD3quCAjO90oqnlHHx7RA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Rspamd-Queue-Id: 445764000B X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: naegfkath3k11a553rokobupnsid137u X-HE-Tag: 1672956117-128240 X-HE-Meta: U2FsdGVkX189nWe3FSCvR0Ly1bcjpI+R7VKSoJEdJVHCkKaXgaHafj9iQHbtfXorJ4aWTlIryl+tpA9/Zy4dFWhnJqp5dQFHaL8nDD0kwP6SLKD/xVjsr6h7n8P7yQyNtKQBHuQRJchrc0tu2KgWwLsH8D8JBzZ08DuaYAedOKTkNoY/pU/Kn0jtFGHU9slLTYKQU1Z1uDO2JjUkvSxgwCxQXU/HuUym40garYV8k9FCr1gV9yG5ZvOE6EZX+iN9qIgkaFpeo7wZx1Ah/59oB0tMUvKVtTuHvrwLEWzgleNNFhXY32ii+1b8BGzRakUJvFIQL6wmET2FnQHAwnJpiBa9MQlfOOKKAjOD61kmdNxj4n2WJGagJrAgw2+Uj0i2NvQydz+fzwjIpXnk1VwYg4455jVQBwBt7uLSBsUmvR6FlxcbUISJ1h76Ko3jU6LRner5WRrVzFYP8zqT3X90lhwmNgqxzqruWGL5TBnbYZZiKSpMszfUoR08vZmasvAXfAa/GWEil6XaSi8tQoQG/Fp14dDPuDPQbTdzcTZBf0pvCDljJYmG2K+3GN1E5fUEccbxuPmLJ3NlvKXWNv/sZV+lPgBU1l8f0cNQJFWcx8r3lu8PfB/q6rEKrSQm0WYKN6B1/6u/d9S9NjfT4VvTs6//qvVcpnRsiieFi3mvIrAM4+tEcvNxt42M3YiDpxr/z/xzvHyhSgnAl/vllMzp/UjoLhoTPSJ3mgZzL5HnOCbJO/CX3H5xNBz4N4h5Aiv68Pf3nmnAy9lmYPytTETMkiwu5tjpjMHznzXmNKfg4ehGBhPXBsZOg9roWzZGqnD20ZtnVcCY0T74yeKFVTvbvws+hz83l0RY1qL7O3TY2Ryd0nZXAHGMe4IVN9mXne9O49mf9VVM28NIOt92JUQR+gPfCMMCp8KuHRLpT/xiSRYd/QgMpWXjN0isoyaDh/yhMzHtm1ZvRieoJTRT1uY T6zTEf9X CH5IUzjCT1pvBHdAjdjUgntqS7/yTSi1fdr6nD877DeLhokcEAoxkgJWewQjAbCkoq+BF3MJpSAQn6ZUTk+2uEPHFCtpkJRoOmwTg X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Zero-length arrays are deprecated[1]. Replace struct ethtool_rxnfc's "rule_locs" 0-length array with a flexible array. Detected with GCC 13, using -fstrict-flex-arrays=3: In file included from include/asm-generic/memory_model.h:5, from arch/x86/include/asm/page.h:86, from arch/x86/include/asm/thread_info.h:12, from include/linux/thread_info.h:60, from arch/x86/include/asm/preempt.h:9, from include/linux/preempt.h:78, from include/linux/spinlock.h:56, from include/linux/mmzone.h:8, from include/linux/gfp.h:7, from include/linux/mm.h:7, from mm/sparse-vmemmap.c:21: In function 'reuse_compound_section', inlined from 'vmemmap_populate_compound_pages' at mm/sparse-vmemmap.c:407:6, inlined from '__populate_section_memmap' at mm/sparse-vmemmap.c:463:7: mm/sparse-vmemmap.c:376:39: warning: array subscript is outside array bounds of 'struct range[0]' [-Warray-bounds=] 376 | PHYS_PFN(pgmap->ranges[pgmap->nr_range].start); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ include/linux/pfn.h:22:43: note: in definition of macro 'PHYS_PFN' 22 | #define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT)) | ^ In file included from include/linux/mm.h:31: include/linux/memremap.h: In function '__populate_section_memmap': include/linux/memremap.h:138:30: note: while referencing 'ranges' 138 | struct range ranges[0]; | ^~~~~~ [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Cc: Andrew Morton Cc: Dan Williams Cc: Alex Sierra Cc: Felix Kuehling Cc: "Matthew Wilcox (Oracle)" Cc: Shiyang Ruan Cc: "Gustavo A. R. Silva" Cc: linux-mm@kvack.org Signed-off-by: Kees Cook Reviewed-by: Dan Williams --- include/linux/memremap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 7fcaf3180a5b..1314d9c5f05b 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -135,7 +135,7 @@ struct dev_pagemap { int nr_range; union { struct range range; - struct range ranges[0]; + DECLARE_FLEX_ARRAY(struct range, ranges); }; };