Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp917060pxb; Wed, 6 Apr 2022 04:12:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTjX7eFE1oSKzBRJkVrm6llEFQaT5jQE4DLCR4HlykRzA7/+oPfB+blWoNdn2LYY8RwrZG X-Received: by 2002:a17:902:da91:b0:153:cc84:f13f with SMTP id j17-20020a170902da9100b00153cc84f13fmr8055102plx.38.1649243576091; Wed, 06 Apr 2022 04:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649243576; cv=none; d=google.com; s=arc-20160816; b=OlvCwxP1VHn/l2Do6DM66p4+og8eNd8+P2sDpdp1UXQ63LuSKoSwnjp4DDb339S/IM xuOpH4SWNihML2cCQAzldAz/XxPsjyvEHBETbFjkBnKNV+QcN8Z/fy4hiLOeLRg90crR wbeKJ7B/3ltkLLMXnpo4AYu1ifHmLi59fMtgCShgNIDvodssfY35OOgcboa2Lx8/vFBp R9lMU/KbiHQm20ufF50yw+NWG0yf3u+342aDqfdd3E7FYCOspXF/wx3EMSGw3vaZQbNH laZl2SG4hr/IxNzrzznk7brYtQ0zfRu5i8gFyrBTB2W5t8KlDMV+01t+IU8Gy4UwaXRS T7xQ== 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 :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=MieTPQFs8VOXyiBgZhn9rhV52nQUcA3L833nsfzanM8=; b=Ej/+30Nbrx/efLuHOs9V7VgXG3imjwvgShuccurKEtGefR3LSKVEOrpnopSZuY1M2l Vu1IzOVrRcu6MvcN4bRrKcmahocCTVMzX/9IhKsomFp/Pu6SMj+hwkiPWAZ3aG4F44bP 3PB4877cTErGrwLRMj7dP8aLmYgsUwlcBtVEh4IkxfPU5PAGNpMWQ0K7oUnFxdzEMPgW Rkqpui73Sk+lhJIeRjH7cGqBmHBPn0OWA/eg73Ac14nSvDbD9tYA7jyZhByRioxmBT0M XMVszw9iqFVSsAYF4yfKgrVHBv3XNZDUyzWuS9G8aJwn5kARQHrsQnhKioDUh6FXqLhO HULQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KEw28suM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c2-20020a631c02000000b00399577e28cbsi5096658pgc.17.2022.04.06.04.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:12:56 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KEw28suM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C1C1D4DEE12; Wed, 6 Apr 2022 02:38:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1579694AbiDEXcj (ORCPT + 99 others); Tue, 5 Apr 2022 19:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242634AbiDEN6t (ORCPT ); Tue, 5 Apr 2022 09:58:49 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 929B414FBB6 for ; Tue, 5 Apr 2022 05:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649163422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MieTPQFs8VOXyiBgZhn9rhV52nQUcA3L833nsfzanM8=; b=KEw28suMJ2GfuTfTThG/vrfhgsT0fmEWPDfdZADCl2Mx5puB3+oJpz3CSlYAjdk76MgoQX ux60uBPa1DD1U8DAbx6kalPUR6Z6HMJ2kEZnZBOkjUPwkSbFVvXQi3WJSzfpOrjyvtbQTf ZDgntC6G0jlJMA695p8o3unMIwK6PPI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-nOsaf9cQOtq3c5ulp4vhag-1; Tue, 05 Apr 2022 08:56:59 -0400 X-MC-Unique: nOsaf9cQOtq3c5ulp4vhag-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE8FF3C1EA4D; Tue, 5 Apr 2022 12:56:58 +0000 (UTC) Received: from RHTPC1VM0NT (unknown [10.22.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6F5DB40CF8E5; Tue, 5 Apr 2022 12:56:58 +0000 (UTC) From: Aaron Conole To: Ilya Maximets Cc: netdev@vger.kernel.org, dev@openvswitch.org, linux-kernel@vger.kernel.org, Jakub Kicinski , Paolo Abeni , "David S. Miller" Subject: Re: [ovs-dev] [PATCH net] net: openvswitch: fix leak of nested actions References: <20220404154345.2980792-1-i.maximets@ovn.org> Date: Tue, 05 Apr 2022 08:56:52 -0400 In-Reply-To: <20220404154345.2980792-1-i.maximets@ovn.org> (Ilya Maximets's message of "Mon, 4 Apr 2022 17:43:45 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Ilya Maximets writes: > While parsing user-provided actions, openvswitch module may dynamically > allocate memory and store pointers in the internal copy of the actions. > So this memory has to be freed while destroying the actions. > > Currently there are only two such actions: ct() and set(). However, > there are many actions that can hold nested lists of actions and > ovs_nla_free_flow_actions() just jumps over them leaking the memory. > > For example, removal of the flow with the following actions will lead > to a leak of the memory allocated by nf_ct_tmpl_alloc(): > > actions:clone(ct(commit),0) > > Non-freed set() action may also leak the 'dst' structure for the > tunnel info including device references. > > Under certain conditions with a high rate of flow rotation that may > cause significant memory leak problem (2MB per second in reporter's > case). The problem is also hard to mitigate, because the user doesn't > have direct control over the datapath flows generated by OVS. > > Fix that by iterating over all the nested actions and freeing > everything that needs to be freed recursively. > > New build time assertion should protect us from this problem if new > actions will be added in the future. > > Unfortunately, openvswitch module doesn't use NLA_F_NESTED, so all > attributes has to be explicitly checked. sample() and clone() actions > are mixing extra attributes into the user-provided action list. That > prevents some code generalization too. > > Fixes: 34ae932a4036 ("openvswitch: Make tunnel set action attach a metada= ta dst") > Link: https://mail.openvswitch.org/pipermail/ovs-dev/2022-March/392922.ht= ml > Reported-by: St=C3=A9phane Graber > Signed-off-by: Ilya Maximets > --- Acked-by: Aaron Conole