Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7233199ybh; Thu, 8 Aug 2019 12:13:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFlLeNFX+6hv+HSFT/JFYB6gqhMwLPNtNr2qJlpL18VpbqI2WqWaQqrreo8TjyrMV2tdH3 X-Received: by 2002:a17:902:bd06:: with SMTP id p6mr15516547pls.189.1565291630291; Thu, 08 Aug 2019 12:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565291630; cv=none; d=google.com; s=arc-20160816; b=GjRSEVZnVz5dU9yr1C1qylUSwz0d4CE5wJHLGRkx5cWmBggMcYV14ZFG0ERjNw4yE3 RLvYxUP0V9VPg1Z3yb6wbpW7s5AQ+RsTNlwjrZUOfyPNvmS2jTNGtbswoMFgup8eN1mr K/4UI9ZkuIAEIbpi6kY0QbnKP0o7zkarBc63XjBXxa48cLA+ZRKu0ZGA87ijfI5KAgYH N8ji+OI8fgqXeoeIc/X4xvCxgpjObqkweopFwGZtuse7IlrMPkEF2rGemRWcoyEypYf5 LjrzLz/D7f7c87qeYTmuK4lHRllQWXenNTNlScuZXrhD2fwUgg3GNp6qZZTyhP1YAQlw nKdA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DY7Bdbx4Y56mqihBvTd8HzQtAI1iqDXBPniKE2I06fw=; b=TGcAvqVoD6rsWPcYoHNhvRoXS3Q9tGN7JqSa7cki/17akEs5fwlPXwdaGO9oa/hN7b 7uEr9jzuPPortJDoBJw+RRdBshUkvmc6unIt9CYTzV63F5HCHvQXiGqhvK18DSsJQs0Z 8ZfESX7xRV9pLx3QgSU2OOyQj/tUQCo/ILRzQT8jGhfH+Zsd8dw9ytly5Leg2PWLra95 DLdp4eI69FSVLzkl/RmLlEMQxDu6HxNQy0SEHOYcwuTRPqgvY9Bw3hfSj8iYXTVJZ4YZ KuYuqVdkipuU68PoZyN8hXn9KnEUveqqVodxiXnuO4PbOL87dUXyh0tC3bii7W/JF2rQ F6+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fHeJFmX2; 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 y16si55648602pgj.169.2019.08.08.12.13.34; Thu, 08 Aug 2019 12:13:50 -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; dkim=pass header.i=@kernel.org header.s=default header.b=fHeJFmX2; 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 S2405003AbfHHTLD (ORCPT + 99 others); Thu, 8 Aug 2019 15:11:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:45492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405398AbfHHTLB (ORCPT ); Thu, 8 Aug 2019 15:11:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DED73214C6; Thu, 8 Aug 2019 19:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565291460; bh=ekEil7OIvosv3Ar8RW497EvnfJe5r+WgJEwJe01LqaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHeJFmX2OtfrlWJRPSL6K9Y6xx38NpCLROBZtEss1EDIqwZtFFx/1eoNhLbRCZfZI 36Np2fEf0byig+KxojeFP1hssAnqrEXtoBbst35gmUlUeQREWtvK1BeppePYSStRtt i1XnmnMqFCe/rKPcOrfuJ0qkwBi1m98rRvvaUxQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taras Kondratiuk , Ying Xue , "David S. Miller" Subject: [PATCH 4.14 22/33] tipc: compat: allow tipc commands without arguments Date: Thu, 8 Aug 2019 21:05:29 +0200 Message-Id: <20190808190454.715871628@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190808190453.582417307@linuxfoundation.org> References: <20190808190453.582417307@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Taras Kondratiuk [ Upstream commit 4da5f0018eef4c0de31675b670c80e82e13e99d1 ] 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/netlink_compat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- 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; @@ -252,7 +253,8 @@ static int tipc_nl_compat_dumpit(struct 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); @@ -345,7 +347,8 @@ static int tipc_nl_compat_doit(struct ti { 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); @@ -1267,8 +1270,8 @@ static int tipc_nl_compat_recv(struct sk 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;