Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3284980pxk; Mon, 21 Sep 2020 09:41:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/AZCXlJvUSqTvgirLozdYPpCRZw6anDwzpZ4xMRDho0U+X7vfvRfEEz84GIDwt4iwC0rR X-Received: by 2002:a50:f197:: with SMTP id x23mr502259edl.367.1600706460416; Mon, 21 Sep 2020 09:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706460; cv=none; d=google.com; s=arc-20160816; b=li2Vm6VB4p6Re6+iiRWItWGURO++650/ypoVjaP9hB7A6JRmkKHqwIpo4kN6AJBHN+ KpLc+vAUUpX25yVhGk+9T0OfC3WciVkD2fcqQCZDM1NiN7JwgmOnBu+Pt+Iop9HNGTsD PF192+V7cfqQwGalQ8Zv2VrUCHd4DvpbyOa0MmTKwzoq6SK52Xydv4loHh9URVGYSpeN JjpfvjAIGRY3pmpWa3v3zYN3WQXwvx5IAhGVsa5SYhneoH71I7JcDaV8qAuq604q/zxv 1Hff3oQFp4D+/nr/K//G3u0ddnBEjvOw+10lOhfe8fYUTkzeDiT3CrHfUBeYmT8Br9IQ NxBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=672gUrEgD6utncNRF8a6et3IdeRrz+RtBvS4ziYGol8=; b=bamO3dHdGeydaR4wZQ62U7fhWBW3pEg0cs+lAaRp9A1xW9nuCQWjRL/XFt7Uo43SmO zKfmQlxL4tT15P62JoWIbmnyCcHWrwf5CvutZk9/47bru3SKvBTtHLdg1r0HfGMJA1Cl FussNtYhmcKokdd2E9FOg2qwQtvBbbpiTGYmfBXdnpprEFG6gha8oNnajWcb3g8UC7Fa wxgmO3C9MMnZdoIdieFUioqsc2RO2AiIwWwY2UDfFVOo9Jr8fDAHtbGHwylTPERPV38D gyyEy2ujWIAPXVjaPGsavjIYoQYjOgZNwZy7ObxLTkwOMhpxljNc6lSaXvJ84+f7Zx1C Vnkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LatMboJN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si8639013ejc.26.2020.09.21.09.40.36; Mon, 21 Sep 2020 09:41:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LatMboJN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728753AbgIUQii (ORCPT + 99 others); Mon, 21 Sep 2020 12:38:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:39458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729114AbgIUQiY (ORCPT ); Mon, 21 Sep 2020 12:38:24 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 590D4238EE; Mon, 21 Sep 2020 16:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706303; bh=OB6E9YQNC9G0IHnrJsWk7F4uIibOH09LZsdA+Y2YVpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LatMboJNzKwE7Ee88Dbu4oIfD2icof3Ry4UGsSUuaShpyNm+EFFEUuBRjfiD7qoRw txVuiLbCd0yR5c2g2QpKCqPkfAf9wxy5Vk3stE8O15Cmk972pVg1ezR/582ILYWt8x CEZgiDx4+u8G2QW4BOknl4NtPT8t1Y1ZvH1PQeVU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe , Yi Zhang , Bart Van Assche Subject: [PATCH 4.14 46/94] RDMA/rxe: Fix the parent sysfs read when the interface has 15 chars Date: Mon, 21 Sep 2020 18:27:33 +0200 Message-Id: <20200921162037.664354069@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162035.541285330@linuxfoundation.org> References: <20200921162035.541285330@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yi Zhang commit 60b1af64eb35074a4f2d41cc1e503a7671e68963 upstream. 'parent' sysfs reads will yield '\0' bytes when the interface name has 15 chars, and there will no "\n" output. To reproduce, create one interface with 15 chars: [root@test ~]# ip a s enp0s29u1u7u3c2 2: enp0s29u1u7u3c2: mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000 link/ether 02:21:28:57:47:17 brd ff:ff:ff:ff:ff:ff inet6 fe80::ac41:338f:5bcd:c222/64 scope link noprefixroute valid_lft forever preferred_lft forever [root@test ~]# modprobe rdma_rxe [root@test ~]# echo enp0s29u1u7u3c2 > /sys/module/rdma_rxe/parameters/add [root@test ~]# cat /sys/class/infiniband/rxe0/parent enp0s29u1u7u3c2[root@test ~]# [root@test ~]# f="/sys/class/infiniband/rxe0/parent" [root@test ~]# echo "$(<"$f")" -bash: warning: command substitution: ignored null byte in input enp0s29u1u7u3c2 Use scnprintf and PAGE_SIZE to fill the sysfs output buffer. Cc: stable@vger.kernel.org Fixes: 8700e3e7c485 ("Soft RoCE driver") Link: https://lore.kernel.org/r/20200820153646.31316-1-yi.zhang@redhat.com Suggested-by: Jason Gunthorpe Signed-off-by: Yi Zhang Reviewed-by: Bart Van Assche Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -1178,7 +1178,7 @@ static ssize_t parent_show(struct device struct rxe_dev *rxe = container_of(device, struct rxe_dev, ib_dev.dev); - return snprintf(buf, 16, "%s\n", rxe_parent_name(rxe, 1)); + return scnprintf(buf, PAGE_SIZE, "%s\n", rxe_parent_name(rxe, 1)); } static DEVICE_ATTR_RO(parent);