[apparmor] [PATCH] parser: Quiet valgrind false positive

Tyler Hicks tyhicks at canonical.com
Wed Feb 5 18:40:27 UTC 2014


On 2014-02-05 10:35:58, Steve Beattie wrote:
> On Wed, Feb 05, 2014 at 01:22:42PM -0500, Tyler Hicks wrote:
> > strlen() assumes that it can read an entire word but when a char array
> > array does not end on a word boundary, it reads past the end of the
> > array. This results in the following valgrind warning:
> > 
> >  Invalid read of size 4
> >     at 0x40A162: yylex() (parser_lex.l:277)
> >     by 0x40FA14: yyparse() (parser_yacc.c:1487)
> >     by 0x40C5B9: process_profile(int, char const*) (parser_main.c:1003)
> >     by 0x404074: main (parser_main.c:1340)
> >   Address 0x578d870 is 16 bytes inside a block of size 18 alloc'd
> >     at 0x4C2A420: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> >     by 0x53E31C9: strdup (strdup.c:42)
> >     by 0x40A145: yylex() (parser_lex.l:276)
> >     by 0x40FA14: yyparse() (parser_yacc.c:1487)
> >     by 0x40C5B9: process_profile(int, char const*) (parser_main.c:1003)
> >     by 0x404074: main (parser_main.c:1340)
> > 
> > This patch quiets the warning by not using strlen(). This can be done
> > because yyleng already contains the length of string.
> > 
> > Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
> 
> Yes, much better. Acked-by: Steve Beattie <steve at nxnw.org>
> 
> With that, we can get rid of the valgrind supression that applies for
> that bit of code. Here's the patch to do that:
> 
> Signed-off-by: Steve Beattie <steve at nxnw.org>
> ---

Oh, nice!

Acked-by: Tyler Hicks <tyhicks at canonical.com>

>  parser/tst/valgrind_simple.py |    9 ---------
>  1 file changed, 9 deletions(-)
> 
> Index: b/parser/tst/valgrind_simple.py
> ===================================================================
> --- a/parser/tst/valgrind_simple.py
> +++ b/parser/tst/valgrind_simple.py
> @@ -33,15 +33,6 @@ VALGRIND_SUPPRESSIONS = '''
>  }
>  
>  {
> -    valgrind-yylex-obsessive-overreads
> -    Memcheck:Addr4
> -    fun:_Z?yylex?
> -    fun:_Z*yyparse*
> -    fun:_Z*process_profile*
> -    fun:main
> -}
> -
> -{
>      valgrind-serialize_profile-obsessive-overreads
>      Memcheck:Addr4
>      fun:_Z*sd_serialize_profile*
> 
> -- 
> Steve Beattie
> <sbeattie at ubuntu.com>
> http://NxNW.org/~steve/



> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140205/80917527/attachment.pgp>


More information about the AppArmor mailing list