Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7334853ybi; Thu, 1 Aug 2019 06:42:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMn2N6OQjPqFH+D51Gu20Wppt7luhhxQdZ6abcKlw7bNVb/7spUxOaLgeF/LEESQOFvbjo X-Received: by 2002:a17:90a:25af:: with SMTP id k44mr8688169pje.122.1564666957730; Thu, 01 Aug 2019 06:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564666957; cv=none; d=google.com; s=arc-20160816; b=greMn7hgZi4e2LusLijc2SgPZk5xyciBujD7JM2l4tvg+Om7LCsFZObLkoTee94wIP FnzxW38FHMcapN+CsYzvsRwt1UnckcU5LfldUMx8w0WWD+bVfyrt8XZXi5Fcpl9DZ3VP 4J1UX1BXVMw5MDgPP7xXO+SxW+gqsU7H9EIjqcMWgnZ1g+X9Qis2LWpDBN/N8eGRRyRj x0gHheFFaETynTfWPejJzEPIQliWyXgYoUYvtpMO2nmoKItuOznybeiUSU1hO4+5zxf4 0CxPUPWsHRQHMrRADRJThokEBV9qjGKyHxRDYCNaXYjn2gaGVKwdIcEURsySnosynl/C sTVg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=mHucje2pwaIaZTmjEqEAme8yZ6zB6T1wMjt5OiWQ1bA=; b=TNzs6mhF3jDNGbGOqKYzLLjvb0Yf+3uhMM85VCKdZMnE7jY76RnGZb9rGmwikwzn7Z ekX4mE5Zg+hXRMEJfS7qy4IZRJrMXeWnBWkZzaRWgPjqPQj5Ubc+6vptAXwtrLEkWPjI scr1P9vIAi9DHQcUPaQwCt/ZXIsR0gQjtfuP/aKefNnaYi8jWwYGFFCx0HyH2k7VwfN2 9buwRT5RPmzPojrZiuIbHkmtQDHo9UolI6wZhFqmT1vUhA3lhEvRgZxqwJikTmjNu+Ea ct+CeI7jB1Tdm11Nh1CHba4PIUbSZXdoN3j8aw1r4f48mf00Irx6/+8v0DMvWWMSi/4o gogg== ARC-Authentication-Results: i=1; mx.google.com; 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 t19si4084068pjr.68.2019.08.01.06.42.22; Thu, 01 Aug 2019 06:42:37 -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; 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 S1731106AbfHANZm (ORCPT + 99 others); Thu, 1 Aug 2019 09:25:42 -0400 Received: from mail5.windriver.com ([192.103.53.11]:38808 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730706AbfHANZm (ORCPT ); Thu, 1 Aug 2019 09:25:42 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id x71DNfDm032295 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 1 Aug 2019 06:24:18 -0700 Received: from [128.224.155.90] (128.224.155.90) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.468.0; Thu, 1 Aug 2019 06:23:40 -0700 Subject: Re: [PATCH] tipc: compat: allow tipc commands without arguments To: Taras Kondratiuk , Jon Maloy , "David S. Miller" CC: , , , , References: <20190729221507.48893-1-takondra@cisco.com> From: Ying Xue Message-ID: <605b6a6e-8bdd-c95f-ac00-9dd895fcc6a3@windriver.com> Date: Thu, 1 Aug 2019 21:12:36 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <20190729221507.48893-1-takondra@cisco.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [128.224.155.90] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/30/19 6:15 AM, Taras Kondratiuk wrote: > Commit 2753ca5d9009 ("tipc: fix uninit-value in tipc_nl_compat_doit") > broke older tipc tools that use compat interface (e.g. tipc-config from > tipcutils package): > > % tipc-config -p > operation not supported > > The commit started to reject TIPC netlink compat messages that do not > have attributes. It is too restrictive because some of such messages are > valid (they don't need any arguments): > > % grep 'tx none' include/uapi/linux/tipc_config.h > #define TIPC_CMD_NOOP 0x0000 /* tx none, rx none */ > #define TIPC_CMD_GET_MEDIA_NAMES 0x0002 /* tx none, rx media_name(s) */ > #define TIPC_CMD_GET_BEARER_NAMES 0x0003 /* tx none, rx bearer_name(s) */ > #define TIPC_CMD_SHOW_PORTS 0x0006 /* tx none, rx ultra_string */ > #define TIPC_CMD_GET_REMOTE_MNG 0x4003 /* tx none, rx unsigned */ > #define TIPC_CMD_GET_MAX_PORTS 0x4004 /* tx none, rx unsigned */ > #define TIPC_CMD_GET_NETID 0x400B /* tx none, rx unsigned */ > #define TIPC_CMD_NOT_NET_ADMIN 0xC001 /* tx none, rx none */ > > This patch relaxes the original fix and rejects messages without > arguments only if such arguments are expected by a command (reg_type is > non zero). > > Fixes: 2753ca5d9009 ("tipc: fix uninit-value in tipc_nl_compat_doit") > Cc: stable@vger.kernel.org > Signed-off-by: Taras Kondratiuk Acked-by: Ying Xue > --- > The patch is based on v5.3-rc2. > > net/tipc/netlink_compat.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c > index d86030ef1232..e135d4e11231 100644 > --- a/net/tipc/netlink_compat.c > +++ b/net/tipc/netlink_compat.c > @@ -55,6 +55,7 @@ struct tipc_nl_compat_msg { > int rep_type; > int rep_size; > int req_type; > + int req_size; > struct net *net; > struct sk_buff *rep; > struct tlv_desc *req; > @@ -257,7 +258,8 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, > int err; > struct sk_buff *arg; > > - if (msg->req_type && !TLV_CHECK_TYPE(msg->req, msg->req_type)) > + if (msg->req_type && (!msg->req_size || > + !TLV_CHECK_TYPE(msg->req, msg->req_type))) > return -EINVAL; > > msg->rep = tipc_tlv_alloc(msg->rep_size); > @@ -354,7 +356,8 @@ static int tipc_nl_compat_doit(struct tipc_nl_compat_cmd_doit *cmd, > { > int err; > > - if (msg->req_type && !TLV_CHECK_TYPE(msg->req, msg->req_type)) > + if (msg->req_type && (!msg->req_size || > + !TLV_CHECK_TYPE(msg->req, msg->req_type))) > return -EINVAL; > > err = __tipc_nl_compat_doit(cmd, msg); > @@ -1278,8 +1281,8 @@ static int tipc_nl_compat_recv(struct sk_buff *skb, struct genl_info *info) > goto send; > } > > - len = nlmsg_attrlen(req_nlh, GENL_HDRLEN + TIPC_GENL_HDRLEN); > - if (!len || !TLV_OK(msg.req, len)) { > + msg.req_size = nlmsg_attrlen(req_nlh, GENL_HDRLEN + TIPC_GENL_HDRLEN); > + if (msg.req_size && !TLV_OK(msg.req, msg.req_size)) { > msg.rep = tipc_get_err_tlv(TIPC_CFG_NOT_SUPPORTED); > err = -EOPNOTSUPP; > goto send; >