Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp577615img; Fri, 22 Mar 2019 04:24:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGQ3PVStjCDWDIOxG5h6z5Zo3K0kROdrYh+WzEG1o0iGPgMqqrxz46cJWml7B9o7EAPWM6 X-Received: by 2002:a65:6645:: with SMTP id z5mr8534835pgv.251.1553253890355; Fri, 22 Mar 2019 04:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253890; cv=none; d=google.com; s=arc-20160816; b=wQP1ENisQh4m4EIA42r9dOb4cgW9doqJK4IhAhoM3DuLwMvGhYFsp55/SWmQnhRJvo UaQv84SHESgTsfYw3lpnO+BSRqjiiMxjUpLzmTyDLG1YujdiFMmOwxtGRjxeEM2W6Tf6 ZozMf3wx1zsRUoBNgunqktY/e7zDGu5zZ+hAbnJ5RaynlVUg1g8fDlfVD7uYkHAaU/9d H6jR174bV5aCqxi4LeOsPmRQ3dJgESbYTdUhWAv2JEzPkSa4xDyotgDL7Qg2Q6fC3E+9 RHBBg+RHb4g8+CMNkWPxMYFlf9jOlyT6fP1vOGvtyuEpehx0rsfwZRFWQIP78C5EFFcl QEFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=09ZhGa6qM5e4xkj0YFuuBAi0KvgJNlq1OeGkwU6+KCc=; b=UkHKdtbUJy+gfC2VLzEAb90kQtG/YPKQWZ0XApA78ns5A+jBhs/jTPDdnzo4RqxyxS 8NviR5+xRfXwMTYav6cr0ZgJFB8ZLBPuaZS3sMr1BSrGUKVn1fRCO5FHc8AVvWRLpkab /pxgE7bN/Nn0pwbB88t+tsZukhReyfqIbkfm4ya3UiQFko/LJjIxAcJpZvuZQqIz6B3g VADUb8T9dEm+AByRtyYZoCTbZl7mGVyRCSoPG3TwkCEtfIWQfDSdBH7O+Ytm3qJcEKB3 gPsitOnoq38BKcKN/FfAubgsAPUPy9G/x4afwwTnRIo8kp7+cEZQ3nFpDzUUYkz75BK4 xxjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="X/zNJ0wy"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si167747pgm.385.2019.03.22.04.24.31; Fri, 22 Mar 2019 04:24:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="X/zNJ0wy"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728844AbfCVLWl (ORCPT + 99 others); Fri, 22 Mar 2019 07:22:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:49412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728433AbfCVLWj (ORCPT ); Fri, 22 Mar 2019 07:22:39 -0400 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 94343218A2; Fri, 22 Mar 2019 11:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253758; bh=xYAgpWuhEuPMuRRw9l0jnGZQh/OXyZAEHAfzLG9nCnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X/zNJ0wykq5t/jxw6wZyuKLVB5UTMNreOz3z/UM+jcq+aJ86t6tcnRIs0hEdOshJn AvrvfVNDaF/GpFcnmdzEP42l7PJFboDattvV5HEdyNlF6u6rIWHnF2e3i96dFp1VZL cuM2OC+m/PXMngPuXMvoKyYojNjVQeGZBXY7cw0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Amit Cohen , Jiri Pirko , "David S. Miller" Subject: [PATCH 3.18 046/134] team: Free BPF filter when unregistering netdev Date: Fri, 22 Mar 2019 12:14:19 +0100 Message-Id: <20190322111213.236043976@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ido Schimmel [ Upstream commit 692c31bd4054212312396b1d303bffab2c5b93a7 ] When team is used in loadbalance mode a BPF filter can be used to provide a hash which will determine the Tx port. When the netdev is later unregistered the filter is not freed which results in memory leaks [1]. Fix by freeing the program and the corresponding filter when unregistering the netdev. [1] unreferenced object 0xffff8881dbc47cc8 (size 16): comm "teamd", pid 3068, jiffies 4294997779 (age 438.247s) hex dump (first 16 bytes): a3 00 6b 6b 6b 6b 6b 6b 88 a5 82 e1 81 88 ff ff ..kkkkkk........ backtrace: [<000000008a3b47e3>] team_nl_cmd_options_set+0x88f/0x11b0 [<00000000c4f4f27e>] genl_family_rcv_msg+0x78f/0x1080 [<00000000610ef838>] genl_rcv_msg+0xca/0x170 [<00000000a281df93>] netlink_rcv_skb+0x132/0x380 [<000000004d9448a2>] genl_rcv+0x29/0x40 [<000000000321b2f4>] netlink_unicast+0x4c0/0x690 [<000000008c25dffb>] netlink_sendmsg+0x929/0xe10 [<00000000068298c5>] sock_sendmsg+0xc8/0x110 [<0000000082a61ff0>] ___sys_sendmsg+0x77a/0x8f0 [<00000000663ae29d>] __sys_sendmsg+0xf7/0x250 [<0000000027c5f11a>] do_syscall_64+0x14d/0x610 [<000000006cfbc8d3>] entry_SYSCALL_64_after_hwframe+0x49/0xbe [<00000000e23197e2>] 0xffffffffffffffff unreferenced object 0xffff8881e182a588 (size 2048): comm "teamd", pid 3068, jiffies 4294997780 (age 438.247s) hex dump (first 32 bytes): 20 00 00 00 02 00 00 00 30 00 00 00 28 f0 ff ff .......0...(... 07 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 ........(....... backtrace: [<000000002daf01fb>] lb_bpf_func_set+0x45c/0x6d0 [<000000008a3b47e3>] team_nl_cmd_options_set+0x88f/0x11b0 [<00000000c4f4f27e>] genl_family_rcv_msg+0x78f/0x1080 [<00000000610ef838>] genl_rcv_msg+0xca/0x170 [<00000000a281df93>] netlink_rcv_skb+0x132/0x380 [<000000004d9448a2>] genl_rcv+0x29/0x40 [<000000000321b2f4>] netlink_unicast+0x4c0/0x690 [<000000008c25dffb>] netlink_sendmsg+0x929/0xe10 [<00000000068298c5>] sock_sendmsg+0xc8/0x110 [<0000000082a61ff0>] ___sys_sendmsg+0x77a/0x8f0 [<00000000663ae29d>] __sys_sendmsg+0xf7/0x250 [<0000000027c5f11a>] do_syscall_64+0x14d/0x610 [<000000006cfbc8d3>] entry_SYSCALL_64_after_hwframe+0x49/0xbe [<00000000e23197e2>] 0xffffffffffffffff Fixes: 01d7f30a9f96 ("team: add loadbalance mode") Signed-off-by: Ido Schimmel Reported-by: Amit Cohen Acked-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/team/team_mode_loadbalance.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/drivers/net/team/team_mode_loadbalance.c +++ b/drivers/net/team/team_mode_loadbalance.c @@ -305,6 +305,20 @@ static int lb_bpf_func_set(struct team * return 0; } +static void lb_bpf_func_free(struct team *team) +{ + struct lb_priv *lb_priv = get_lb_priv(team); + struct bpf_prog *fp; + + if (!lb_priv->ex->orig_fprog) + return; + + __fprog_destroy(lb_priv->ex->orig_fprog); + fp = rcu_dereference_protected(lb_priv->fp, + lockdep_is_held(&team->lock)); + bpf_prog_destroy(fp); +} + static int lb_tx_method_get(struct team *team, struct team_gsetter_ctx *ctx) { struct lb_priv *lb_priv = get_lb_priv(team); @@ -619,6 +633,7 @@ static void lb_exit(struct team *team) team_options_unregister(team, lb_options, ARRAY_SIZE(lb_options)); + lb_bpf_func_free(team); cancel_delayed_work_sync(&lb_priv->ex->stats.refresh_dw); free_percpu(lb_priv->pcpu_stats); kfree(lb_priv->ex);