All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] RDMA/rxe: fix the parent sysfs read when the interface has 15 chars
@ 2020-08-20 15:36 Yi Zhang
  2020-08-24 16:47 ` Bart Van Assche
  2020-08-24 17:07 ` Jason Gunthorpe
  0 siblings, 2 replies; 3+ messages in thread
From: Yi Zhang @ 2020-08-20 15:36 UTC (permalink / raw)
  To: linux-rdma, jgg; +Cc: bvanassche, kamalheib1, yanjunz

parent sysfs reads will yield '\0' bytes when the interface name
has 15 chars, and there will no "\n" output.

reproducer:
Create one interface with 15 chars
[root@test ~]# ip a s enp0s29u1u7u3c2
2: enp0s29u1u7u3c2: <BROADCAST,MULTICAST,UP,LOWER_UP> 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

Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
---
 drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index bb61e534e468..756980f79951 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -1056,7 +1056,7 @@ static ssize_t parent_show(struct device *device,
 	struct rxe_dev *rxe =
 		rdma_device_to_drv_device(device, struct rxe_dev, ib_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);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] RDMA/rxe: fix the parent sysfs read when the interface has 15 chars
  2020-08-20 15:36 [PATCH v2] RDMA/rxe: fix the parent sysfs read when the interface has 15 chars Yi Zhang
@ 2020-08-24 16:47 ` Bart Van Assche
  2020-08-24 17:07 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2020-08-24 16:47 UTC (permalink / raw)
  To: Yi Zhang, linux-rdma, jgg; +Cc: kamalheib1, yanjunz

On 8/20/20 8:36 AM, Yi Zhang wrote:
> parent sysfs reads will yield '\0' bytes when the interface name
> has 15 chars, and there will no "\n" output.
> 
> reproducer:
> Create one interface with 15 chars
> [root@test ~]# ip a s enp0s29u1u7u3c2
> 2: enp0s29u1u7u3c2: <BROADCAST,MULTICAST,UP,LOWER_UP> 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
> 
> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
> ---
>   drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index bb61e534e468..756980f79951 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -1056,7 +1056,7 @@ static ssize_t parent_show(struct device *device,
>   	struct rxe_dev *rxe =
>   		rdma_device_to_drv_device(device, struct rxe_dev, ib_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);

Please add 'Cc: stable' to this patch.

Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] RDMA/rxe: fix the parent sysfs read when the interface has 15 chars
  2020-08-20 15:36 [PATCH v2] RDMA/rxe: fix the parent sysfs read when the interface has 15 chars Yi Zhang
  2020-08-24 16:47 ` Bart Van Assche
@ 2020-08-24 17:07 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2020-08-24 17:07 UTC (permalink / raw)
  To: Yi Zhang; +Cc: linux-rdma, bvanassche, kamalheib1, yanjunz

On Thu, Aug 20, 2020 at 11:36:46PM +0800, Yi Zhang wrote:
> parent sysfs reads will yield '\0' bytes when the interface name
> has 15 chars, and there will no "\n" output.
> 
> reproducer:
> Create one interface with 15 chars
> [root@test ~]# ip a s enp0s29u1u7u3c2
> 2: enp0s29u1u7u3c2: <BROADCAST,MULTICAST,UP,LOWER_UP> 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
> 
> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/infiniband/sw/rxe/rxe_verbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-rc with a Fixes and cc stable line

Thanks,
Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-24 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20 15:36 [PATCH v2] RDMA/rxe: fix the parent sysfs read when the interface has 15 chars Yi Zhang
2020-08-24 16:47 ` Bart Van Assche
2020-08-24 17:07 ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.