Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7459530rdb; Wed, 3 Jan 2024 17:47:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjuucE3xjR60JMkiI4IL1ddcvIdy0gKVfev86nAJvVgIm1ahSgqhd58wqVR2f3nSNNXbej X-Received: by 2002:a05:620a:570:b0:77f:3756:e200 with SMTP id p16-20020a05620a057000b0077f3756e200mr15566559qkp.5.1704332850076; Wed, 03 Jan 2024 17:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704332850; cv=none; d=google.com; s=arc-20160816; b=moinjQek1h6V4ed9tQNaaMs7R9+Nxe+/ghn+jY5Sp94345EEsAEJj7b+/DzbVkeyCi LzFl/a1YjBse8rGRis/qDlviaBVzI3zPAif3Kns1HioqEOKvLe7J+cP7i3YiR1kcSlDw BPV2hLeRaa8qhtceahOb829WQuV71IQ+UrUk6ykW1ZVMpbZ4VDd3CXtWMjPa+OwBBpyT U6ymRo3JThjKMfNGRUaZbVmJIpB+bIi7fC2h9MRHMp0W+/cQGD0Qbzpyp4oe7ekXiJvA nQeef06GypszZL3ENosIEF11VzI6uByP5mVYF+g23VPtUxeNTtIOFp997hT6OHeiNX7l ie1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Xxe2BpEwxXURMFw7Sx1uPae7Y0aHu44FzOaNsjRoYm0=; fh=CGo4UQ2pZ4jDcZF8DbfrQ0dhCgkw81HHyvVOJfLkTaU=; b=TK6WftxF8qhTwjScgmrn4/j8CAZqnLYVjt5KTyJmKnJR2lW9rTFOvXG+mJrYNa5n5/ 3r1TB7tWJBsLMPsfa1VZmzgvfJMDLO+MvHERN2Z2a+M9vKDl+NzmR3CPz84CkBbSt8At AYS6AI1wakCwWhzSKoHzn7Edh5C66c6tMW9AJhOaV+Wf5xbOHkAUZ1y6GmMeif64aunb GbWzwoB9yG5Hk25pYrMSYxGqwcPtkBWC+bJVrMdTRT+7J8tHc4iVbl6u09ldCET2uzL0 Qa76rKG0jG1XWiFEaL7VJISn1ZBShpuf+HsdKZtv64rk4K2ZqE2jGdCOIdTJrimDdvIq ghVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oohtoBmc; spf=pass (google.com: domain of linux-kernel+bounces-16185-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16185-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z39-20020a05620a262700b00781d197b7c8si6614504qko.625.2024.01.03.17.47.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 17:47:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16185-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oohtoBmc; spf=pass (google.com: domain of linux-kernel+bounces-16185-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16185-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D255C1C24B2B for ; Thu, 4 Jan 2024 01:47:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC8CD1C20; Thu, 4 Jan 2024 01:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oohtoBmc" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC2F91849; Thu, 4 Jan 2024 01:47:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E99EC433C7; Thu, 4 Jan 2024 01:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704332840; bh=kQ9z3YizwfzmqcFN76TVfrBEZr7D/AzQOLXak1t8Y0o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oohtoBmc4FNRxf8gicjq0J2lgUihr9zu3Nd4nQilcFpjFIUCdaX4fo4A7HI57zdir +cNAyJBuDW13TcW66roEWJ2xmCzWeXDYm7WaXMbmz1nlu7N4yHvDQQDlRBOW0Vejal lM3OseYO9O3NT6rpLzDoE4JbUPHIXavm7g53NiV9GsNCNG0p2l5YKGDqPcGtOD0Icu 13LGimTP/eqzg81Uwjho3PrmkwhPr1bynIrBmt6W036w1QDvebHRwjG3KMQzrG7/LX MmWD7h2gRn9gBxshwBwg/lie3DJwrsEL5ZZoPxGs62e/9y0pKGkkRyambFDcMy9YKs wEofqy+SmRBIQ== Date: Wed, 3 Jan 2024 17:47:19 -0800 From: Jakub Kicinski To: Lin Ma Cc: jk@codeconstruct.com.au, matt@codeconstruct.com.au, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v1] net: mctp: use deprecated parser in mctp_set_link_af Message-ID: <20240103174719.2b2c1565@kernel.org> In-Reply-To: <20231228070258.3052422-1-linma@zju.edu.cn> References: <20231228070258.3052422-1-linma@zju.edu.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 28 Dec 2023 15:02:58 +0800 Lin Ma wrote: > In mctp set_link_af implementation `mctp_set_link_af`, it uses strict > parser nla_parse_nested to parse the nested attribute. This is fine in > most cases but not here, as the rtnetlink uses *bad magic* in setlink > code, see code snippet in function `do_setlink`. > > nla_for_each_nested(af, tb[IFLA_AF_SPEC], rem) { > const struct rtnl_af_ops *af_ops; > BUG_ON(!(af_ops = rtnl_af_lookup(nla_type(af)))); <= (1) > err = af_ops->set_link_af(dev, af, extack); <= (2) > > That is, in line (1), the attribute type of af will used to look up the > af_ops, and for MCTP case will use AF_MCTP here to get mctp_af_ops. > Therefore, the attribute with type AF_MCTP will never survive in the > check within the nla_parse_nested. > > if (!(nla->nla_type & NLA_F_NESTED)) { <= nla_type is AF_MCTP > NL_SET_ERR_MSG_ATTR(extack, nla, "NLA_F_NESTED is missing"); > return -EINVAL; <= always invalid > } > > For other set_link_af users IPV4 and IPV6 both make a trick here by > using nla_parse_nested_deprecated, which will check the NLA_F_NESTED > then able to use this type field as family value. This patch simply port > the MCTP code also to deprecated parser to make it work. Did you test this? It's a suspiciously detailed and yet seemingly incorrect explanation.. -- pv-bot: s pw-bot: cr