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=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham 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 C5F56C282C4 for ; Tue, 12 Feb 2019 19:21:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D6F6222C6 for ; Tue, 12 Feb 2019 19:21:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731651AbfBLTVa (ORCPT ); Tue, 12 Feb 2019 14:21:30 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:56876 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727562AbfBLTVa (ORCPT ); Tue, 12 Feb 2019 14:21:30 -0500 Received: from localhost (96-89-128-221-static.hfc.comcastbusiness.net [96.89.128.221]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 2536214C5A2ED; Tue, 12 Feb 2019 11:21:28 -0800 (PST) Date: Tue, 12 Feb 2019 11:21:20 -0800 (PST) Message-Id: <20190212.112120.214845352415845624.davem@davemloft.net> To: xiyou.wangcong@gmail.com Cc: netdev@vger.kernel.org, syzbot+4d4af685432dc0e56c91@syzkaller.appspotmail.com, syzbot+68ee510075cf64260cc4@syzkaller.appspotmail.com, jiri@resnulli.us, pabeni@redhat.com Subject: Re: [Patch net] team: avoid complex list operations in team_nl_cmd_options_set() From: David Miller In-Reply-To: <20190212055951.6712-1-xiyou.wangcong@gmail.com> References: <20190212055951.6712-1-xiyou.wangcong@gmail.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Tue, 12 Feb 2019 11:21:29 -0800 (PST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Cong Wang Date: Mon, 11 Feb 2019 21:59:51 -0800 > The current opt_inst_list operations inside team_nl_cmd_options_set() > is too complex to track: > > LIST_HEAD(opt_inst_list); > nla_for_each_nested(...) { > list_for_each_entry(opt_inst, &team->option_inst_list, list) { > if (__team_option_inst_tmp_find(&opt_inst_list, opt_inst)) > continue; > list_add(&opt_inst->tmp_list, &opt_inst_list); > } > } > team_nl_send_event_options_get(team, &opt_inst_list); > > as while we retrieve 'opt_inst' from team->option_inst_list, it could > be added to the local 'opt_inst_list' for multiple times. The > __team_option_inst_tmp_find() doesn't work, as the setter > team_mode_option_set() still calls team->ops.exit() which uses > ->tmp_list too in __team_options_change_check(). > > Simplify the list operations by moving the 'opt_inst_list' and > team_nl_send_event_options_get() into the nla_for_each_nested() loop so > that it can be guranteed that we won't insert a same list entry for > multiple times. Therefore, __team_option_inst_tmp_find() can be removed > too. > > Fixes: 4fb0534fb7bb ("team: avoid adding twice the same option to the event list") > Fixes: 2fcdb2c9e659 ("team: allow to send multiple set events in one message") > Reported-by: syzbot+4d4af685432dc0e56c91@syzkaller.appspotmail.com > Reported-by: syzbot+68ee510075cf64260cc4@syzkaller.appspotmail.com > Cc: Jiri Pirko > Cc: Paolo Abeni > Signed-off-by: Cong Wang Applied and queued up for -stable, thanks Cong.