|
From: <sv...@va...> - 2005-07-18 22:41:40
|
Author: tom
Date: 2005-07-18 23:41:33 +0100 (Mon, 18 Jul 2005)
New Revision: 4166
Log:
Check each field of the msghdr structure passed to sendmsg/recvmsg
individually to avoid complaints due to uninitialised padding bytes
on 64 bit platforms.
Also fixed sendmsg to check things which should be initialised (the
msghdr structure and the iov array) properly instead of doing a write
check for everything.
Modified:
trunk/coregrind/m_syswrap/syswrap-generic.c
Modified: trunk/coregrind/m_syswrap/syswrap-generic.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
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2005-07-18 17:53:07 UTC (=
rev 4165)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2005-07-18 22:41:33 UTC (=
rev 4166)
@@ -586,45 +586,54 @@
}
=20
static=20
-void pre_mem_read_sendmsg ( ThreadId tid,
+void pre_mem_read_sendmsg ( ThreadId tid, Bool read,
Char *msg, Addr base, SizeT size )
{
Char *outmsg =3D strdupcat ( "socketcall.sendmsg", msg, VG_AR_CORE );
PRE_MEM_READ( outmsg, base, size );
-
VG_(arena_free) ( VG_AR_CORE, outmsg );
}
=20
static=20
-void pre_mem_write_recvmsg ( ThreadId tid,
+void pre_mem_write_recvmsg ( ThreadId tid, Bool read,
Char *msg, Addr base, SizeT size )
{
Char *outmsg =3D strdupcat ( "socketcall.recvmsg", msg, VG_AR_CORE );
- PRE_MEM_WRITE( outmsg, base, size );
+ if ( read )
+ PRE_MEM_READ( outmsg, base, size );
+ else
+ PRE_MEM_WRITE( outmsg, base, size );
VG_(arena_free) ( VG_AR_CORE, outmsg );
}
=20
static
-void post_mem_write_recvmsg ( ThreadId tid,
+void post_mem_write_recvmsg ( ThreadId tid, Bool read,
Char *fieldName, Addr base, SizeT size )
{
- POST_MEM_WRITE( base, size );
+ if ( !read )
+ POST_MEM_WRITE( base, size );
}
=20
static
void msghdr_foreachfield (=20
ThreadId tid,=20
struct vki_msghdr *msg,=20
- void (*foreach_func)( ThreadId, Char *, Addr, SizeT )=20
+ void (*foreach_func)( ThreadId, Bool, Char *, Addr, SizeT )=20
)
{
if ( !msg )
return;
=20
- foreach_func ( tid, "(msg)", (Addr)msg, sizeof( struct vki_msghdr ) )=
;
+ foreach_func ( tid, True, "(msg)", (Addr)&msg->msg_name, sizeof( msg-=
>msg_name ) );
+ foreach_func ( tid, True, "(msg)", (Addr)&msg->msg_namelen, sizeof( m=
sg->msg_namelen ) );
+ foreach_func ( tid, True, "(msg)", (Addr)&msg->msg_iov, sizeof( msg->=
msg_iov ) );
+ foreach_func ( tid, True, "(msg)", (Addr)&msg->msg_iovlen, sizeof( ms=
g->msg_iovlen ) );
+ foreach_func ( tid, True, "(msg)", (Addr)&msg->msg_control, sizeof( m=
sg->msg_control ) );
+ foreach_func ( tid, True, "(msg)", (Addr)&msg->msg_controllen, sizeof=
( msg->msg_controllen ) );
+ foreach_func ( tid, True, "(msg)", (Addr)&msg->msg_flags, sizeof( msg=
->msg_flags ) );
=20
if ( msg->msg_name )
- foreach_func ( tid,=20
+ foreach_func ( tid, False,
"(msg.msg_name)",=20
(Addr)msg->msg_name, msg->msg_namelen );
=20
@@ -632,18 +641,18 @@
struct vki_iovec *iov =3D msg->msg_iov;
UInt i;
=20
- foreach_func ( tid,=20
+ foreach_func ( tid, True,
"(msg.msg_iov)",=20
(Addr)iov, msg->msg_iovlen * sizeof( struct vki_iov=
ec ) );
=20
for ( i =3D 0; i < msg->msg_iovlen; ++i, ++iov )
- foreach_func ( tid,=20
+ foreach_func ( tid, False,
"(msg.msg_iov[i]",=20
(Addr)iov->iov_base, iov->iov_len );
}
=20
if ( msg->msg_control )
- foreach_func ( tid,=20
+ foreach_func ( tid, False,
"(msg.msg_control)",=20
(Addr)msg->msg_control, msg->msg_controllen );
}
|
|
From: Julian S. <js...@ac...> - 2005-07-18 22:53:26
|
> Check each field of the msghdr structure passed to sendmsg/recvmsg > individually to avoid complaints due to uninitialised padding bytes > on 64 bit platforms. Great stuff. Does this reduce the amount of complaining the testsuite does on amd64? J |
|
From: Tom H. <to...@co...> - 2005-07-18 23:13:05
|
In message <200...@ac...>
Julian Seward <js...@ac...> wrote:
> > Check each field of the msghdr structure passed to sendmsg/recvmsg
> > individually to avoid complaints due to uninitialised padding bytes
> > on 64 bit platforms.
>
> Great stuff.
>
> Does this reduce the amount of complaining the testsuite does on amd64?
I don't think so, but it does mean I can now run our software without
any complaints ;-) I'm running a regtest now to see where we're at...
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|
|
From: Tom H. <to...@co...> - 2005-07-18 23:19:21
|
In message <e51...@lo...>
Tom Hughes <to...@co...> wrote:
> In message <200...@ac...>
> Julian Seward <js...@ac...> wrote:
>
> > Does this reduce the amount of complaining the testsuite does on amd64?
>
> I don't think so, but it does mean I can now run our software without
> any complaints ;-) I'm running a regtest now to see where we're at...
The sigaltstack one I just committed does fix a test failure however.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|