From patchwork Thu Jan 5 03:37:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 39296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp103098wrt; Wed, 4 Jan 2023 19:44:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXtT2kwbMzT6Mxpu3i52dx0FXQHD+7m9VYTZX4vw1eMqMeC/atO0eSZeC8dPoH3q/Ov8/vD+ X-Received: by 2002:a17:906:a04f:b0:831:a76:90c0 with SMTP id bg15-20020a170906a04f00b008310a7690c0mr52510617ejb.32.1672890247717; Wed, 04 Jan 2023 19:44:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672890247; cv=none; d=google.com; s=arc-20160816; b=S20fe0jctvyssyOfXRthGFhSYj0EIs3DgSWAg0ZuCE2T701I+Ia9k6vINwDl/jwmfr WIkUwa72pcVPy5So4ElFI4rALydU+zntc59rV85UVWDeA/7p2+4fpAeZLSXpwv8zzpRO IZdBba1/EnGDVcMGVRVU4WeG4zd/DZeJKA9he6QHUR/D/NFdPuuqRJtKYHnWPLcdXlAo HTp1F78h0lWHkn4roIVipFnSqwlvaXTuX2TsfQx6Ai/Crilrq1wp4JcXIYrDrGllfMWi +wvuEC5j8MfTPuruNiZBZl4ETxHN+iho5npmeyTieFbhW4qKFmQrHz+3dvo7Uymqtd+M Z1bQ== 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=r1JpqbJ9++K/xzT47dMTEov/5+2eYul5oJHyAzUfPlI=; b=tW0jEex4ZpVyuNcOjtI6VShI6tAq11UAILKEpB2YBTDtFvLIluKMi3L0bO3EtXXS4v Oua/cCi/k447J04DiwqKq67zGc3iDHO1Rl9bl2KwUn7jts1wcz9BEkQF6LZ9oLZesNKn Cg1/zJnRQZpjQjNd717b+mcNu6GG4mXaEau8TSzrsaH8jFTXa9VYLkEacMk1w9BwfF1D uaF6qmFEmljU9aPW8+rDUTT1VdmAuK9rG24TnsZRsoynkKezfRQmRkGO5XZZhW8XBJPI 5BNUmg659vyB89rySSzLadhNCi/RjYt/yn8N+z92quEUlVcKjD0J95Hq5d7iza7Q2mNA UPCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BHsuebGz; 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 b2-20020a05640202c200b004599ae68f98si29171535edx.136.2023.01.04.19.43.44; Wed, 04 Jan 2023 19:44:07 -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=BHsuebGz; 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 S230146AbjAEDig (ORCPT + 99 others); Wed, 4 Jan 2023 22:38:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbjAEDh4 (ORCPT ); Wed, 4 Jan 2023 22:37:56 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1727A48CD4 for ; Wed, 4 Jan 2023 19:37:55 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id c8-20020a17090a4d0800b00225c3614161so723319pjg.5 for ; Wed, 04 Jan 2023 19:37:55 -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=r1JpqbJ9++K/xzT47dMTEov/5+2eYul5oJHyAzUfPlI=; b=BHsuebGz7UeGzGoW+IgpyeSNW0q2RdIcdyQ1lia+mDfh5WQUzUcg8FBu5cGvL5bmVd h1MHDMLC2Bq/qIYjylAiEzm4JqV+i62MO4R1/zf0ccUhdL6YKFMCIrdjdhNEu1v5AEST zlkrBx6EmfW3RoHcj6qm3k7WqJQLxSVeHAh2Y= 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=r1JpqbJ9++K/xzT47dMTEov/5+2eYul5oJHyAzUfPlI=; b=OF2Mheg4lgb7KHGi5zysnU8Znet/fqX8ps6Mcl8iDWHtA1zL5axgSEKVcNQyj2uv1b 8JI6jbtgNH2KR6O/JDe8wzRIOZ8FkmZmbGhl2RuaephLB6kO/QLU3H5pdH7QUlVI05xA kqDPhytwpwpx1JqhV8k5pdzQu3neJ96BPrdSq1O/rF8Kt5OuPXZnF+CtpzPTbIOcDxGD Ws3eSsG0Biocskoh4Tus6V21+93EsGeucYDSMgA9glSMjrXO81wrn79BXTLQlQEkSuPx OyYSO689hGFb7oPK5rDV/UApTeq+Ff8LlWTLt8AbpldwWT0F25TM8lpl4fz1uxcQp9LL Fdtw== X-Gm-Message-State: AFqh2krmAIRsY1+YD8Mg2Q+YvWIMCnP3MpdH8z0if5iRaBI6oFh3JZ3Z ZLBVsrT333Hzn889ntc9HXvCyg== X-Received: by 2002:a17:90a:f697:b0:226:1dbc:9f89 with SMTP id cl23-20020a17090af69700b002261dbc9f89mr27025085pjb.28.1672889874597; Wed, 04 Jan 2023 19:37:54 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o18-20020a17090ad25200b001fb1de10a4dsm280956pjw.33.2023.01.04.19.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 19:37:54 -0800 (PST) From: Kees Cook To: Jens Axboe Cc: Kees Cook , Pavel Begunkov , "Gustavo A. R. Silva" , stable@vger.kernel.org, io-uring@vger.kernel.org, Dylan Yudaken , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] io_uring: Replace 0-length array with flexible array Date: Wed, 4 Jan 2023 19:37:48 -0800 Message-Id: <20230105033743.never.628-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1795; h=from:subject:message-id; bh=r+TSIVb2BAWhTrGlFufqT3ga06iplRy8uL8xmu6l8Nc=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjtkYLP77BW3IAXqPW/RhqrA24FMPNCSI45CQs2IEd fy5cqKeJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY7ZGCwAKCRCJcvTf3G3AJqxND/ 4oGtR93uxHdilcizcL38yy4WDqC1zZkr1T3PXAepEgKMvcdsHqd9vzYPr2LgRHkCHsXo40ZPZR82Wz sUz0G6mP2tbZB85d990jEkkNQZE6Dc6OHj5I+dEsbm59Axce8iv0TpSEt8K8CZYg3VSuG/cQwyLKWa 4LLH3lIemP13XM3j4h035U+MPCF6jawWAw4chzz75/ulJIUSvDiS0ZxuAKPYZDTbbFsqkqMZzrAp6D azrxOyTr1c22SdkFTrF+0yqN4d245n9b8ueQlddoV5yPVaOQy1oDUXFlkgXJ2jvwNPa0phSgWastVe 6fjWF2k5OHzljQeBNtb8RqEf5Ud735dMTgPEU9o3lqQc8IkmGXyAsPi89wVk/eksoWrqcMP0s6XGcP hPrzB0Ixz2AW2bM2xyWPneebhaQlYnR3RO7xn83E8lbtKSTRRxcL0KhtD4Edoizki4soYMPUHFnvnG KC1035zSBZpj9w+SWeEGDgsSJlOria6hjC0f9gfypCRMvLRdVRRhy9amB+31qZ8a5fk9TtB4jbTjZY vqZu/+TYJuwU4zTLbR8YPtSipI4GKsxg7g/aN6FGlH7euKWsWi1JfGfraY+sAB6ZsrEqH/qCcAChe8 jmUNLNZCX8679hAFztKUsOc+IgPTku8pHV1XKvutWA5doN2Yq23jvjHDPujA== 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=unavailable 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?1754152564561742603?= X-GMAIL-MSGID: =?utf-8?q?1754152564561742603?= Zero-length arrays are deprecated[1]. Replace struct io_uring_buf_ring's "bufs" with a flexible array member. (How is the size of this array verified?) Detected with GCC 13, using -fstrict-flex-arrays=3: In function 'io_ring_buffer_select', inlined from 'io_buffer_select' at io_uring/kbuf.c:183:10: io_uring/kbuf.c:141:23: warning: array subscript 255 is outside the bounds of an interior zero-length array 'struct io_uring_buf[0]' [-Wzero-length-bounds] 141 | buf = &br->bufs[head]; | ^~~~~~~~~~~~~~~ In file included from include/linux/io_uring.h:7, from io_uring/kbuf.c:10: include/uapi/linux/io_uring.h: In function 'io_buffer_select': include/uapi/linux/io_uring.h:628:41: note: while referencing 'bufs' 628 | struct io_uring_buf bufs[0]; | ^~~~ [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Fixes: c7fb19428d67 ("io_uring: add support for ring mapped supplied buffers") Cc: Jens Axboe Cc: Pavel Begunkov Cc: "Gustavo A. R. Silva" Cc: stable@vger.kernel.org Cc: io-uring@vger.kernel.org Signed-off-by: Kees Cook --- include/uapi/linux/io_uring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 2780bce62faf..9d8861899cde 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -625,7 +625,7 @@ struct io_uring_buf_ring { __u16 resv3; __u16 tail; }; - struct io_uring_buf bufs[0]; + struct io_uring_buf bufs[]; }; };