Date: Thu, 4 Jul 2013 12:50:01 GMT From: Shahar Klein <shahark@mellanox.com> To: freebsd-net@FreeBSD.org Subject: RE: kern/179999: [ofed] [patch] Bug assigning HCA from IB to ETH Message-ID: <201307041250.r64Co13m052282@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/179999; it has been noted by GNATS. From: Shahar Klein <shahark@mellanox.com> To: John Baldwin <jhb@freebsd.org>, "bug-followup@freebsd.org" <bug-followup@freebsd.org> Cc: Orit Moskovich <oritm@mellanox.com>, Oded Shanoon <odeds@mellanox.com> Subject: RE: kern/179999: [ofed] [patch] Bug assigning HCA from IB to ETH Date: Thu, 4 Jul 2013 12:34:09 +0000 Thanks John I've tested this version and it works fine. Shahar Klein -----Original Message----- From: John Baldwin [mailto:jhb@freebsd.org]=20 Sent: Friday, June 28, 2013 12:20 AM To: bug-followup@freebsd.org; Shahar Klein Subject: Re: kern/179999: [ofed] [patch] Bug assigning HCA from IB to ETH Thanks, I think the sysfs fix has a few issues though (it writes to buf[] e= ven if the copyin() fails, and it doesn't enforce a bounds check). It does= seem that this should probably be using sysctl_handle_string() instead of = doing it by hand, but for now I've just adjusted your patch. Can you pleas= e test this version? Index: ofed/drivers/net/mlx4/main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ofed/drivers/net/mlx4/main.c (revision 252306) +++ ofed/drivers/net/mlx4/main.c (working copy) @@ -479,11 +479,11 @@ int i; int err =3D 0; =20 - if (!strcmp(buf, "ib\n")) + if (!strcmp(buf, "ib")) info->tmp_type =3D MLX4_PORT_TYPE_IB; - else if (!strcmp(buf, "eth\n")) + else if (!strcmp(buf, "eth")) info->tmp_type =3D MLX4_PORT_TYPE_ETH; - else if (!strcmp(buf, "auto\n")) + else if (!strcmp(buf, "auto")) info->tmp_type =3D MLX4_PORT_TYPE_AUTO; else { mlx4_err(mdev, "%s is not supported port type\n", buf); Index: ofed/include/linux/sysfs.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ofed/include/linux/sysfs.h (revision 252306) +++ ofed/include/linux/sysfs.h (working copy) @@ -104,10 +104,15 @@ error =3D SYSCTL_OUT(req, buf, len); if (error || !req->newptr || ops->store =3D=3D NULL) goto out; - error =3D SYSCTL_IN(req, buf, PAGE_SIZE); + len =3D req->newlen - req->newidx; + if (len >=3D PAGE_SIZE) + error =3D EINVAL; + else=20 + error =3D SYSCTL_IN(req, buf, len); if (error) goto out; - len =3D ops->store(kobj, attr, buf, req->newlen); + ((char *)buf)[len] =3D '\0'; + len =3D ops->store(kobj, attr, buf, len); if (len < 0) error =3D -len; out: -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307041250.r64Co13m052282>