Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7230113ybh; Thu, 8 Aug 2019 12:11:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVzTDk4AcdphadsM1QHrMjeShF1XxVkRDI9IF0Jv/s6SEcDOawglirqvbODGsPGU6MUVSv X-Received: by 2002:a63:8a49:: with SMTP id y70mr14707826pgd.271.1565291461234; Thu, 08 Aug 2019 12:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565291461; cv=none; d=google.com; s=arc-20160816; b=edgHGAgtAxEczilH5hvvQeobcdmtLBU50zXupY2P2e1m7DJ/NNLGDc2VmKNhwT7Cfd jNPZA/oY/+KhOpcI5hSw/eXshtNU8ezPTnOg1Lg8QlBJhGjLTxIMnwznPMttNpnb4Ll6 1YUFdlQ2S93B84oubtIpSccGqT7B/YUEcdyzii4Uk/1e8HUANDG9ZuT9GO7w6QXB7MMj NWto72RL+gDsAjsBp6GgAJTj8jhugqlzC5xFIN9opslxNfQXkrzoDLufb3ZzSq/0tbPi 6yOtkmRSk2te3q5xPoR0cPhqa1+mF5EhtsdTpz08qCp6Gn9Z+CXw8QUc92xAf9+T3ssy o0IQ== 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=KthpjCwjEFg+eNngTXTygWlxr5T4Jhe8jkM1IbmkkwE=; b=V8/t/doAuytG5Hb7UvoUf5dGMr79isBfQ9p8OiprxH2WqfwvD5JB3YNinm0uUnBqqD FF1btbOzm2SKJ5XCo9pe/T0ng6fguZ/xgUOrO3yTlC74/eaAVAJ03VPfKv3RjBsARqv5 EH1tfBB0n1hFNeiHEqgD0T1TanUBSwLLl89Rp61HEVtJXWYYJ8SUCWDdPgr2Q7JuS6UR 1ItwY8h1kNuZ47WuhY9IJHA9wrHY/ujCChvplwO02a7fllVbFeoVfiTYDOgtr1vi+uqr JGBjnMaCPJnhQYPtrcUYXQNtrEpVYDThIWREq9GRaA/BmiXVytdqEbJF/3LIX0pkx25g IMMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KWJ1fLhX; 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 w7si2509501pjr.65.2019.08.08.12.10.46; Thu, 08 Aug 2019 12:11:01 -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=KWJ1fLhX; 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 S2405123AbfHHTJd (ORCPT + 99 others); Thu, 8 Aug 2019 15:09:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:43836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405117AbfHHTJb (ORCPT ); Thu, 8 Aug 2019 15:09:31 -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 A6C702184E; Thu, 8 Aug 2019 19:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565291370; bh=9l2N5SIuEtZ7BOTgZYhRCMghjLx+HRbPEaw+B6lfg3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KWJ1fLhX4Q3ulDy01oGlZbOYrkJ07hqIQ9JnbeCFh49AQqDnPG77emiZPiQXrG6d8 xrVFAxu4poGZfjahm+GnohTu5LDPaK+jWqvdjZOre6LDtylUhpKrBbTed5vs7n1Yks eM/WCzPMtE56uAuWmyNMZDDkcJ/bXBtMozO6UVdE= 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.19 34/45] tipc: compat: allow tipc commands without arguments Date: Thu, 8 Aug 2019 21:05:20 +0200 Message-Id: <20190808190455.713867804@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190808190453.827571908@linuxfoundation.org> References: <20190808190453.827571908@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; @@ -257,7 +258,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); @@ -354,7 +356,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); @@ -1276,8 +1279,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;