Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1452385pxb; Fri, 27 Aug 2021 09:09:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3/kT6XYi+u6TDGIGSIIWhcPFOvMgNxP230HwgyGpuQwZfGACOhkWLnTLDwlirNyKOhLEt X-Received: by 2002:a17:906:417:: with SMTP id d23mr10388073eja.383.1630080551335; Fri, 27 Aug 2021 09:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630080551; cv=none; d=google.com; s=arc-20160816; b=gXRTm7N7zmDgBqb/yEl0nUiS4AFP0bZXqenIcZAMCaH+0cQxnRVQN8kPesrSu2LZRc GJ2lxP46xl8pZBVbv3BoFcF2eDbGyvshphSSCgcQHz55q8JFxErZhKpFshiXjO3A7zFk A/raYeEhug53xcslnM37IrWAvUiE+p+q++cYtbj1TEypcGmH4LQh8IEla/V79jEsQl4g lnTDVPLyqMM6UWPaAAiSuI83IFNaaWuBXkC5OlfRY3yR6A30NAWpGmtyI/VB2/IZ6W4U Jis+W8BPrxMGXURWTHKPvkLtHwrFiylC8hcbtHQFPEqHzIOKkfee2uKLB594WLVruVK8 ssMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3BOREjcUGdekjt/HzJv8JPNZZV+WRxv1ga5r5CaLfMg=; b=Iv9M4CO3ITrwOTzJ8D16wUCS31VObIgzdvqOyviXdv5sw0Off7FHZLyvpi9N9iogHx KvqaQXE6hUt3f95YlZ+0ofdQdux1jcvPm7ZLbiynAhzkPLZvYu8Zg1I2z/b0KEDOtgSa 03Wu+Bh+23tmkk2/qJFPqkNxHSoX6IryE4Qpw73ew/LRdOJ2COi+lOdBv8Stm7yLA4K4 J3PR6mHNx7rkrBoddgAcTogkmTRGpO2zGogCip1cxuWfqrt8ozTWVhK35CVp5Jum/KZo lj4cEUGB1MZCuyGGZKKlGbE2F0sgWkZK1GSTFGKGi5cJapxppAAPqCI+kOuJyMmZ6+hd eFkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LgSMkv8y; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qb26si2258874ejc.538.2021.08.27.09.08.26; Fri, 27 Aug 2021 09:09:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LgSMkv8y; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S245469AbhH0QJM (ORCPT + 99 others); Fri, 27 Aug 2021 12:09:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234297AbhH0QJM (ORCPT ); Fri, 27 Aug 2021 12:09:12 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29BE2C061757 for ; Fri, 27 Aug 2021 09:08:23 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id mq3so4842522pjb.5 for ; Fri, 27 Aug 2021 09:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3BOREjcUGdekjt/HzJv8JPNZZV+WRxv1ga5r5CaLfMg=; b=LgSMkv8yRY6NcFjGg/J63Y2GpE2F2TGefzma4o9g5HEhtSAND6DhVddNHYYks45NsN vl/76kMWgkZPlkAHgvJTPVgljvSFRJ7Ui/2QED3sjgSLOAoCwiEAsmgZNMGT/LdlCbMz 6XWQqYT5qF5nKBsTivPFzvO7iyOTn/hubgj2U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3BOREjcUGdekjt/HzJv8JPNZZV+WRxv1ga5r5CaLfMg=; b=rJSl1xU8b+8W1BPeVQ352IQVfmmgZJqqlZsR6dhie9aqDYp95mspMrQaPPMrXb3P8p nrRG1j6TY99B3iUj3wJXU1CK7nJ3z3G52p7n9cudt+Fwr01XhPwrdBqDczYJhMDrPBwF 3KFYXYJvB4ENAi1WErUyjiVuR46cFJ/JO7XcxS3bvrHb8o8+U8YtE20sdNt/g3eX89uI vSd8bMGhPkICI34MFdWwaS/KYeuy/ofdV29/iPyCwVhuaWBANnOfR3Nfm3IfIZNFuAs3 PlvznndCNGSG3sHaxaBqyANBsiJb+1EBG1l2m2rTnHhgYQ4cXq5rmL5mUVPnJcYZyLzo iQDw== X-Gm-Message-State: AOAM533decPXSb4EYSz3VIKPevmBJ1rfn/q0OGOZp6dVdYdlfYZ9TjIe 79xmUh2pesa0Gsy51ImsKRPL3A== X-Received: by 2002:a17:90b:357:: with SMTP id fh23mr8796487pjb.140.1630080502650; Fri, 27 Aug 2021 09:08:22 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h9sm13930821pjg.9.2021.08.27.09.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 09:08:21 -0700 (PDT) Date: Fri, 27 Aug 2021 09:08:19 -0700 From: Kees Cook To: Marc Kleine-Budde Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , Arnd Bergmann , Ayush Sawal , Vinay Kumar Yadav , Rohit Maheshwari , Herbert Xu , "David S. Miller" , Kalle Valo , Jakub Kicinski , Stanislaw Gruszka , Luca Coelho , "James E.J. Bottomley" , "Martin K. Petersen" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Johannes Berg , Mordechay Goodstein , Lee Jones , Wolfgang Grandegger , Arunachalam Santhanam , Vincent Mailhol , Mikulas Patocka , linux-crypto@vger.kernel.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, linux-can@vger.kernel.org, bpf@vger.kernel.org, Rasmus Villemoes , Keith Packard , Dan Williams , Daniel Vetter , clang-built-linux@googlegroups.com, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2 2/5] treewide: Replace open-coded flex arrays in unions Message-ID: <202108270906.7C85982525@keescook> References: <20210826050458.1540622-1-keescook@chromium.org> <20210826050458.1540622-3-keescook@chromium.org> <20210826062452.jekmoo43f4xu5jxk@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210826062452.jekmoo43f4xu5jxk@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Aug 26, 2021 at 08:24:52AM +0200, Marc Kleine-Budde wrote: > On 25.08.2021 22:04:55, Kees Cook wrote: > > In support of enabling -Warray-bounds and -Wzero-length-bounds and > > correctly handling run-time memcpy() bounds checking, replace all > > open-coded flexible arrays (i.e. 0-element arrays) in unions with the > > flex_array() helper macro. > > > > This fixes warnings such as: > > > > fs/hpfs/anode.c: In function 'hpfs_add_sector_to_btree': > > fs/hpfs/anode.c:209:27: warning: array subscript 0 is outside the bounds of an interior zero-length array 'struct bplus_internal_node[0]' [-Wzero-length-bounds] > > 209 | anode->btree.u.internal[0].down = cpu_to_le32(a); > > | ~~~~~~~~~~~~~~~~~~~~~~~^~~ > > In file included from fs/hpfs/hpfs_fn.h:26, > > from fs/hpfs/anode.c:10: > > fs/hpfs/hpfs.h:412:32: note: while referencing 'internal' > > 412 | struct bplus_internal_node internal[0]; /* (internal) 2-word entries giving > > | ^~~~~~~~ > > > > drivers/net/can/usb/etas_es58x/es58x_fd.c: In function 'es58x_fd_tx_can_msg': > > drivers/net/can/usb/etas_es58x/es58x_fd.c:360:35: warning: array subscript 65535 is outside the bounds of an interior zero-length array 'u8[0]' {aka 'unsigned char[]'} [-Wzero-length-bounds] > > 360 | tx_can_msg = (typeof(tx_can_msg))&es58x_fd_urb_cmd->raw_msg[msg_len]; > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > In file included from drivers/net/can/usb/etas_es58x/es58x_core.h:22, > > from drivers/net/can/usb/etas_es58x/es58x_fd.c:17: > > drivers/net/can/usb/etas_es58x/es58x_fd.h:231:6: note: while referencing 'raw_msg' > > 231 | u8 raw_msg[0]; > > | ^~~~~~~ > > > > Cc: "Gustavo A. R. Silva" > > Cc: Arnd Bergmann > > Cc: Ayush Sawal > > Cc: Vinay Kumar Yadav > > Cc: Rohit Maheshwari > > Cc: Herbert Xu > > Cc: "David S. Miller" > > Cc: Kalle Valo > > Cc: Jakub Kicinski > > Cc: Stanislaw Gruszka > > Cc: Luca Coelho > > Cc: "James E.J. Bottomley" > > Cc: "Martin K. Petersen" > > Cc: Alexei Starovoitov > > Cc: Daniel Borkmann > > Cc: Andrii Nakryiko > > Cc: Martin KaFai Lau > > Cc: Song Liu > > Cc: Yonghong Song > > Cc: John Fastabend > > Cc: KP Singh > > Cc: Johannes Berg > > Cc: Mordechay Goodstein > > Cc: Lee Jones > > Cc: Wolfgang Grandegger > > Cc: Marc Kleine-Budde > > Cc: Arunachalam Santhanam > > Cc: Vincent Mailhol > > Cc: Mikulas Patocka > > Cc: linux-crypto@vger.kernel.org > > Cc: ath10k@lists.infradead.org > > Cc: linux-wireless@vger.kernel.org > > Cc: netdev@vger.kernel.org > > Cc: linux-scsi@vger.kernel.org > > Cc: linux-can@vger.kernel.org > > Cc: bpf@vger.kernel.org > > Signed-off-by: Kees Cook > > --- > > drivers/net/can/usb/etas_es58x/es581_4.h | 2 +- > > drivers/net/can/usb/etas_es58x/es58x_fd.h | 2 +- > > For the can drivers: > > Acked-by: Marc Kleine-Budde Thanks! > BTW: Is there opportunity for conversion, too? > > | drivers/net/can/peak_canfd/peak_pciefd_main.c:146:32: warning: array of flexible structures Oh, hrmpf. This isn't a sane use of flex arrays: struct __packed pucan_rx_msg { ... __le32 can_id; u8 d[]; }; struct pciefd_rx_dma { __le32 irq_status; __le32 sys_time_low; __le32 sys_time_high; struct pucan_rx_msg msg[]; } __packed __aligned(4); I think that needs to be handled separately. How are you building to get that warning, by the way? I haven't seen that in my builds... -- Kees Cook