From patchwork Tue Oct 18 09:25:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1859060wrs; Tue, 18 Oct 2022 02:30:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ZDoQofTipEL3+KnTW59otBWu09sjzhPBZh9vnl+uyERTU6LTUne5B+oRtCrAs1X19M7Wr X-Received: by 2002:a17:907:2c67:b0:78d:49d2:6297 with SMTP id ib7-20020a1709072c6700b0078d49d26297mr1651998ejc.21.1666085457569; Tue, 18 Oct 2022 02:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666085457; cv=none; d=google.com; s=arc-20160816; b=M3v1r2X6oHsfVf2bRwxUxG24SllJ1NQbvhgd2tORXyTpe9z3556rcwnLw/M8BdS4oQ fuvm4chl5PMg2yAAi1o2Zmv2Yf12uFbPBVm5RgtnbD2RpNCRrmBAtYH6lmk7Xsp+TZbM efJzoyQcHSkX+QhfraEge653I/N2s0H0HVtkBJLQiOUUARPjnkgsTYvx0+nO4zxsfs/E 5R8zIpAYTM5bGnN6LLXk/Rsf5J8Rv7vKvqwRFYyq93opEuFN9XreBEQRuWAz5MTFZOy9 HfVJULpu73/0feyiv1cPD3HcwqYD0LLeIzpAAWZcnDmHfYrZXRODo1kkGMAdNgkdnz/c wfKA== 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=smgOzVjWqVIBBGSbk+bAqgSK+ImSgqCNvhjx9z8C2ds=; b=Yd/uJ21mPkAjiHr39BVJGf/y2G8MFtGrw4niDhaRzz+vd9koZYd33ys96Z1woVXQy9 rKCrvkRWFOkEL5R6V5SSjGimkMHn988uKxSbb+PXtoHsNR/PL12BgrGQkx/spwsOZxZA nH1yeYaQ/rV9+uyzVmBMfNMOV83LvxcOFcup/0FCkIIonUwSInO8S0Y140mpcwpyxwb8 J3vFOFNkTI6+fQlZP+7f4bKxjYd6x20MCi4ZSIXiXg+lmxnbJpD5eXRLMVdsmvGcyrRD 6fh+tFo1jdI0JneL4GWarrVK3Ra3sL4zbAzq6mlYz2OwCDCn4Xp/zlS8pSEy1sXazLZC pt1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Prf7xxc8; 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 dn17-20020a17090794d100b0078e16203457si10499663ejc.5.2022.10.18.02.30.31; Tue, 18 Oct 2022 02:30:57 -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=Prf7xxc8; 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 S229998AbiJRJ0G (ORCPT + 99 others); Tue, 18 Oct 2022 05:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbiJRJZi (ORCPT ); Tue, 18 Oct 2022 05:25:38 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37CFD923C1 for ; Tue, 18 Oct 2022 02:25:30 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id b5so12808744pgb.6 for ; Tue, 18 Oct 2022 02:25:30 -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=smgOzVjWqVIBBGSbk+bAqgSK+ImSgqCNvhjx9z8C2ds=; b=Prf7xxc8c6RO6831Ks9ssdZq9ofHZAcpE0hdIQ+d1AkuWLxyhtob5UiyGEajV/rAI7 xgDSn/tg2vMoGP9+Y3mziadWZ3N28bU5CYJXHnoeTqq/NuzQMxi5gmOudYdPOw+X5Gxr ndG4v/RSevGxcD8K/0XJ67T9qNiNuXCgmy9ao= 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=smgOzVjWqVIBBGSbk+bAqgSK+ImSgqCNvhjx9z8C2ds=; b=pZPJQuA0Z1aXf6SWoVz5tHoiudq2b425VPABCXmikbCmTdrE21YO8loXn3wAnXhBwk 1dpG3H1rb3P2VS9FcAN9oCxfvi7010MjCQh5tZw5wm37ZVeSln4kxjQs0BV0WAEcbFXY ti+nb4BuJHx01SwAAmeuAgtmYpKfSPzjrdR/WBX65njtd0FDwbzEgJZT5yG9muzp3Rds JvQCb1x5IbsfS5Mn7cayW3LTQddCI956X+/KV5PsQQKOv9xWkTUrgY5vclATRUZS4wXC A6mHSrO2zZRkXDv7xjpkVI2rdZ2EnvLQV3F37U6TEnx5npn2arxww91TT20fcRmA32Cd gBRg== X-Gm-Message-State: ACrzQf0WVuWrTxGGUkLw3rJA8p/XYMglNZ6HA5Wk59i0HWX3thz74O05 mfFxQeM2FLpsBCA2tOZhbPZDPQ== X-Received: by 2002:a63:4307:0:b0:464:a24d:8201 with SMTP id q7-20020a634307000000b00464a24d8201mr1911063pga.116.1666085129704; Tue, 18 Oct 2022 02:25:29 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m20-20020a62a214000000b005609d3d3008sm9039968pff.171.2022.10.18.02.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 02:25:28 -0700 (PDT) From: Kees Cook To: Ruhl@www.outflux.net, Michael J Cc: Kees Cook , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v3 0/2] igb: Proactively round up to kmalloc bucket size Date: Tue, 18 Oct 2022 02:25:23 -0700 Message-Id: <20221018092340.never.556-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=667; h=from:subject:message-id; bh=fe46aJaXIAy8NFr6NaDoWVctMGkMgluCIMsXEg4daWs=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjTnEFofbxhgG6+Oz/mqUhGoxgqnLDQsrMFGGpTPSL oHyi/4CJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY05xBQAKCRCJcvTf3G3AJvpsD/ 9e+QOmvIyz2MVEyVrcUOvmy4j+puTP/6PIBx8eB78oe+SxMHCsGBBNxooJbXME0Mw0qM5zEHzbks7a ND4MP+VamgnU/UfGcxGX/E9VnNcPHieQmpuAikOhqYsKaFYvuVohgJhHsDKf/MevMr9ZH1Zxa/efi7 gYUQa0QhYgT6mQ8FJZHXZdpVuAa09KMktmCO28YKnF/v1/qGMJJzE5X3ekdi4lvgxw4YGXLBZuariM Ky9jvuQrz6BE1TMRWBdMadND9UaBjhOGdu2/vPI5ZmQ6fO2n8fM//mX5C8jDh8M+Fuu8JdF290B8ci lveHjW12jkXfGrnnZNLew69uvexfjw1GIJRFzqFNJR+Hmlcv4x4SSBJwxhRoVB3aTpeLiMaQJIqjau tyKUPepOLR5jKxzOVvQ+cwJigmY1E4TxY/YLpBqDU5PAnyOxxIbzSQRe2B/bkTa4WpJ5P1lqwvybLc Qn+ffjYdd23f279GWcGonSAGKCzShx0QIJ/NQTZD2a6+uSvnG0nzNJ5+PosRlr1YZxC0yGjfDrfa7D Xp5cRYOMhDXFwm+GPH23JnsrMDK4pwHAde8HAiPYp00eN1efRiOSvHjv0j0bvfQS505N7wQowiy32c mQC5kJf5z26Ib8AqFERv3eMDM5Uwbyn3NapEjQh48vEXIg4KkNwdzcKyKcrA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747017115987726968?= X-GMAIL-MSGID: =?utf-8?q?1747017224779358856?= Hi, In preparation for removing the "silently change allocation size" users of ksize(), explicitly round up all q_vector allocations so that allocations can be correctly compared to ksize(). Before that, fix a potential Use After Free under memory pressure. Thanks, -Kees v3; split UAF fix from bucket rounding. v2: https://lore.kernel.org/lkml/20220923202822.2667581-7-keescook@chromium.org/ Kees Cook (2): igb: Do not free q_vector unless new one was allocated igb: Proactively round up to kmalloc bucket size drivers/net/ethernet/intel/igb/igb_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)