Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4056639rwo; Mon, 24 Jul 2023 23:10:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlFaM9Q4ihzBCExE5FMQpiDHbXbq+LwIiDZOfV4ZggInS7gOy3990jeaWIGPqnRzsuJO1/z+ X-Received: by 2002:a17:906:259:b0:994:1956:2331 with SMTP id 25-20020a170906025900b0099419562331mr12722207ejl.13.1690265450494; Mon, 24 Jul 2023 23:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690265450; cv=none; d=google.com; s=arc-20160816; b=MXq+1ZKrrMr8VbwQF5JbZNna4ppcil7YLK4eNNJcCSXs6vogliA40WOePQcSfm0toO 4/RLcbNTZR853jMliPhZQuQ325yYAdJdhV6PCAoZJKlOOkhBVE9AVZAyuNCTUM564O4d OiBVRrK1uSbWFFMWdBvZEgSK7WVKws0jIeCW2O8YVNGi9gdUsUYkTLaxvM2s/7wyfFyb tjUcbwxKXcRe9IzvMCr7BrainOUjsSg5yNWuABXl2l5F1bAT/2kE2BgxCqH5VsJ4Sdm0 dSAVXLRt18E4IAGqyjiz1M2OCIa5pua8dwbGFG6T+hkik1VElfOGt0GH/jeAH7NNY7ON vHNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=r1ivNWVkP40+c+8ekYarVwzw66jvoyXQ5zxZfgRzeg8=; fh=LLEtp7LUKaYIfonSyFhSAq18qAVrsdguAD73Neb23bI=; b=eZC/ITlK0ZS0c8b1b+xHfnrZGvrKDkC9Itki4dbGx8EKVcxeG49EFF+TFp7JoDSrtU /i0vU7IB5ulUreKTBIt2qmTgnLu5tnOzfcYZL47sSTBpjxc1tluuJB2z3g6dfc1fTG0H TEHEZpMOD/UyjSgNZ0EK/oNZ3TRai4G4KpzJaK5lkiuJ7h68eqT+x2EM/xM1ZvibD+ZE 9xxTqurwawQHEoC27XgpfiEcFDF1PzCj5onJiUjC+bxfbSyaO/fOJltic3KC+8maC+1/ N0SEtoE8YFoEmoUAP7KvFktRbYjBQ+EKTcG1Hsdumnwi25/PuTldyZgYhPhw/tgmhYgr z2qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tFXTRYo1; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a170906961000b009928b4e3b9esi7900796ejx.313.2023.07.24.23.10.16; Mon, 24 Jul 2023 23:10:50 -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=@kernel.org header.s=k20201202 header.b=tFXTRYo1; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231182AbjGYFlP (ORCPT + 99 others); Tue, 25 Jul 2023 01:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbjGYFlK (ORCPT ); Tue, 25 Jul 2023 01:41:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0CBB1FCA for ; Mon, 24 Jul 2023 22:40:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F01A66153B for ; Tue, 25 Jul 2023 05:40:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A12EEC433C7; Tue, 25 Jul 2023 05:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690263651; bh=VEjQx7H1H+Mb+AJoPV4BZFXw7TX8zA9RwisdpdkLNwY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tFXTRYo1hIredh5OpbIa/0sE9HPeA7+c/oG6J17Iqb7+3ofR0Zj0Mj6PmdnelcXVd 4xbcYRK408jG39EjjZQF+NI1oyAQjemYoD8HN9rk9d4R+CB1LdxuclPhx9oJ8k12xb HDpOHt1NG/1aRVJieW+CeGukcrf/9rOv6M9d3LJJP0CmvNrrH7TkQDl27SgmEUqZyr 4FBNNp6wAJA9VuMpZMysRlqUr3bQ9kGbKvmLVS1om/cD9WOzgxZwjpu1ZxexWyt/zy 8mIDWKZq57LQHlaxDZUX7F02niWvQMbDKVnnZ/s9IPRucVshhg5NLF027Tdz7nXIpc EwUDUWkAfXT6Q== Date: Tue, 25 Jul 2023 08:40:46 +0300 From: Leon Romanovsky To: Jakub Kicinski Cc: Lin Ma , jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, richardcochran@gmail.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] i40e: Add length check for IFLA_AF_SPEC parsing Message-ID: <20230725054046.GK11388@unreal> References: <20230723075042.3709043-1-linma@zju.edu.cn> <20230724174435.GA11388@unreal> <20230724142155.13c83625@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230724142155.13c83625@kernel.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 24, 2023 at 02:21:55PM -0700, Jakub Kicinski wrote: > On Mon, 24 Jul 2023 20:44:35 +0300 Leon Romanovsky wrote: > > > @@ -13186,6 +13186,9 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev, > > > if (nla_type(attr) != IFLA_BRIDGE_MODE) > > > continue; > > > > > > + if (nla_len(attr) < sizeof(mode)) > > > + return -EINVAL; > > > + > > > > I see that you added this hunk to all users of nla_for_each_nested(), it > > will be great to make that iterator to skip such empty attributes. > > > > However, i don't know nettlink good enough to say if your change is > > valid in first place. > > Empty attributes are valid, we can't do that. Maybe Lin can add special version of nla_for_each_nested() which will skip these empty NLAs, for code which don't allow empty attributes. > > But there's a loop in rtnl_bridge_setlink() which checks the attributes. > We can add the check there instead of all users, as Leon points out. > (Please just double check that all ndo_bridge_setlink implementation > expect this value to be a u16, they should/) > -- > pw-bot: cr