Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp110524pxb; Tue, 17 Aug 2021 20:42:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyij/5cHrbVkoACaIBLXJDHYddlm6ElKh0ywXpSuOZe8eyDQhgQm/YDuGJ7Rq6R003vX9K9 X-Received: by 2002:a17:906:d04f:: with SMTP id bo15mr7410163ejb.309.1629258151554; Tue, 17 Aug 2021 20:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629258151; cv=none; d=google.com; s=arc-20160816; b=fTezqtiTMK0n0bCkr16NrCzelLiRR15SUZU3GzK//i40ivwS6b5KfCRsGhA1z40Zw2 pL9/QfkZD4kzgRjbgctTDuUPWjw93ttB1I3HSf5s0Cga7XB7hK+T21pOgIQPVb90QFex SsN6+sWCuTsPscCNAwP/F+78Go/hlSMXCfdgHpQgNkWdmN1YOTB42M6bDRavS/t5xC7K L3EF+J2PMi+I/2zFl18ZOAC/KuJ1eTbZ3bcvt32+sIFYfPpC1Vp3y3iyswGyaTHD427K lND+ykqSMuqEUbuEednTpDqFDmfzfmWeMXZ41Gh+ABUcpg/lZAInnYFa4iQ/qyYwZ1Q0 fIBg== 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=BsdVXbhtWjUQaskCMlUgEBNS4pC3NCkpK2fi3WMsLKs=; b=Jz/HaB7AQBCxMNKoSmO2SYofWAPDbCIl+jwJaD6MRGZThwME2WKLcMl6x8LoPqypJV XsH9XGlOY7wr4mNHaEAp4YXSnb0NNEY7K40Q6lHfWLrH6b8MIXAx2BThB6LaEKj52B/2 ylfjsQTtQ0viuhiGibfcdi9JTZb+s5ljEZB2/d5YExfQMdwUReGv4Ysl4oeHcHjQl3gQ isShqhyoRB5gliJC2MMWpb9Q0W+huNUrolNirqGo6FO8+KS/Ba1+AyMA2ao5FztDUcTl 1mFlGXwablbj48jbgsJSW260+AaWo6VnJpu+tzYRJbPLALku99JQkFpOGFJ3HddClY/u bcOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ljf+4KWe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 de10si4476351edb.214.2021.08.17.20.42.07; Tue, 17 Aug 2021 20:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=Ljf+4KWe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236392AbhHRDlX (ORCPT + 99 others); Tue, 17 Aug 2021 23:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236297AbhHRDlW (ORCPT ); Tue, 17 Aug 2021 23:41:22 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59A25C061796 for ; Tue, 17 Aug 2021 20:40:48 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id oa17so1779523pjb.1 for ; Tue, 17 Aug 2021 20:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BsdVXbhtWjUQaskCMlUgEBNS4pC3NCkpK2fi3WMsLKs=; b=Ljf+4KWeVggSI4Lf6tc0A3nHEXXDjCM1/9HKrlbPRAGljqsAxLc2XrTWzSUlDcrMPh P6DnuN3vSN0v5bJ/HdgOf94oR/ORI+tgmH6XRTm2wnfkm5667m2RKbNnJ77J82+Nx5pX bpu+zhJrfZSTkVjY8NK3lNiH6W5lAUhuFMu7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BsdVXbhtWjUQaskCMlUgEBNS4pC3NCkpK2fi3WMsLKs=; b=VIWXVTjfYVlgm/q0M5PP37YxvoPpqTkUaY9wcskg0qYi7KsjZiAsYCTZhhiX/Z8HW+ 2B0xY9zOP61JpwHGNrW6xWSWvuIsgUybc064aLuyUQ1b0J4CZIomSuQolIN3erv+lu5I KbB5CoDWufd2G1a0AavbPhZzYDcFovxPi6Tc5P9eNH3Jqs6vszRNytPEjqkuVRoDbi9k 9+VBYo8dhvemUMLUKqG6+xjuctVq8uSgYOWi4Le6QquinuSmAS/Qp5C0FvhlKawHOplD x3TFjKZRqYWGBRIBh1KgLfepdjHlkQW5AsqnscUlVc+LJPDLzrraKWn0ydPyGuVSoom5 y+nQ== X-Gm-Message-State: AOAM531BBygBFhwS5T8mrMFiDtkOfqkOXTszxq65EtceA2u+vJuSKnWY S/OBMYCN6yRzUnTNaX6RPxTRqQ== X-Received: by 2002:a17:90a:6888:: with SMTP id a8mr7162828pjd.91.1629258047889; Tue, 17 Aug 2021 20:40:47 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y5sm3790937pfa.5.2021.08.17.20.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 20:40:47 -0700 (PDT) From: Kees Cook To: Wolfgang Grandegger Cc: Kees Cook , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski , Arunachalam Santhanam , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] can: etas_es58x: Replace 0-element raw_msg array Date: Tue, 17 Aug 2021 20:40:10 -0700 Message-Id: <20210818034010.800652-1-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2405; h=from:subject; bh=2pghWRFPuQ+zVAOzO5gfNiPmiJDuiTH+Yfm+Ryq/M0I=; b=owEBbAKT/ZANAwAKAYly9N/cbcAmAcsmYgBhHIEaiZ+lXRC4QwUOqC71mOhS6HSGOj3Caw1KKYLF 7L2JZyaJAjIEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYRyBGgAKCRCJcvTf3G3AJsVpD/ j7xXbwKjJwKT2/GO+ODaujdBGdL6Osu0WV1eU4XmqS5JfJkc+l2PFtKNfj6weSU0gXlOjRX8zQo9Vk RGTXtjXdt7Cw6atuK6aFxzGJuFRek6LadYkYs7hUunrsAuHTyoV++Q/ltnSzptbX6zTZtKkzjT4Mnb 1sbL6mA+MGtTnYFO6cqc5IPv9qZZFZr7lOyYkpiztuUQjj1Lb8Zqj+/IP6sh7ePDPksNRFqHcIeEx4 u+cDgj0hCPPHdE4WRYbK2CSXjL5m9stprftBB5AfmdxXblnZIPW9w26iSWTVSKoyej3pB/f1upjQxs YUs4j6qklJb8pe1DGwrudFdZtGtFImGSL7ap+9UXyYhkU2txwLCOMZbwHhrSKTGw7C2c/GLTO+rceS qa/qXMGgpT1cMAkKX2yL1XK/wg4yCEbT00q4oj7XPLEcadol2gXH3dafW+/ydbcaY4kgxvYvBSewsP rXPTtLeoN4RpHB+kHdSXET3oed3KzRg6hS2x1078wD2iCE/RKQtbEyGHXPlpq8HOkHjCazT9CMbR9L cpAmLTqZeddlhGnvs0rlgQ8LxHHeEPEPCzyK+2blJZjg7aYahRjZlUm05YoPSQUN0XhInmO7oJIutG lbwOtuCNS2QSeh6mvvNab0mm/3Ibe3VZ8Kq/+P1m+l1sisDz595D+GbIOg X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While raw_msg isn't a fixed size, it does have a maximum size. Adjust the struct to represent this and avoid the following warning when building with -Wzero-length-bounds: 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: Wolfgang Grandegger Cc: Marc Kleine-Budde Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Arunachalam Santhanam Cc: Vincent Mailhol Cc: linux-can@vger.kernel.org Cc: netdev@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 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/usb/etas_es58x/es581_4.h b/drivers/net/can/usb/etas_es58x/es581_4.h index 4bc60a6df697..af38c4938859 100644 --- a/drivers/net/can/usb/etas_es58x/es581_4.h +++ b/drivers/net/can/usb/etas_es58x/es581_4.h @@ -192,7 +192,7 @@ struct es581_4_urb_cmd { struct es581_4_rx_cmd_ret rx_cmd_ret; __le64 timestamp; u8 rx_cmd_ret_u8; - u8 raw_msg[0]; + u8 raw_msg[USHRT_MAX]; } __packed; __le16 reserved_for_crc16_do_not_use; diff --git a/drivers/net/can/usb/etas_es58x/es58x_fd.h b/drivers/net/can/usb/etas_es58x/es58x_fd.h index ee18a87e40c0..e0319b8358ef 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_fd.h +++ b/drivers/net/can/usb/etas_es58x/es58x_fd.h @@ -228,7 +228,7 @@ struct es58x_fd_urb_cmd { struct es58x_fd_tx_ack_msg tx_ack_msg; __le64 timestamp; __le32 rx_cmd_ret_le32; - u8 raw_msg[0]; + u8 raw_msg[USHRT_MAX]; } __packed; __le16 reserved_for_crc16_do_not_use; -- 2.30.2