public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl()
@ 2011-07-04  9:53 sebastien dugue
  2011-07-05 11:41 ` Hal Rosenstock
  2011-07-05 18:17 ` [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl() Bart Van Assche
  0 siblings, 2 replies; 5+ messages in thread
From: sebastien dugue @ 2011-07-04  9:53 UTC (permalink / raw)
  To: linux-rdma; +Cc: Alex Netes, Vincent


This fixes the following warning issued by valgrind:

==5287== Syscall param ioctl(generic) points to uninitialised byte(s)
==5287==    at 0x3C466D95D7: ioctl (in /lib64/libc-2.12.so)
==5287==    by 0x526C292: umad_register (umad.c:947)
==5287==    by 0x568D206: smp_engine_init (query_smp.c:228)
==5287==    by 0x5689F8F: ibnd_discover_fabric (ibnetdisc.c:537)
==5287==    by 0x411700: devmgr_discover_fabric (devmgr_discover.c:66)

Signed-off-by: Jean-Vincent Ficet <jean-vincent.ficet-6ktuUTfB/bM@public.gmane.org>

---

diff --git a/src/umad.c b/src/umad.c
index 45a9423..cac46a4 100644
--- a/src/umad.c
+++ b/src/umad.c
@@ -892,6 +892,7 @@ int umad_register_oui(int fd, int mgmt_class, uint8_t rmpp_version,
 		return -EINVAL;
 	}
 
+	memset(&req, 0, sizeof(req));
 	req.qpn = 1;
 	req.mgmt_class = mgmt_class;
 	req.mgmt_class_version = 1;
@@ -928,6 +929,7 @@ int umad_register(int fd, int mgmt_class, int mgmt_version,
 	    ("fd %d mgmt_class %u mgmt_version %u rmpp_version %d method_mask %p",
 	     fd, mgmt_class, mgmt_version, rmpp_version, method_mask);
 
+	memset(&req, 0, sizeof(req));
 	req.qpn = qp = (mgmt_class == 0x1 || mgmt_class == 0x81) ? 0 : 1;
 	req.mgmt_class = mgmt_class;
 	req.mgmt_class_version = mgmt_version;
-- 
1.7.1.rc2.7.g3e7f1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl()
  2011-07-04  9:53 [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl() sebastien dugue
@ 2011-07-05 11:41 ` Hal Rosenstock
       [not found]   ` <4E12F85D.4010801-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  2011-07-05 18:17 ` [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl() Bart Van Assche
  1 sibling, 1 reply; 5+ messages in thread
From: Hal Rosenstock @ 2011-07-05 11:41 UTC (permalink / raw)
  To: sebastien dugue; +Cc: linux-rdma, Alex Netes, Vincent

On 7/4/2011 5:53 AM, sebastien dugue wrote:
> 
> This fixes the following warning issued by valgrind:
> 
> ==5287== Syscall param ioctl(generic) points to uninitialised byte(s)
> ==5287==    at 0x3C466D95D7: ioctl (in /lib64/libc-2.12.so)
> ==5287==    by 0x526C292: umad_register (umad.c:947)
> ==5287==    by 0x568D206: smp_engine_init (query_smp.c:228)
> ==5287==    by 0x5689F8F: ibnd_discover_fabric (ibnetdisc.c:537)
> ==5287==    by 0x411700: devmgr_discover_fabric (devmgr_discover.c:66)
> 
> Signed-off-by: Jean-Vincent Ficet <jean-vincent.ficet-6ktuUTfB/bM@public.gmane.org>
> 
> ---
> 
> diff --git a/src/umad.c b/src/umad.c
> index 45a9423..cac46a4 100644
> --- a/src/umad.c
> +++ b/src/umad.c
> @@ -892,6 +892,7 @@ int umad_register_oui(int fd, int mgmt_class, uint8_t rmpp_version,
>  		return -EINVAL;
>  	}
>  
> +	memset(&req, 0, sizeof(req));
>  	req.qpn = 1;
>  	req.mgmt_class = mgmt_class;
>  	req.mgmt_class_version = 1;
> @@ -928,6 +929,7 @@ int umad_register(int fd, int mgmt_class, int mgmt_version,
>  	    ("fd %d mgmt_class %u mgmt_version %u rmpp_version %d method_mask %p",
>  	     fd, mgmt_class, mgmt_version, rmpp_version, method_mask);
>  
> +	memset(&req, 0, sizeof(req));
>  	req.qpn = qp = (mgmt_class == 0x1 || mgmt_class == 0x81) ? 0 : 1;
>  	req.mgmt_class = mgmt_class;
>  	req.mgmt_class_version = mgmt_version;

I think this is a "false positive" in valgrind. memset of the request
isn't really needed for either of these APIs as all input fields are
filled in by the caller and the only one which isn't is id which is an
output field.

-- Hal
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 beforeinvoking ioctl()
       [not found]   ` <4E12F85D.4010801-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2011-07-05 15:11     ` sebastien dugue
  0 siblings, 0 replies; 5+ messages in thread
From: sebastien dugue @ 2011-07-05 15:11 UTC (permalink / raw)
  To: Hal Rosenstock; +Cc: linux-rdma, Alex Netes, Vincent

On Tue, 05 Jul 2011 07:41:17 -0400
Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org> wrote:

> On 7/4/2011 5:53 AM, sebastien dugue wrote:
> > 
> > This fixes the following warning issued by valgrind:
> > 
> > ==5287== Syscall param ioctl(generic) points to uninitialised byte(s)
> > ==5287==    at 0x3C466D95D7: ioctl (in /lib64/libc-2.12.so)
> > ==5287==    by 0x526C292: umad_register (umad.c:947)
> > ==5287==    by 0x568D206: smp_engine_init (query_smp.c:228)
> > ==5287==    by 0x5689F8F: ibnd_discover_fabric (ibnetdisc.c:537)
> > ==5287==    by 0x411700: devmgr_discover_fabric (devmgr_discover.c:66)
> > 
> > Signed-off-by: Jean-Vincent Ficet <jean-vincent.ficet-6ktuUTfB/bM@public.gmane.org>
> > 
> > ---
> > 
> > diff --git a/src/umad.c b/src/umad.c
> > index 45a9423..cac46a4 100644
> > --- a/src/umad.c
> > +++ b/src/umad.c
> > @@ -892,6 +892,7 @@ int umad_register_oui(int fd, int mgmt_class, uint8_t rmpp_version,
> >  		return -EINVAL;
> >  	}
> >  
> > +	memset(&req, 0, sizeof(req));
> >  	req.qpn = 1;
> >  	req.mgmt_class = mgmt_class;
> >  	req.mgmt_class_version = 1;
> > @@ -928,6 +929,7 @@ int umad_register(int fd, int mgmt_class, int mgmt_version,
> >  	    ("fd %d mgmt_class %u mgmt_version %u rmpp_version %d method_mask %p",
> >  	     fd, mgmt_class, mgmt_version, rmpp_version, method_mask);
> >  
> > +	memset(&req, 0, sizeof(req));
> >  	req.qpn = qp = (mgmt_class == 0x1 || mgmt_class == 0x81) ? 0 : 1;
> >  	req.mgmt_class = mgmt_class;
> >  	req.mgmt_class_version = mgmt_version;
> 
> I think this is a "false positive" in valgrind. memset of the request
> isn't really needed for either of these APIs as all input fields are
> filled in by the caller and the only one which isn't is id which is an
> output field.

  Ok then, it's no needed.

  Thanks,

  Sébastien.

> 
> -- Hal
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl()
  2011-07-04  9:53 [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl() sebastien dugue
  2011-07-05 11:41 ` Hal Rosenstock
@ 2011-07-05 18:17 ` Bart Van Assche
       [not found]   ` <CAO+b5-pKPdJC20s7dL18b97fd778GoT4TJ_J13NwbkEFz6bz4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2011-07-05 18:17 UTC (permalink / raw)
  To: sebastien dugue
  Cc: linux-rdma, Alex Netes, Vincent,
	hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb

On Mon, Jul 4, 2011 at 11:53 AM, sebastien dugue
<sebastien.dugue-6ktuUTfB/bM@public.gmane.org> wrote:
>
> This fixes the following warning issued by valgrind:
>
> ==5287== Syscall param ioctl(generic) points to uninitialised byte(s)
> ==5287==    at 0x3C466D95D7: ioctl (in /lib64/libc-2.12.so)
> ==5287==    by 0x526C292: umad_register (umad.c:947)
> ==5287==    by 0x568D206: smp_engine_init (query_smp.c:228)
> ==5287==    by 0x5689F8F: ibnd_discover_fabric (ibnetdisc.c:537)
> ==5287==    by 0x411700: devmgr_discover_fabric (devmgr_discover.c:66)
>
> Signed-off-by: Jean-Vincent Ficet <jean-vincent.ficet-6ktuUTfB/bM@public.gmane.org>
>
> ---
>
> diff --git a/src/umad.c b/src/umad.c
> index 45a9423..cac46a4 100644
> --- a/src/umad.c
> +++ b/src/umad.c
> @@ -892,6 +892,7 @@ int umad_register_oui(int fd, int mgmt_class, uint8_t rmpp_version,
>                return -EINVAL;
>        }
>
> +       memset(&req, 0, sizeof(req));
>        req.qpn = 1;
>        req.mgmt_class = mgmt_class;
>        req.mgmt_class_version = 1;
> @@ -928,6 +929,7 @@ int umad_register(int fd, int mgmt_class, int mgmt_version,
>            ("fd %d mgmt_class %u mgmt_version %u rmpp_version %d method_mask %p",
>             fd, mgmt_class, mgmt_version, rmpp_version, method_mask);
>
> +       memset(&req, 0, sizeof(req));
>        req.qpn = qp = (mgmt_class == 0x1 || mgmt_class == 0x81) ? 0 : 1;
>        req.mgmt_class = mgmt_class;
>        req.mgmt_class_version = mgmt_version;

A possible alternative approach is to develop a patch for Valgrind
that makes Valgrind ignore padding fields and/or output fields in the
pre-ioctl check. See also PRE(sys_ioctl) in source file
coregrind/m_syswrap/syswrap-linux.c or the documentation file
README_MISSING_SYSCALL_OR_IOCTL.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0before invoking ioctl()
       [not found]   ` <CAO+b5-pKPdJC20s7dL18b97fd778GoT4TJ_J13NwbkEFz6bz4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-07-06  7:08     ` sebastien dugue
  0 siblings, 0 replies; 5+ messages in thread
From: sebastien dugue @ 2011-07-06  7:08 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: linux-rdma, Alex Netes, Vincent,
	hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb

On Tue, 5 Jul 2011 20:17:18 +0200
Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org> wrote:

> On Mon, Jul 4, 2011 at 11:53 AM, sebastien dugue
> <sebastien.dugue-6ktuUTfB/bM@public.gmane.org> wrote:
> >
> > This fixes the following warning issued by valgrind:
> >
> > ==5287== Syscall param ioctl(generic) points to uninitialised byte(s)
> > ==5287==    at 0x3C466D95D7: ioctl (in /lib64/libc-2.12.so)
> > ==5287==    by 0x526C292: umad_register (umad.c:947)
> > ==5287==    by 0x568D206: smp_engine_init (query_smp.c:228)
> > ==5287==    by 0x5689F8F: ibnd_discover_fabric (ibnetdisc.c:537)
> > ==5287==    by 0x411700: devmgr_discover_fabric (devmgr_discover.c:66)
> >
> > Signed-off-by: Jean-Vincent Ficet <jean-vincent.ficet-6ktuUTfB/bM@public.gmane.org>
> >
> > ---
> >
> > diff --git a/src/umad.c b/src/umad.c
> > index 45a9423..cac46a4 100644
> > --- a/src/umad.c
> > +++ b/src/umad.c
> > @@ -892,6 +892,7 @@ int umad_register_oui(int fd, int mgmt_class, uint8_t rmpp_version,
> >                return -EINVAL;
> >        }
> >
> > +       memset(&req, 0, sizeof(req));
> >        req.qpn = 1;
> >        req.mgmt_class = mgmt_class;
> >        req.mgmt_class_version = 1;
> > @@ -928,6 +929,7 @@ int umad_register(int fd, int mgmt_class, int mgmt_version,
> >            ("fd %d mgmt_class %u mgmt_version %u rmpp_version %d method_mask %p",
> >             fd, mgmt_class, mgmt_version, rmpp_version, method_mask);
> >
> > +       memset(&req, 0, sizeof(req));
> >        req.qpn = qp = (mgmt_class == 0x1 || mgmt_class == 0x81) ? 0 : 1;
> >        req.mgmt_class = mgmt_class;
> >        req.mgmt_class_version = mgmt_version;
> 
> A possible alternative approach is to develop a patch for Valgrind
> that makes Valgrind ignore padding fields and/or output fields in the
> pre-ioctl check. See also PRE(sys_ioctl) in source file
> coregrind/m_syswrap/syswrap-linux.c or the documentation file
> README_MISSING_SYSCALL_OR_IOCTL.

  Could be, but this is largely out of scope for me and I can live
with the warning knowing it's a false positive.

  Thanks,

  Sébastien.

> 
> Bart.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2011-07-06  7:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-04  9:53 [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl() sebastien dugue
2011-07-05 11:41 ` Hal Rosenstock
     [not found]   ` <4E12F85D.4010801-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2011-07-05 15:11     ` [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 beforeinvoking ioctl() sebastien dugue
2011-07-05 18:17 ` [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0 before invoking ioctl() Bart Van Assche
     [not found]   ` <CAO+b5-pKPdJC20s7dL18b97fd778GoT4TJ_J13NwbkEFz6bz4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-07-06  7:08     ` [PATCH] umad.c: memset() ib_user_mad_reg_req structure to 0before " sebastien dugue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox