Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5397693rwb; Tue, 1 Aug 2023 01:40:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlEi+OqnFCkrWidDzvhYVpejp7eH82aGiqgu4ZrQCfqj8S+1IALx1UcJqNny5HxDD9iM4XfI X-Received: by 2002:a05:620a:4724:b0:767:eb51:ac27 with SMTP id bs36-20020a05620a472400b00767eb51ac27mr15599892qkb.5.1690879214378; Tue, 01 Aug 2023 01:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690879214; cv=none; d=google.com; s=arc-20160816; b=Az24Nv5fXuQtTnQ4lExhGyq4i5MJB9ONNWSf8gpOhS5M+/Db27xtfm9HYm8jRJ5DDg Df6c1rRnnbAkK33hJ4i8GmxNAgBZs/bJMjERRnWOBfgCYxXPOFpbye4gTlOMU2lvvGYO cM/2EIPFkVWcoyYjRAEAMG/UGwRG9iDFxlrvzXHrZcyX6dBESSytNOGG7ECYqMamGHOd CqRhvGio7YHn6JTDvtSuprLib/D/K2ytRng2L739V4wfS4fiu/L1nRvBIiigrD0Kj4kn /6niyX8TcmzXAZLkITtn9c+LOuGJGcWiF/KAWEhbDR3ARlGZ/MdK5k4m+sebLVkog+Qy uatw== 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=XSHLA6W8S96VdEQTrAOyY+5emXuHzjDlQ5fKZZ4k1Pc=; fh=g+zUEMhBxKGRZggiZwF+YEZXk7ojOyaXZdn5srI0CNw=; b=G6cWFSNfrvTmNgp6iHLkRuM3aLTwNEIdiT3oV8NYSZWJvkteNTazFXmuby+tGFzXMQ UznCib9WAzehv7FVJyOeK3zXaE6j8WW3vPXkAPHTSjMyIeYRLse0EVpBlJGi8HLX0isP xFIdVSwmC0kiPbQJhFE7kR5bVQtuxPJIV8TlklC/bP7DzHJv8Dpb9XKSBf66rMCwJLSa +TNSD+V+TFnI735rt6RtBfnOECy5a/Z/GCF+LOHNLtGCFWhKZIon5XjUE2luTaX/Wc4S s5VxKmA5f/xgZoJ3bqsP55d4aLB2LYAhC56OcOwfAhBkpv8WsFEUKKaewIqlSWUO2J1Z 3fow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EVLDGFUj; 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 u4-20020a637904000000b00563dd9b6da6si3146291pgc.718.2023.08.01.01.40.02; Tue, 01 Aug 2023 01:40:14 -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=EVLDGFUj; 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 S232105AbjHAIL1 (ORCPT + 99 others); Tue, 1 Aug 2023 04:11:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbjHAILY (ORCPT ); Tue, 1 Aug 2023 04:11:24 -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 C73B611D; Tue, 1 Aug 2023 01:11:23 -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 4D623614A6; Tue, 1 Aug 2023 08:11:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0373C433C8; Tue, 1 Aug 2023 08:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690877482; bh=OWZu55Ufaewrwq61zbQVPkXisyIVRzmtL9NXkGrrT08=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EVLDGFUjKNL9YQvEJbi0QhgdkVVETRueKCZ2xE2fcWVDSDYQjcZ3ajuQn8FA75WES QzJwkFIXIl53Hvt9giwEdNL08L9HRCrKEw4pZ3ieIyitW1B3bSZIIFjA1DSdoNNZsO /gxpzFmZuvW72e6fhmdqoFGybN5rw84F3gdG4ydJcOjopWXtNHsCtQeEqkrVAl4lRv Y9Ym7C7ibhuPCPwt2u0ZfZG66iMhiW0nNoAUH5NhRTGaeHmvy2GlP37pDtSuU2Q710 wcoQYCuFKCk0tVd78iILIpWMKQLDwpnMM8MpM3+shJ4ZL6N4nv2nfQX6Fv/4tENdGt 133UkLROCpQ1Q== Date: Tue, 1 Aug 2023 11:11:17 +0300 From: Leon Romanovsky To: Jakub Kicinski Cc: Lin Ma , davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, fw@strlen.de, yang.lee@linux.alibaba.com, jgg@ziepe.ca, markzhang@nvidia.com, phaddad@nvidia.com, yuancan@huawei.com, ohartoov@nvidia.com, chenzhongjin@huawei.com, aharonl@nvidia.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Subject: Re: [PATCH net v1 1/2] netlink: let len field used to parse type-not-care nested attrs Message-ID: <20230801081117.GA53714@unreal> References: <20230731121247.3972783-1-linma@zju.edu.cn> <20230731120326.6bdd5bf9@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230731120326.6bdd5bf9@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 31, 2023 at 12:03:26PM -0700, Jakub Kicinski wrote: > On Mon, 31 Jul 2023 20:12:47 +0800 Lin Ma wrote: > > In short, the very direct idea to fix such lengh-check-forgotten bug is > > add nla_len() checks like > > > > if (nla_len(nla) < SOME_LEN) > > return -EINVAL; > > > > However, this is tedious and just like Leon said: add another layer of > > cabal knowledge. The better solution should leverage the nla_policy and > > discard nlattr whose length is invalid when doing parsing. That is, we > > should defined a nested_policy for the X above like > > Hard no. Putting array index into attr type is an advanced case and the > parsing code has to be able to deal with low level netlink details. Jakub, IMHO, you are lowering too much the separation line between simple vs. advanced use cases. I had no idea that my use-case of passing nested netlink array is counted as advanced usage. Thanks