From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 021C0C432C0 for ; Tue, 3 Dec 2019 23:00:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCA1C2053B for ; Tue, 3 Dec 2019 23:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575414038; bh=aC1dVxvdq8PyZZwSvJVJJu1e/NRFcdnQdCPGZ0CjNE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mPBUcOhMzMFkqu34Ef5gQaQVaJM+ESVOx/Wy3Un2bi0YZJBw9J5YJ/UtDeVMoN5Ya VUF4iiLsXhHQvE45u9Yey1DAg/by9OxXRRSxdAA9098DxR3sdUDjSZ+WmCIUSRuYKq KHj+C3E98OuNrb1poawMSgIb+30r02iJAWczCM50= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730611AbfLCXAh (ORCPT ); Tue, 3 Dec 2019 18:00:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:53142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbfLCW52 (ORCPT ); Tue, 3 Dec 2019 17:57:28 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F04520656; Tue, 3 Dec 2019 22:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575413847; bh=aC1dVxvdq8PyZZwSvJVJJu1e/NRFcdnQdCPGZ0CjNE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n7bb7fkUezNH+p0z1jNoI0hHXT9YUqpYhP61pT4RPdM2EeX3SWgxETd6HeNtxCwM4 kB+75c4DOnmTXhbGJparQLbM7BPkZoUxZgj66LyT3SN0F6t5iU4U5LgkDcLc/piEmF 5Yq+iaXicQ3UqQicLnbwuY18MGJ4y53ZlHgEMqmQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qi Jun Ding , Paolo Abeni , "David S. Miller" Subject: [PATCH 4.19 284/321] openvswitch: fix flow command message size Date: Tue, 3 Dec 2019 23:35:50 +0100 Message-Id: <20191203223441.910383949@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203223427.103571230@linuxfoundation.org> References: <20191203223427.103571230@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni [ Upstream commit 4e81c0b3fa93d07653e2415fa71656b080a112fd ] When user-space sets the OVS_UFID_F_OMIT_* flags, and the relevant flow has no UFID, we can exceed the computed size, as ovs_nla_put_identifier() will always dump an OVS_FLOW_ATTR_KEY attribute. Take the above in account when computing the flow command message size. Fixes: 74ed7ab9264c ("openvswitch: Add support for unique flow IDs.") Reported-by: Qi Jun Ding Signed-off-by: Paolo Abeni Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/openvswitch/datapath.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -697,9 +697,13 @@ static size_t ovs_flow_cmd_msg_size(cons { size_t len = NLMSG_ALIGN(sizeof(struct ovs_header)); - /* OVS_FLOW_ATTR_UFID */ + /* OVS_FLOW_ATTR_UFID, or unmasked flow key as fallback + * see ovs_nla_put_identifier() + */ if (sfid && ovs_identifier_is_ufid(sfid)) len += nla_total_size(sfid->ufid_len); + else + len += nla_total_size(ovs_key_attr_size()); /* OVS_FLOW_ATTR_KEY */ if (!sfid || should_fill_key(sfid, ufid_flags))