Message ID | 20221018090628.never.537-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1852519wrs; Tue, 18 Oct 2022 02:10:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jdSx+fv/HPuqiTjR1cU8wqblnzT04gEKXi6ztVdNcrJyFnQFCvee70Hx+ku481HlQ1q6W X-Received: by 2002:a63:fd41:0:b0:438:7670:589a with SMTP id m1-20020a63fd41000000b004387670589amr1826834pgj.148.1666084256119; Tue, 18 Oct 2022 02:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666084256; cv=none; d=google.com; s=arc-20160816; b=YDkqXg8kPcqMHgTq+xkqFuc5tWu7ekIso52vYA8lJusl4ZVbfqg3wBOtbzeDIFXOIF b4gw5s1ekvfKgwvS+6lKbPz5bu4ZGVr0N6714iwZ3yqmIRl7NoP4X2aoubQDaUrLxCaE LaQ2qbJVpXUWQEc2nYwFLcNJ+xRk/y+sWBxB7jX7HisPj+Zca1ckmc8fqsIZUQOzw92/ 3Y74xVUt6DPU++pZc3mSbnjZTA16EsSb8A8iAjyMf3eW8VuJfI4cFqP5XFjhfqIY/CU8 R7sFzPzgA3MH62z1+88u9xsUd6lUMaeeHu1rSp2yCDn46TI8amy8x0zId6bpZZfoTTTI 1Vug== 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=9MOOms4QunOl/6Redp5Ge9aew4FeGkKwE9CSS5CTGUk=; b=gM4yprJoAF4xZe9vSa1Y7zY8deXPCyCj5yqUNSVBzujwAaZCMVYv3e6/rAqnAdCkxr sboP3lf+HjpGdorSeKkZxEuZAWB7JSS3iD3+hP3OEeF6dvePOrLisIGZ8ApCQtXxMNXf MDNmkwuSgMZ+vTO7B9P6NrvzYawHJihlcJXWN9chBIj64V8huxAhvoaVkDhB5vRGP5Fw FacUYzPjsJp+IzThwbFe3HI9jjmyQxccriB7/EiAdvUNYfbacMeq7uJPRhilxi2VDwXL LLy5GqiB/qXR/w8MXBjZxaaiwZ3QZj1xakkJb6iQBZPdPInSCBBwY+zyWoyh/KgEtYF0 +osg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bdWf76FJ; 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 mh8-20020a17090b4ac800b00200435da17asi24647177pjb.128.2022.10.18.02.10.44; Tue, 18 Oct 2022 02:10: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=bdWf76FJ; 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 S230214AbiJRJGi (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Tue, 18 Oct 2022 05:06:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbiJRJGg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 18 Oct 2022 05:06:36 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8232EBD for <linux-kernel@vger.kernel.org>; Tue, 18 Oct 2022 02:06:35 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id e129so12756011pgc.9 for <linux-kernel@vger.kernel.org>; Tue, 18 Oct 2022 02:06:35 -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=9MOOms4QunOl/6Redp5Ge9aew4FeGkKwE9CSS5CTGUk=; b=bdWf76FJaO1kF+hjnmXSBf/v9sJfP6NN+AVj77rOmYr/zC8IJoba7lZzu08X7MAtMl onZbwHwT2GXyaR2b/c44rjKulTveOHZojgOfs1AkYf+FxN/CXynUlvVyFJVSV3C1plZA +ElyZ5TJkZm/c3w2KMvc/gs0yEqh4f8DPd2Gw= 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=9MOOms4QunOl/6Redp5Ge9aew4FeGkKwE9CSS5CTGUk=; b=8A9S6GeCIiOSeJ1aRL2FlVRRO+NeVqNZrzl0gAgzfAc01yLQWPf8BJ9+sM4osZqwFb oiRPRbuS+ya5H6xMX1nTGso4weCNx88LWzk9kiFbQAAKNZgTNDCGAGzIytnVKxi3Hsvh Xi6Yy3jQYuvKJaJrblNi6MbGwmLb2KrYNhwAqHa/zHbQhVJ7sKLxSArGtVp/z1TvFELZ uXyVr+KgsJX3QULX/bJXtxObQ3qg88QHeO14yiWkLKhL47bHIvVc2w/wWmxHybILlXmK edkS0/Cw1bOUWUbL/aYiVI/wt5plkWCZmROAf1GlivoA+l2QhcITCnmJrM47nsH54a3Z xl8Q== X-Gm-Message-State: ACrzQf0VDfCOCfY28xzg5t7SdkQNH/3RyrFDnSGGkaScSfUpISAmDyLt ibXJ4XKIUiB1Bx/Mxga2LJpU2Q== X-Received: by 2002:a63:f924:0:b0:46b:1a7d:3b91 with SMTP id h36-20020a63f924000000b0046b1a7d3b91mr1854046pgi.133.1666083995181; Tue, 18 Oct 2022 02:06:35 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j13-20020a17090a31cd00b0020a28156e11sm10860369pjf.26.2022.10.18.02.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 02:06:34 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Pravin B Shelar <pshelar@ovn.org> Cc: Kees Cook <keescook@chromium.org>, "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, dev@openvswitch.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] openvswitch: Use kmalloc_size_roundup() to match ksize() usage Date: Tue, 18 Oct 2022 02:06:33 -0700 Message-Id: <20221018090628.never.537-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1114; h=from:subject:message-id; bh=NhjdtkVuggI88oO8Nj3gLYP4PbB5EfOeHn4wwpvKYiQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjTmyYd07vNuW7hF46ml2A2+/iXnZPwyLH4REJ4KB4 /tmTfbyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY05smAAKCRCJcvTf3G3AJqluD/ 0aRWBEoY+aCL2cVvvXRcvGOlgjAflm5NRESnXMp3Ytrxe5RKVsnitgn+q6vpSH/DQG38ZEmnsD8t2B 1Ww0ENz3AoE1LZ1RkIHoeNvaZ4/+BwWFkeeuSDqyr7pGxj5C/Q6+viPgg1gwDR2kmMbKnK2rqWmFjz ktZZalu1MKeLEXCougjT2krbZUY0N+8VOIYuCPGzZq70YE4Y56QdBTo4H8C9Oaa9MI4oJf3z4sd+TU WfENOVET6aeuD01do32M9dF4nZBNCov90BDgu/BQ30xk8bzNOpyju2gXrOhbOOqoxNb+mI47omLcB7 Iu4iqYXYufV1PicXiMVNG2KFKoAxmMm/3RK6evB3nIknqBjqvgJ9N4tflIIjdjyL+Sdl6vyKT0APvL t88jWnJPU0qIZiVRNs4NQZTJkj+tLrenYF8GWfp0kTnFxJSWHni3PozAWgcu0SLMXNvSZoWtYZCQX+ hsWc+ujLaI+sFb1B+azMbWAYFfQsKizkbs2lW0bwYMwUeEo2l6kqxi1k9tWoItDzQP8qUyfXe9L4SD epapI+7OOojqQtsyi5/T7QPKtrCLVvovLc9WqqrvchYa8BuisBoejpXE2k0oKU0KlgCH9g4orTIEd+ c9DCR4z7mwmBuFajGsC5cgQlLd51nAExgPzCNT7HXayfyuGL4ILnp1DP1M3Q== 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?1747015964645587251?= X-GMAIL-MSGID: =?utf-8?q?1747015964645587251?= |
Series |
openvswitch: Use kmalloc_size_roundup() to match ksize() usage
|
|
Commit Message
Kees Cook
Oct. 18, 2022, 9:06 a.m. UTC
Round up allocations with kmalloc_size_roundup() so that openvswitch's
use of ksize() is always accurate and no special handling of the memory
is needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE.
Cc: Pravin B Shelar <pshelar@ovn.org>
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
Cc: dev@openvswitch.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
net/openvswitch/flow_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hello: This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <kuba@kernel.org>: On Tue, 18 Oct 2022 02:06:33 -0700 you wrote: > Round up allocations with kmalloc_size_roundup() so that openvswitch's > use of ksize() is always accurate and no special handling of the memory > is needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE. > > Cc: Pravin B Shelar <pshelar@ovn.org> > 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 > Cc: dev@openvswitch.org > Signed-off-by: Kees Cook <keescook@chromium.org> > > [...] Here is the summary with links: - openvswitch: Use kmalloc_size_roundup() to match ksize() usage https://git.kernel.org/netdev/net-next/c/ab3f7828c979 You are awesome, thank you!
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index 4a07ab094a84..ead5418c126e 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c @@ -2309,7 +2309,7 @@ static struct sw_flow_actions *nla_alloc_flow_actions(int size) WARN_ON_ONCE(size > MAX_ACTIONS_BUFSIZE); - sfa = kmalloc(sizeof(*sfa) + size, GFP_KERNEL); + sfa = kmalloc(kmalloc_size_roundup(sizeof(*sfa) + size), GFP_KERNEL); if (!sfa) return ERR_PTR(-ENOMEM);