Hi, --- On Thu, 4/9/09, Guo Hongruan <[email protected]> wrote:
> From: Guo Hongruan <[email protected]> > Subject: [LTP] patch for mount02.c and mount03.c bugs(maybe) > To: [email protected] > Date: Thursday, April 9, 2009, 11:41 AM > Hi, Guys, > I think I found a bug of mount02.c and > mount03.c which can not validate > mount system call correctly. I did the following change, on > my sites, it > works OK. Here is the patch, hope it is useful. > > Running these testcases manually can > reproduce this bug: > mount02 -D /dev/hda2 -T ext2 > mount03 -D /dev/hda2 -T ext2 > I can reproduce the problem with mount02, and confirm the patch works. However, mount03 does not fail for me without the patch. # # ./mount03 -D /dev/sdb1 -T ext2 mount03 1 PASS : mount(2) Passed for rwflag MS_RDONLY - mount read-only mount03 2 PASS : mount(2) Passed for rwflag MS_NODEV - disallow access to device special files mount03 3 PASS : mount(2) Passed for rwflag MS_NOEXEC - disallow program execution mount03 4 PASS : mount(2) Passed for rwflag MS_SYNCHRONOUS - writes are synced at once mount03 5 PASS : mount(2) Passed for rwflag MS_REMOUNT - alter flags of a mounted FS mount03 6 PASS : mount(2) Passed for rwflag MS_NOSUID - ignore suid and sgid bits Can you describe a little bit about the problem you were facing with mount03? CAI Qian > Index: testcases/kernel/syscalls/mount/mount02.c > =================================================================== > --- > testcases/kernel/syscalls/mount/mount02.c (revision > 297) > +++ > testcases/kernel/syscalls/mount/mount02.c (working > copy) > @@ -414,8 +414,8 @@ > > if (Tflag) { > > /* Avoid buffer > overflow */ > > strncpy(Type, > fstype, > - > > (FSTYPE_LEN < strlen(fstype)) ? > FSTYPE_LEN > : > - > > strlen(fstype)); > + > > (FSTYPE_LEN < strlen(fstype)+1) ? > > FSTYPE_LEN : > + > > strlen(fstype)+1); > > } else { > > strcpy(Type, > "ext2"); > > } > > > Index: mount03.c > =================================================================== > --- mount03.c (revision 297) > +++ mount03.c (working copy) > @@ -170,18 +170,20 @@ > } > > if (Tflag) { > - Fstype = (char *) > malloc(strlen(fstype)); > + Fstype = (char *) > malloc(strlen(fstype)+1); > if (Fstype == > NULL) { > > tst_brkm(TBROK, NULL, "malloc failed to > alloc %d errno " > > " %d ", > strlen(fstype), errno); > } > + memset(Fstype, 0, > strlen(fstype)+1); > > strncpy(Fstype, fstype, strlen(fstype)); > } else { > - Fstype = (char *) > malloc(strlen(DEFAULT_FSTYPE)); > + Fstype = (char *) > malloc(strlen(DEFAULT_FSTYPE)+1); > if (Fstype == > NULL) { > > tst_brkm(TBROK, NULL, "malloc failed to > alloc %d errno " > > " %d ", > strlen(fstype), errno); > } > + memset(Fstype, 0, > strlen(DEFAULT_FSTYPE)+1); > > strncpy(Fstype, DEFAULT_FSTYPE, strlen(DEFAULT_FSTYPE)); > } > > @@ -408,6 +410,7 @@ > > > strerror(TEST_ERRNO)); > > } > > execve(file, NULL, > NULL); > + > exit(-127); > > /* NOT REACHEAD */ > > } else { > > waitpid(pid, > &status, 0); > > -- > Guo Hongruan, Embedded Linux Consultant > Mobile: +86-0-13484056007 > Skype: camelguo > http://www.gulessoft.com > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > High Quality Requirements in a Collaborative Environment. > Download a free trial of Rational Requirements Composer > Now! > http://p.sf.net/sfu/www-ibm-com > _______________________________________________ > Ltp-list mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ltp-list > ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
