From patchwork Tue May 9 12:12:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yotam Gigi X-Patchwork-Id: 760064 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wMdSp1JHyz9s7C for ; Tue, 9 May 2017 22:08:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753341AbdEIMIz (ORCPT ); Tue, 9 May 2017 08:08:55 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:52560 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752858AbdEIMIy (ORCPT ); Tue, 9 May 2017 08:08:54 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yotamg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 9 May 2017 15:08:50 +0300 Received: from dev-r-vrt-156.mtr.labs.mlnx (dev-r-vrt-156.mtr.labs.mlnx [10.212.156.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v49C8o58031098; Tue, 9 May 2017 15:08:50 +0300 From: Yotam Gigi To: davem@davemloft.net, zhangshengju@cmss.chinamobile.com, roopa@cumulusnetworks.com, sd@queasysnail.net, bblanco@plumgrid.com, minipli@googlemail.com, tklauser@distanz.ch, nogahf@mellanox.com, moshe@mellanox.com, rshearma@brocade.com, daniel@iogearbox.net, netdev@vger.kernel.org Cc: Yotam Gigi , David Ahern Subject: [PATCH net] rtnetlink: Fix the IFLA_PHYS_PORT_NAME TLV to include terminating NULL Date: Tue, 9 May 2017 15:12:02 +0300 Message-Id: <1494331922-16451-1-git-send-email-yotamg@mellanox.com> X-Mailer: git-send-email 2.4.11 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The IFLA_PHYS_PORT_NAME rtnetlink TLV length does not include the terminating NULL character, which is different from other string typed TLVs. Due to the fact that libnl checks for the terminating NULL in every string typed attribute, it crashes on every RTM_GETLINK response on drivers that implement ndo_get_phys_port_name. Make the fill_phys_port_name function include the terminating NULL in the TLV size by using the nla_put_string helper function. Fixes: db24a9044ee1 ("net: add support for phys_port_name") Signed-off-by: Yotam Gigi Cc: David Ahern Reviewed-by: Ido Schimmel Acked-by: Jiri Pirko --- Please consider this for stable too. Thanks! --- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index c4e84c5..69daf39 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1056,7 +1056,7 @@ static int rtnl_phys_port_name_fill(struct sk_buff *skb, struct net_device *dev) return err; } - if (nla_put(skb, IFLA_PHYS_PORT_NAME, strlen(name), name)) + if (nla_put_string(skb, IFLA_PHYS_PORT_NAME, name)) return -EMSGSIZE; return 0;