Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp189264rwb; Wed, 21 Sep 2022 20:14:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57rIPas2DjlfkChMhcquJkh9bB4J02+4EQWN4nKVbKm2xcPDPIT2xOXxBTmylsuPVvuALn X-Received: by 2002:a17:906:4fca:b0:782:2484:6d72 with SMTP id i10-20020a1709064fca00b0078224846d72mr1075008ejw.150.1663816442590; Wed, 21 Sep 2022 20:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663816442; cv=none; d=google.com; s=arc-20160816; b=pR7rhWQysBlStw+AaeoY22JOTXEoOg1EaRz/F4qwKidlxnj4A5NUDWKMBHHLaagewP cFR3X6aF5RRcDXcBgckiFaZyw/ihv5LumTjqI1vZAZM5Tj9Ye3Um7EBG1Jyu4zTtmpOZ RxT+ivQP/hMJrlivC6xb24o8JVDk0R57F/vv90/U9Aplxvy1jtA/bt025hO2NxyBVrQ8 B/O/BxmV+qf3DDXDSod35Kxe/R8vO5Nz3BWx5Dnv19NS8J8po0RFykAl0/HU98xjBKoN LoeoiANmP9IvBJEO59uqgkvAe7JB3j+vhcjZlQS5cpZvb0wEnV/o7SL9VebmLV+8UaWc 3Ecw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KtJQxM97YBw1ybtvuETSvn7dCGYbbNyL/TMT/+SzmmU=; b=fnLZz9YXDTUv1X1hKbGkS8FVWbBhHWeaAMiGGs4af1sQQxr+PPc8X0yLkVO7rjMKFn Q0McQz+bY7RyZd6n4MC+3HKIeItlfojf63OMWv5O63Jv3ADbJQhHU0O9+oGcUuiaV08a +DGa3Zzpoh/+iMlosKbx6z7WIIHJJpCXfHZPvayHJyVFN42DMcwJtT64mejrcSPOAUoQ asloobfRaS288hwFDJNAiK/9JS/NRQSu1CfSuzMkGj8Bwm5Jyt28Ssm1RJwUZgiYWOuG hhc3J1j9oom+aLquB6FU3F16DobCWso0aSI550Ihqy/5Cz9G1Zcf/o3B4PmP3Q4wRyIg rw3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FXq499je; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd27-20020a170907629b00b0076210372a3bsi4835946ejc.333.2022.09.21.20.13.45; Wed, 21 Sep 2022 20:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=FXq499je; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 S231376AbiIVDMq (ORCPT + 63 others); Wed, 21 Sep 2022 23:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbiIVDLh (ORCPT ); Wed, 21 Sep 2022 23:11:37 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B10E90C4E for ; Wed, 21 Sep 2022 20:10:28 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id c198so7911238pfc.13 for ; Wed, 21 Sep 2022 20:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KtJQxM97YBw1ybtvuETSvn7dCGYbbNyL/TMT/+SzmmU=; b=FXq499jerICaOIudNJl9X9HvncqoZ26Rey2ZEcTHwfOsxqpZ88m1AcMNvabITl7ktf otabATcFdrn9uUfQaBz54ORv9CLq2BALyhNuHATyi853KWeUJJODBiaOX2We8TBvbr3R 089SGfE8g5vUSB25WVvFLrng0+Ij1LNA8tvzE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KtJQxM97YBw1ybtvuETSvn7dCGYbbNyL/TMT/+SzmmU=; b=qXpY9HUe5QoN23p3NdQVca9Zg48eTSYoIhVlltcg9gQD7Fe9YR2OHHDwLN4c3BJ870 74vczFFExJizWAT9GcsTPdV3FCRT01dzD6vjPjjDxYUTNbKvd+Lw/tfvO5bluznGQBT3 woz71f0Twv/yP7ABZzUaZEVuM2Y1ziTp8yMBpPbYI5l09bA8YbG4BTeLIVgKMNaFneh2 2uh8AaueGCBvGHBZZnqY7QWXp2XJ5GSh9PP9xOWy/Az3909trElgDVJrupyM2NvFaKNX XfzF41TH7ztsYtWdrfJPLgdku3756SkexyNGboMEhwKJt8blTxsxoEw2NSEeWo80nXXB 1KDQ== X-Gm-Message-State: ACrzQf0BFVQoBU7TQZfgvWBeN5uKy0/dj3Q9B5hsMucM8uZX/KBHksqN U3T4hh5Q9k2TEKzikQumzC2ugg== X-Received: by 2002:a05:6a00:174f:b0:537:6845:8b1a with SMTP id j15-20020a056a00174f00b0053768458b1amr1476359pfc.68.1663816227626; Wed, 21 Sep 2022 20:10:27 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g2-20020a17090a9b8200b002001c9bf22esm2650047pjp.8.2022.09.21.20.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 20:10:26 -0700 (PDT) From: Kees Cook To: Vlastimil Babka Cc: Kees Cook , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Greg Kroah-Hartman , Nick Desaulniers , Alex Elder , Josef Bacik , David Sterba , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Daniel Micay , Yonghong Song , Marco Elver , Miguel Ojeda , Jacob Shin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org, dev@openvswitch.org, x86@kernel.org, linux-wireless@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 07/12] igb: Proactively round up to kmalloc bucket size Date: Wed, 21 Sep 2022 20:10:08 -0700 Message-Id: <20220922031013.2150682-8-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220922031013.2150682-1-keescook@chromium.org> References: <20220922031013.2150682-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1355; h=from:subject; bh=GnGo60Q8Ey4t/45rZVkHHXQYJiJECnGYVFTtoXWQ73Y=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjK9ITjdxbzH7GftOj5prz+63FJ1nPbhwlH4IVeCtD 8ED2tMyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYyvSEwAKCRCJcvTf3G3AJjCiD/ wMJri5QLOOqouOEh6gNHJttRS42p0Og0uXHFXBpfBrQHVdMA/pZ7vM6aplEkCSzfpBRS9ns48N68wS jcAXVJGdtoRra0fSdkwT4D/eNkhKa/DLtxD0AIjix8HXBLfF0xblfFujjMTn2AcNU0TIoJNpYb7VgX k5ga7gxgqR6sqMlNaFb5qthk1BfSfBFjP5XdVSZtQjZHuc1xAXbYyBzlTYP5PHfAzBhZdVwZxDKAoh HLy++A+AphN0n4DVADlQ2Pn0+VZTZBXDRRAYBIKxn4mFfjNlexbTZx9K9vi+BB/QWW7WFQR851SPy2 H0AIW6jGUmqOlFp42ZjG32ra+NQrzMdB3SHS0UCKvWrHcgGOij3jZloSaDZ9TqEk86JUA2eNTV8EsO H2dRnVfemfa8X8YeGg5PS19OLC7pnOJYipxZfBdX5FrqP2SnHC2IqAqpLlOfeapo5yjFQdZZY/QeMW aYDixd+87XW69dT3Y8AMCAHA74UZNFOpQ96K/S/nwAMoGRQVUKRicu3fOrBwssRCIoAd24pldFMqg3 1lPT3qVVTF1IPhnR4vQ3RQJihuPUWjOP3S+3lH2U15ueKvZmGmjl7MCHI2RUE87+c+TqOb87PwG6fW eepaAJi+LmbVjbB1PG3ptYHjsDDSkTgUtQRqZ0fL/ZAxrsHf91M5rKLsQBig== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit 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-wireless@vger.kernel.org Instead of having a mismatch between the requested allocation size and the actual kmalloc bucket size, which is examined later via ksize(), round up proactively so the allocation is explicitly made for the full size, allowing the compiler to correctly reason about the resulting size of the buffer through the existing __alloc_size() hint. Cc: Jesse Brandeburg Cc: Tony Nguyen Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- drivers/net/ethernet/intel/igb/igb_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 2796e81d2726..4d70ee5b0f79 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -1196,6 +1196,7 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter, ring_count = txr_count + rxr_count; size = struct_size(q_vector, ring, ring_count); + size = kmalloc_size_roundup(size); /* allocate q_vector and rings */ q_vector = adapter->q_vector[v_idx]; -- 2.34.1