Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp47124pxk; Tue, 15 Sep 2020 17:22:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvy/35LqCFEXzBIr62qKrAUQV1hnRdtfI54CSVBlaXNych7mjEjKt2LXfHyQ0JFt/XTcZz X-Received: by 2002:a50:baed:: with SMTP id x100mr9790458ede.384.1600215751868; Tue, 15 Sep 2020 17:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600215751; cv=none; d=google.com; s=arc-20160816; b=S9gxwja46V8znu8GwK7iF88Ad+K1jBVJjHpVU0KC2NWOnwhM9sbhBJlgl6iLCnEbmS NHq3pDK29stVSJKm5rUNdUIsEwW1gzkTpIuxJtvzL/0tEZJGt6/Jr5rFD7HDj+bkBWKR shokc75GZxdcdeUwZUuptJILkRNXpvAVwc+0qLL4B97NPK51zMlKLRAygUWR1uZRPXdD j5a4OG/WyQgLqTRXYRdm6hRlHi3iCPLhKER7rAlroEQPJ70cPkQSwazxGCEuPjl6I/6i +vKjtpHRwcn2mHdV/yUs2b8ukrQ4FzD0hzIK1ApcBXwg4TxER4UT5cUVMzR6wq15Edzy oIEA== 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=Llrls0VKKk+c4ddmPl2ENEEgU2knfvJWT4zkS8SXNcg=; b=C9LJOr1mYa7oPniK6PoTKj9lATBaUuvN7dETsDJ71KCHEDC23Lt/BEI4pmszZWEyfy lvrx45jf5T1ZVnoy5GbpocB4gWkFGA2Vti0NKyM0lfMwrte4tynx1lLUWe4VxVA0mv4Y AUzWrcZHAhveMmfFnxpYC19pXkSm8CKQZcCl765syw9/CSEDbSKW5lYyFZooNJPRoW2t jD3wdFUkfgSuMkTkp1PAqSrVK84LSdC0sy253dRF0nl9sk2QHzqkjjbqh1dxbGZQWlt5 KsdZHKzIRz6t45Re/d3acpU9nLMpW5RmYfRfGCCS8jK6oJdkUJe6hgAjNLQUoFM+cOf+ i3+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uiNwa2zA; 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 i12si10111931ejk.740.2020.09.15.17.22.09; Tue, 15 Sep 2020 17:22:31 -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=uiNwa2zA; 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 S1726905AbgIPATa (ORCPT + 99 others); Tue, 15 Sep 2020 20:19:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbgIOOWr (ORCPT ); Tue, 15 Sep 2020 10:22:47 -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 41D2F222BB; Tue, 15 Sep 2020 14:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179488; bh=krxdbRDgaMeMb8S9OipgumFVTvya9dp9ZGTLkVj+cJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uiNwa2zAio89DAYg+icIckaIzuz8RfW9PyWVgmzJg4PUrRiS7LxVpJxyp9PsH6JeR AZdOxc8+/ugmZ863fRyb8KOAH+S45Moy1MRnLGq+qZkrtYMUHVMUsknFrPJ12+lRmV 8UJjFKAetsj5YBrgSfbVpZL8rbl7W2IHAxmqLP/4= 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.19 64/78] RDMA/rxe: Fix the parent sysfs read when the interface has 15 chars Date: Tue, 15 Sep 2020 16:13:29 +0200 Message-Id: <20200915140636.771980797@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140633.552502750@linuxfoundation.org> References: <20200915140633.552502750@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: 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 @@ -1146,7 +1146,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);