Message ID | ZQSvsLmJrDsKtLCa@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1277900vqi; Fri, 15 Sep 2023 12:39:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrZ4hw96524JBkBqEBZL2jRpq+iry1JMw75ozBr9RRUMjB0s+CoXpo/IMBBY/Dzhu/RUT9 X-Received: by 2002:a05:6a20:2445:b0:133:1d62:dcbd with SMTP id t5-20020a056a20244500b001331d62dcbdmr7235946pzc.28.1694806759970; Fri, 15 Sep 2023 12:39:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694806759; cv=none; d=google.com; s=arc-20160816; b=jZEEq9jeyzyPXpAalRrTPoE721TDJ1MQ+O0DAuqvozAQV30CK0GoRauTnZdkRZsmwO 1tHh27xUSMzzNQyDgiRLiMU5SYrzxv52jcqVyfpBN1n6zzUHW12FM9NiGZvaB+UGPJwd HhAyBv6Enl7Ga8Kx6LSXYCRYVrHqGjxHbVR+k/tcIotQbxaL660mpSIw3a1sh00ldwWT Bm8bhU9h+CFfGdOpfKaqGTL589F2GXluJoqEfUWglNU+ewFcfchLlMaGdE/VGCEVJ5ez x+eUQqncSokBr0CtnfMuvwKKOUSIluing93oJfGKOHdZxcbtoNmIem+eIcTvGJWy/Yyg eO2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=J6Ga7FqjAMB7ACRg0vhnICWfEtXOXqEFgwP23l6Wwz0=; fh=cYGZzd9tN15y12EXkth3icfIPwpUr2swwQ/CluKkD20=; b=jd4wxNe93IQVxHQJWOH5PbufLNfg+0k0E0w8II7WfOewJi/3RCyVrK0JymUqAx5uyE MUTe7hL3/W0Cltu4GcgpeNIC/6BgMAIGKGoYny7O3wyx9tpcoHJ3OBR7C0z7j/0VYEWF zdDyHVTOo3FwASjCyV9C5V++5miK57OedpV4Rn4em4WK1iysiSHydgxjltbnx5ceTE7v 7lcjmbc2CpywJoyISTOpbjgaEfXKspa3Pz84vGXr/e6dMORNVqIwuxGkR/w4X1qM8BPS tzgXGL6o6SXb1TiQHynXdWDFpuXD34dQJ+p8937O2ZcYXgRFxp8JihnVPtCvKK/pn2IZ gUQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Yzd/ccnw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d30-20020a631d5e000000b00577f50580bbsi3653368pgm.299.2023.09.15.12.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:39:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Yzd/ccnw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D5DAA8053CD3; Fri, 15 Sep 2023 12:25:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236897AbjIOTYu (ORCPT <rfc822;ruipengqi7@gmail.com> + 30 others); Fri, 15 Sep 2023 15:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236980AbjIOTYr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 15 Sep 2023 15:24:47 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F5EB199; Fri, 15 Sep 2023 12:24:42 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA574C433C8; Fri, 15 Sep 2023 19:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694805881; bh=MwqHe4JvGzG4fmXR069X5g/4C9oJN5CAAugIujwOjR0=; h=Date:From:To:Cc:Subject:From; b=Yzd/ccnw/jpnhpn+bE/Ms49Rl7aD6/8TKdway2v9+BbVA2BAJHLITBjaVZf9X77d1 fU+KDmmLjj0MQ8T2Mjxo3bnrw4On0yYxWpN7lDPbcFBBg7OaZdmNbiEtNOEUXZw4VS r2eAOmzguYLY4oInOGggWoYmLIBLqkhGHmzQfeheLjJobKWnKuv7zablUqmUb7/+rG BkX7+nO5HB3LOTJOPxfK/wZpcti98WWvttp/qWrJ1sEWdA6UlumNi8MXGTS7zkM1Go KhrefT0si+o14upI4rsCpe5yY63ovVia8VBZge93yijsrHO7EA0iZcK4VT9vkCb983 5WWKjHrnJeSkw== Date: Fri, 15 Sep 2023 13:25:36 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Ishizaki Kou <kou.ishizaki@toshiba.co.jp>, Geoff Levand <geoff@infradead.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, "Gustavo A. R. Silva" <gustavo@embeddedor.com> Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] net: spider_net: Use size_add() in call to struct_size() Message-ID: <ZQSvsLmJrDsKtLCa@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 12:25:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777133693310476777 X-GMAIL-MSGID: 1777133693310476777 |
Series |
[next] net: spider_net: Use size_add() in call to struct_size()
|
|
Commit Message
Gustavo A. R. Silva
Sept. 15, 2023, 7:25 p.m. UTC
If, for any reason, the open-coded arithmetic causes a wraparound,
the protection that `struct_size()` adds against potential integer
overflows is defeated. Fix this by hardening call to `struct_size()`
with `size_add()`.
Fixes: 3f1071ec39f7 ("net: spider_net: Use struct_size() helper")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/net/ethernet/toshiba/spider_net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, Sep 15, 2023 at 01:25:36PM -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, > the protection that `struct_size()` adds against potential integer > overflows is defeated. Fix this by hardening call to `struct_size()` > with `size_add()`. > > Fixes: 3f1071ec39f7 ("net: spider_net: Use struct_size() helper") > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org>
On 9/15/23 14:25, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, > the protection that `struct_size()` adds against potential integer > overflows is defeated. Fix this by hardening call to `struct_size()` > with `size_add()`. > > Fixes: 3f1071ec39f7 ("net: spider_net: Use struct_size() helper") > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > --- > drivers/net/ethernet/toshiba/spider_net.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c > index 50d7eacfec58..87e67121477c 100644 > --- a/drivers/net/ethernet/toshiba/spider_net.c > +++ b/drivers/net/ethernet/toshiba/spider_net.c > @@ -2332,7 +2332,7 @@ spider_net_alloc_card(void) > struct spider_net_card *card; > > netdev = alloc_etherdev(struct_size(card, darray, > - tx_descriptors + rx_descriptors)); > + size_add(tx_descriptors, rx_descriptors))); > if (!netdev) > return NULL; > Looks good to me. Thanks for your fix-up. Signed-off-by: Geoff Levand <geoff@infradead.org>
diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c index 50d7eacfec58..87e67121477c 100644 --- a/drivers/net/ethernet/toshiba/spider_net.c +++ b/drivers/net/ethernet/toshiba/spider_net.c @@ -2332,7 +2332,7 @@ spider_net_alloc_card(void) struct spider_net_card *card; netdev = alloc_etherdev(struct_size(card, darray, - tx_descriptors + rx_descriptors)); + size_add(tx_descriptors, rx_descriptors))); if (!netdev) return NULL;