public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Garrett Cooper <yanegomi@gmail.com>
Cc: ltp-list <ltp-list@lists.sf.net>
Subject: Re: [LTP] [PATCH] Fix FILECAPS test hanging for more than 12 hours
Date: Thu, 6 May 2010 08:55:10 -0500	[thread overview]
Message-ID: <20100506135510.GB12072@us.ibm.com> (raw)
In-Reply-To: <E6FF74A2-EB5B-4D11-A9B8-AA25D426D902@gmail.com>

Quoting Garrett Cooper (yanegomi@gmail.com):
> On May 5, 2010, at 7:18 AM, Serge E. Hallyn wrote:
> 
> > Quoting Garrett Cooper (yanegomi@gmail.com):
> >>>                p = index(buf, '.')+1;
> > 
> > Jinkeys!  The intertubes archives insist I wrote that, but I'm finding
> > it hard to believe.
> > 
> >>> -               if (p==(char *)1) {
> >>> -                       tst_resm(TFAIL, "got a bad message from print_caps\n");
> >>> -                       tst_exit();
> >>> -               }
> >>> +               if (p==(char *)1)
> >>> +                       tst_brkm(TFAIL, tst_exit, "got a bad message from print_caps\n");
> >> 
> >>    This is a really incorrect way to do things. I think that the
> >> assumption made was that index(3) would return 0 ('\0') if it fails to
> >> find '.'. That's incorrect and would cause a segfault on some systems
> >> (does on FreeBSD at least... don't see why it would pass on Linux):
> >> 
> >> $ ~/test_null_inc
> >> Segmentation fault: 11 (core dumped)
> >> [garrcoop@bioshock ~]$ cat ~/test_null_inc.c
> >> #include <stdio.h>
> >> int
> >> main(void)
> >> {
> >> 	printf("%s\n", (NULL + 1));
> >> 	return 0;
> >> }
> > 
> > Well, that's different - you're dereferencing NULL+1, whereas I'm
> > just checking the the value of the pointer.  
> > 
> > Still what I did is darned ugly, cleanup below.
> > 
> > thanks,
> > -serge
> > 
> >>    Could you please change this to check and see whether or not index
> >> returns NULL instead of accessing memory like that?
> >>    Other than that, patch looks good.
> > 
> > From: Serge E. Hallyn <serue@us.ibm.com>
> > Date: Wed, 5 May 2010 02:59:05 -0500
> > Subject: [PATCH 1/1] check for index(3) returning NULL
> > 
> > Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
> > ---
> > .../kernel/security/filecaps/verify_caps_exec.c    |    5 +++--
> > 1 files changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/testcases/kernel/security/filecaps/verify_caps_exec.c b/testcases/kernel/security/filecaps/verify_caps_exec.c
> > index c3f65a9..605f0f6 100644
> > --- a/testcases/kernel/security/filecaps/verify_caps_exec.c
> > +++ b/testcases/kernel/security/filecaps/verify_caps_exec.c
> > @@ -182,9 +182,10 @@ int fork_drop_and_exec(int keepperms, cap_t expected_caps)
> > 			tst_resm(TINFO, "got a bad seqno (c=%d, s=%d, seqno=%d)",
> > 				c, s, seqno);
> > 		}
> > -		p = index(buf, '.')+1;
> > -		if (p==(char *)1)
> > +		p = index(buf, '.');
> > +		if (!p)
> > 			tst_brkm(TFAIL, tst_exit, "got a bad message from print_caps\n");
> > +		p += 1;
> > 		actual_caps = cap_from_text(p);
> > 		if (cap_compare(actual_caps, expected_caps) != 0) {
> > 			capstxt = cap_to_text(expected_caps, NULL);
> 
> Looks good! If that's the complete diff, then Acked-by: Garrett Cooper <yanegomi@gmail.com>

Right - that one on top of the previous longer one, please.  (or I can rebase-squash
them and resend if Subrata prefers)

-serge

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2010-05-06 13:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-04 18:20 [LTP] [PATCH] Fix FILECAPS test hanging for more than 12 hours Subrata Modak
2010-05-04 19:22 ` Serge E. Hallyn
2010-05-04 21:02   ` Garrett Cooper
2010-05-04 22:33     ` Serge E. Hallyn
2010-05-05  5:19       ` Garrett Cooper
2010-05-05 14:18         ` Serge E. Hallyn
2010-05-06  7:50           ` Garrett Cooper
2010-05-06 13:55             ` Serge E. Hallyn [this message]
2010-05-06 14:28               ` Subrata Modak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100506135510.GB12072@us.ibm.com \
    --to=serue@us.ibm.com \
    --cc=ltp-list@lists.sf.net \
    --cc=yanegomi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox