Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1546575rwb; Fri, 23 Sep 2022 14:31:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM45OeJ8pR1Uda7Hhfh0EFQxzQERpKAhk9ps+XgZjpLuc+AmtrUoNIszByHvIOuDo3YkZ0T9 X-Received: by 2002:a63:90c9:0:b0:434:b578:3bb4 with SMTP id a192-20020a6390c9000000b00434b5783bb4mr8900888pge.389.1663968716069; Fri, 23 Sep 2022 14:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663968716; cv=none; d=google.com; s=arc-20160816; b=UBJ793kQ7jyM3hxvpQuwIrO2SoXDcfPAH29iGp4whZogdPM3NDa3TerefLnOFxiFD7 6F0TGfHEXUJy2AjZzQN473gDBDXw5qucokAii9nq12VL/7bhsAXcMSmYhHJ1ZcyOzCwk Jy/LaJNEqmloW6YdlD1jDXqmxbDfbuKVrcn4kBcOBkc6EQ8Tx0sXA2HnM6xtcw+PI85B MmDPVDgjNP4FyvMicT0jKm74ylQ/RVoKAmCUteXuGaDksNnmD13kcGbATvj5u3OAcu2+ gf5PU9fDG3bvy3SDgaxSgYRBc2WxMBMQdqoV+Fg/55SXuU2rNezBl2xtyiNy5uckgHug TtzQ== 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=PCPU7pjQsz2sISTfhiNbNnCu1P7dpEEV5lOobjZTacw=; b=J5gJWwQOCtYFnReNyHZK4/LLtOM8ieEpFMnoVpBtpJ3YdugdLcrGKY9G7v/SSSF52F Gm0h/NpAjH3trO1jovEfK/OdSCR3fAAgTei9liBV9gghadX/7jAMRrkn7bB0RBo+5GIr hv/TGAAdLGi0zyvuiJIhpbN0uGDhY47uGPyYykoQZFzoVAuQpN/QkuvofftnIbIr16gg kPawmRJgohv1Uwh1fJmWPYrW05TcJUtCnd3Jps0FHBL86jxbR/FaBMz9G226pCc+oWIt lqF8nLS8ihBfS+KhZeV+B2+8MvaWlAgbRuDV1nIw81HPxCf9noqlYYjx8BoZ5RGv+RCD OIjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Iu9IAyDu; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m22-20020aa79016000000b0053e7a11f6d1si10287077pfo.91.2022.09.23.14.31.41; Fri, 23 Sep 2022 14:31:56 -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=Iu9IAyDu; 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 S233267AbiIWUfV (ORCPT + 99 others); Fri, 23 Sep 2022 16:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232897AbiIWUcv (ORCPT ); Fri, 23 Sep 2022 16:32:51 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8854614C053 for ; Fri, 23 Sep 2022 13:28:34 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id jm5so1141283plb.13 for ; Fri, 23 Sep 2022 13:28:34 -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=PCPU7pjQsz2sISTfhiNbNnCu1P7dpEEV5lOobjZTacw=; b=Iu9IAyDuLzG+6v/Qe/VDx2yB77cAoW4xXxxoWLwcPs2hQ2vdFhoGM7rk54C0JPoyAN AaLg5lQQvhHAFcTmsUdZWlK9hHQlqBPwPeDuvjvIf+b16rmlZZjb/iy/HTS0LU78apjW nLGtaiMCoXEcj1ad5zoxgqn0DT23BivJkRE/I= 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=PCPU7pjQsz2sISTfhiNbNnCu1P7dpEEV5lOobjZTacw=; b=ZayTmI/2RvJ+/0/UvIVJVFjiMd6vNdezYuJwy2S3nZh8a5KDiOrLlo4yO6zGZUOETu AsDuC4DhFkV8hcKr/c8zxsohVbeukU5eStctjgpthVytzaCMEBHQD6vAvVV3BlcboPdH YVsZtNPu2Z1tIxm/4MhOzls5L+bCXCMVrJFOGEJsazo9h0gN3fyy/BCZu5xJY+C2Iz0E uJXl/zUDKj74RWubeB/DtqYf72Wj7wTtgPdfkSmdMZmcyF/Phat37iD9tMTMffwNMHKj cXO8KX0CC8YfZVmVAdGg5Iw9XHSzJWIu6wlNOup1TpjyEwKwlkse2pXziBTXvbSn/qDe qSkw== X-Gm-Message-State: ACrzQf2k9rGm+bpr2eot0WEVqNEhl0Ki384JdxtG34zKX2P24eLqURT1 ZoypzvGFohq28tcK9xK8HFADvg== X-Received: by 2002:a17:90b:4b09:b0:202:ad77:9ee1 with SMTP id lx9-20020a17090b4b0900b00202ad779ee1mr11743471pjb.10.1663964914034; Fri, 23 Sep 2022 13:28:34 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id p67-20020a622946000000b00528bd940390sm6579869pfp.153.2022.09.23.13.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 13:28:32 -0700 (PDT) From: Kees Cook To: Vlastimil Babka Cc: Kees Cook , Andrew Morton , linux-mm@kvack.org, "Ruhl, Michael J" , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Greg Kroah-Hartman , Nick Desaulniers , Alex Elder , Josef Bacik , David Sterba , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Jesse Brandeburg , Daniel Micay , Yonghong Song , Marco Elver , Miguel Ojeda , linux-kernel@vger.kernel.org, netdev@vger.kernel.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, intel-wired-lan@lists.osuosl.org, dev@openvswitch.org, x86@kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH v2 13/16] mempool: Use kmalloc_size_roundup() to match ksize() usage Date: Fri, 23 Sep 2022 13:28:19 -0700 Message-Id: <20220923202822.2667581-14-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220923202822.2667581-1-keescook@chromium.org> References: <20220923202822.2667581-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=821; h=from:subject; bh=1Gas3SCsMDWgBChil0VwFgY9Fr6zuZgi/zbZ+v/amZU=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjLhblw9hPBOt2abeHvNz251QmxKrK5qZ9E2npmHln zyeWomSJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYy4W5QAKCRCJcvTf3G3AJoKkD/ 0Rw7ftGkpv6Cp14LlheghY8ULuROeYsl+xBHJIECYJxb7Zj7xNiTAKJPkYJG2rfH7dJMP4mnVCyvlE aX9DI2jRbF0DpDm8X4kNTAYLiAnekyLGRBI1uuwyosPWzFt5fthMVPKTGw4skU5eJeoliXwvKRjc7w H2hvKX03v8bjW2hWSueT4lkm2RIg4t4qCd7tAHcfkVFPluuXqkRyHl5jKKj/gvloXfr0a7NEcoK6+B OMr9c7RIevNvATAWl7BVsl1C+sgXBlqnebMSX5UB3sQFDThE2TOU6PM8pwx2uGkviWtrIORGwdnrqF 0BWUxYm3S7RgbB0E08f07OQbs6iZbOosdIECqTf8jwkxFWpqXk+ywZexmptnljyesSCsq4Q45yeVtp CivmXPCHnnW/ltVIwlzqLXkKSA1ANCZugfA9MQMfNYzYLJmYhU2oE75hyFkzyLL6O7DnVutl/lmgOX 3BjHh5o+PuSYbw4gy0xL95tSHEokwlTTS9maudQ7pyB/lQFm8Got/UmZKScGYd6rVWQ+NR3+w3ud3e oz3kjiT0YzaO+sAjrsJDYKalavBaxhajZL8QMmPOZRL6XigFy+8x9O7y3Ji6lN4tryxNvAYJ08zYoV GZZ+QW0vnk/Etuibtx0IyAfth89gRlflFdIp1c7NouB249gCifAsYbMMOFbA== 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-kernel@vger.kernel.org Round up allocations with kmalloc_size_roundup() so that mempool's use of ksize() is always accurate and no special handling of the memory is needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE. Cc: Andrew Morton Cc: linux-mm@kvack.org Signed-off-by: Kees Cook --- mm/mempool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mempool.c b/mm/mempool.c index 96488b13a1ef..0f3107b28e6b 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -526,7 +526,7 @@ EXPORT_SYMBOL(mempool_free_slab); */ void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data) { - size_t size = (size_t)pool_data; + size_t size = kmalloc_size_roundup((size_t)pool_data); return kmalloc(size, gfp_mask); } EXPORT_SYMBOL(mempool_kmalloc); -- 2.34.1