RE: [PATCH 07/12] igb: Proactively round up to kmalloc bucket size
From: Ruhl, Michael J <hidden>
Date: 2022-09-22 15:57:27
Also in:
dri-devel, intel-wired-lan, linux-btrfs, linux-fsdevel, linux-hardening, linux-media, linux-mm, linux-wireless, lkml, llvm
quoted hunk ↗ jump to hunk
-----Original Message----- From: dri-devel <redacted> On Behalf Of Kees Cook Sent: Wednesday, September 21, 2022 11:10 PM To: Vlastimil Babka <redacted> Cc: linux-wireless@vger.kernel.org; Jacob Shin <redacted>; llvm@lists.linux.dev; dri-devel@lists.freedesktop.org; linux-mm@kvack.org; Eric Dumazet [off-list ref]; Nguyen, Anthony L [off-list ref]; linux-hardening@vger.kernel.org; Sumit Semwal [off-list ref]; dev@openvswitch.org; x86@kernel.org; Brandeburg, Jesse [off-list ref]; intel-wired- lan@lists.osuosl.org; David Rientjes [off-list ref]; Miguel Ojeda [off-list ref]; Yonghong Song [off-list ref]; Paolo Abeni [off-list ref]; linux-media@vger.kernel.org; Marco Elver [off-list ref]; Kees Cook [off-list ref]; Josef Bacik [off-list ref]; linaro-mm-sig@lists.linaro.org; Jakub Kicinski [off-list ref]; David Sterba [off-list ref]; Joonsoo Kim [off-list ref]; Alex Elder [off-list ref]; Greg Kroah- Hartman [off-list ref]; Nick Desaulniers [off-list ref]; linux-kernel@vger.kernel.org; David S. Miller [off-list ref]; Pekka Enberg [off-list ref]; Daniel Micay [off-list ref]; netdev@vger.kernel.org; linux- fsdevel@vger.kernel.org; Andrew Morton [off-list ref]; Christian König [off-list ref]; linux-btrfs@vger.kernel.org Subject: [PATCH 07/12] igb: Proactively round up to kmalloc bucket size 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 <redacted> Cc: Tony Nguyen <anthony.l.nguyen@intel.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: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook <redacted> --- drivers/net/ethernet/intel/igb/igb_main.c | 1 + 1 file changed, 1 insertion(+)diff --git a/drivers/net/ethernet/intel/igb/igb_main.cb/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);
why not: size = kmalloc_size_roundup(struct_size(q_vector, ring, ring_count)); ? m
/* allocate q_vector and rings */ q_vector = adapter->q_vector[v_idx]; -- 2.34.1