Message ID | 20221022021004.gonna.489-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1010606wrr; Fri, 21 Oct 2022 19:47:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6O0u7aj8ZnXM/mP88tBKQZmw0tiKPrAJHdqhnCJMseJDwtARQMqrZTayOnqQulAxpLjYdP X-Received: by 2002:a65:6bd4:0:b0:443:94a1:429c with SMTP id e20-20020a656bd4000000b0044394a1429cmr18935941pgw.606.1666406827314; Fri, 21 Oct 2022 19:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666406827; cv=none; d=google.com; s=arc-20160816; b=HT7B3gaQj9KHRB3uvU9IByFFOLicNazpdZ6hhkYpgDrmPK+oji/Tgy6DqrUNtiebW+ S6Qb3Cu+G7BayC2mlg7Xy3itk6vNxCxIlVol9+MFVip/aWBrBXtX9+2EfaCsILy6wB7m 8LFEKyMufpRfgaxQK3eD5+l8Oy7tAFQwCch1veaNv9Rf2yIQJIYKIx5OauCLctHc9FxK /ZgkQU4aZtB1J9QkdRN/1owwbo6vwewvOORBDDZV/KFxkHiFR4sMRXgV7lb+KtqwEZHJ +/P/kbNQ8JYyI73ciNDOJF9WDCcCdoI/e+OHnoRR3eMgqUxcIOReo5Pg0IShMdgx3Qyv rsjA== 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=dp0M8QaGTosDxslHlGRlCukiGrX1euoV7+LSShJejvQ=; b=rOIg2WVRasw0T3SQ1i1V/MH4+Lt5k9171q9/Otk0TueqQCW+jZvFlUtJuKLgYjXVhE Xg8Hff/vISBpXJq7tZjgytibXWfRWxLqajknPli5BE7Tew4R1rePbG/NwXu0M0D+wJLh k4P5OGEEPe1r4dQOFVMgSwAdXe6+R+fhSBlFCY8P7aPizOXjsx6YzuSGMu6EPgcz4BZX L4WJdS7DeKkd1Emkgnjj2MKmJvn2w4X1gDPCHjLNp4Z3jUoB9YDZA3jXENdCZEEfS9r0 RNdE2ROf2YqKWWS/XX0DhMha96tvQUNDgN/Qr6dIgx1PmD9+VOh+/dI31T/LGEprEpJN a1Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P1ssKOsD; 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 k10-20020a056a00134a00b00562fc008395si27158934pfu.341.2022.10.21.19.46.54; Fri, 21 Oct 2022 19:47:07 -0700 (PDT) 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=P1ssKOsD; 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 S229535AbiJVCK5 (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Fri, 21 Oct 2022 22:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbiJVCKy (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Oct 2022 22:10:54 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB8E827083E for <linux-kernel@vger.kernel.org>; Fri, 21 Oct 2022 19:10:50 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id c24so3881352pls.9 for <linux-kernel@vger.kernel.org>; Fri, 21 Oct 2022 19:10:50 -0700 (PDT) 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=dp0M8QaGTosDxslHlGRlCukiGrX1euoV7+LSShJejvQ=; b=P1ssKOsDGfAzkbS0J6o4jiEFKiAboRIfCX2SAcxEgTcVO9vc1+K5Sg5TjmSIxZCgFI GoNyXhBmBcrAt5ZfHf0dXVi02HlyuP8oEFD8UYBYVvwFZSyE+7bCu2JIAFgq4fqgXP7z jFGXOKcAVvCjO4ZbHwMgiSY7EHRorbLDhbfQ4= 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=dp0M8QaGTosDxslHlGRlCukiGrX1euoV7+LSShJejvQ=; b=0AsvODn+oxHG/n1mxixjrsLnGY86e+DP+O7yBfKHiHvso9UeZdrARGsdtYo4edq3ZL nEIPppcrNU56gzMwyvNoCvVixGnsuovCvyLITY81CT0n9G4+6ScfkuSYsNPVFep4NFJ6 /vUUMzlWzhfenqkxuBA0guafi+n4MSQcjvBAOS5R35NQO5G/jNoECxQpod+QeVPFqIIh 4nAr9XMKFHrRhET0kwThBOzCgUTTNj6PLCN+s63mLQNYBRmXGqaJv+liEvcyJHKPjdQy d/Pw5vs01N9nFTko46QAg0UmsXuyot1KjzI9tCrjRa2zSojxWSYQ663HeGw8Yh1jSHUM wWhQ== X-Gm-Message-State: ACrzQf0Pt6jPH5u0T1ISTE/T024hCp0WtFwxQ/hMgiKuUuiTt8ozv9G1 FtBwPWGpc7Dt31VrqOPV5Pq/Vw== X-Received: by 2002:a17:90a:13:b0:212:d139:748a with SMTP id 19-20020a17090a001300b00212d139748amr6201964pja.182.1666404650081; Fri, 21 Oct 2022 19:10:50 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x9-20020a170902ec8900b0018685aaf41dsm935195plg.18.2022.10.21.19.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 19:10:49 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Rasesh Mody <rmody@marvell.com> Cc: Kees Cook <keescook@chromium.org>, GR-Linux-NIC-Dev@marvell.com, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2] bnx2: Use kmalloc_size_roundup() to match ksize() usage Date: Fri, 21 Oct 2022 19:10:47 -0700 Message-Id: <20221022021004.gonna.489-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1611; h=from:subject:message-id; bh=lPZ4Wk6QPlApa8DQwhP0RlPQkBfpj7yqelwZL9l0DOE=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjU1En16msYKz6GI19Alpm5t9/fISZHDbDu9U/jkXb jpPDKhSJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY1NRJwAKCRCJcvTf3G3AJj2HD/ 9Xt0fOgmZo9iMbVqCVd17EwCvEoJg6/inBTNKzuruzFllB69/8PiuUxO5yQjwycpmkBKlYiizirjyM DdMZBMxdYjDflL5Qf3km4kI+yoPaHnD6kGAFUKUzoaQyp11oYaDk9iG5lDug734TySlRmf128kXMqE o79eZXtP6Q2+9ytiDwJUTuMmyK6ZY6LKXmhA2rU6JbrTmNuvh/jTfn0DI6+TFKQ3Jlv49KX8P9hLRk dXjIFQvOvBYgoOE7blbgaJ2eCRf8wVCxxPu+rJ2bwShBKN458wFIDJF20VvHNzqWwYUgUROndiTrUW r3Yw/nYjS9i58GRSkOouNSLpMPMmLeIuUgOtmbVPQ3uCOYFxbhB85KBBReeiHJcF5BTCZU1ayyaWAt fvx5KqtrtmbaDu+ynQFgCXokDdoFYE72DXfxHJ7yzWe1SRuTEV3eY3iqKsQ8g8kfUTVUBKT8MBGY4X t4Av1NiZxXz8BHB/BuoGTJvUtNjnLRZpxU8+Ku4SJ0//btZ33zNENR+3h4Iwi/nIAl+LadgaGnNTTz 4oIP9d7w7Lfa28Uq63RqBENtxFybsE/JaAlVmJ15aNAtOtGqDbBCDjGcYGRDJeRBzpNWqWpb8dPt79 iqPS9R68WYUuIR/nxj0Dv1yxC9R6RqMh8VfoWH+XK1i2yCJDkHTe8CQC3xlA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 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=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747354205080706189?= X-GMAIL-MSGID: =?utf-8?q?1747354205080706189?= |
Series |
[v2] bnx2: Use kmalloc_size_roundup() to match ksize() usage
|
|
Commit Message
Kees Cook
Oct. 22, 2022, 2:10 a.m. UTC
Round up allocations with kmalloc_size_roundup() so that build_skb()'s
use of ksize() is always accurate and no special handling of the memory
is needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE.
Cc: Rasesh Mody <rmody@marvell.com>
Cc: GR-Linux-NIC-Dev@marvell.com
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
v2: use kmalloc_size_roundup() instead of replacing build_skb() argument
v1: https://lore.kernel.org/lkml/20221018085911.never.761-kees@kernel.org/
---
drivers/net/ethernet/broadcom/bnx2.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
Hello: This patch was applied to netdev/net-next.git (master) by Paolo Abeni <pabeni@redhat.com>: On Fri, 21 Oct 2022 19:10:47 -0700 you wrote: > Round up allocations with kmalloc_size_roundup() so that build_skb()'s > use of ksize() is always accurate and no special handling of the memory > is needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE. > > Cc: Rasesh Mody <rmody@marvell.com> > Cc: GR-Linux-NIC-Dev@marvell.com > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> > > [...] Here is the summary with links: - [v2] bnx2: Use kmalloc_size_roundup() to match ksize() usage https://git.kernel.org/netdev/net-next/c/d6dd508080a3 You are awesome, thank you!
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index fec57f1982c8..dbe310144780 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -5415,8 +5415,9 @@ bnx2_set_rx_ring_size(struct bnx2 *bp, u32 size) bp->rx_buf_use_size = rx_size; /* hw alignment + build_skb() overhead*/ - bp->rx_buf_size = SKB_DATA_ALIGN(bp->rx_buf_use_size + BNX2_RX_ALIGN) + - NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); + bp->rx_buf_size = kmalloc_size_roundup( + SKB_DATA_ALIGN(bp->rx_buf_use_size + BNX2_RX_ALIGN) + + NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))); bp->rx_jumbo_thresh = rx_size - BNX2_RX_OFFSET; bp->rx_ring_size = size; bp->rx_max_ring = bnx2_find_max_ring(size, BNX2_MAX_RX_RINGS);