[BusyBox] "mount -a" failure

Matt Waddel matt.waddel at freescale.com
Wed Aug 3 16:29:18 MDT 2005


Hi,

I am using gcc-3.4.0 and glibc-2.3.2-v4e.  The target is the
MCF5475 Coldfire processor (it has an MMU).  I have encountered
the following failure.

When I execute the following mount command everything works as
expected:

# mount proc /proc -t proc

When I put one item in /etc/fstab and execute "mount -a" the
process crashes in the kernel:

# cat /etc/fstab
# file system   mount       type    options           dump    pass
proc            /proc       proc    defaults          0       0

# mount -a
*** FORMAT ERROR ***   FORMAT=4
Current process id is 686
BAD KERNEL TRAP: 00000000
Modules linked in:
PC: [<c0002658>] resume_userspace+0x18/0x1a

SR: 2014  SP: c0fa7f3c  a2: c3fdf5c0
d0: 00000000    d1: ffffff00    d2: 00001208    d3: 00002000
d4: c3974000    d5: 80064070    a0: c3efb020    a1: c3efb038
Process mount (pid: 686, stackpage=c3fe15c0)
Stack from c0fa7f3c:
         ffffff00 00001208 00002000 c3974000 80064070 c3efb020 c3efb038 c3fdf5c0
         00000000 ffffffff 00000000 40382014 c0002658 0c0a2004 c01b7140 80067208
         80067208 c0ed0000 c0062b08 00000000 80064070 c0fa7fc4 c0063634 80067208
         c0fa7fc0 c01ce5e5 80067208 80065088 80067208 80005258 00000000 c0ed0000
         80005258 00000000 bffffcc8 c00025f4 80064080 80065088 80067208 c0ed0000
         80064070 80067208 80064080 800042f8 00000015 00000015 00000000 40800008
Call Trace:
Segmentation fault

The process crashes when it tries to copy information from the user space
with the __get_user() call.  I tracked the failure back to the mount_main()
routine.  With the following patch everything works.  Any ideas what's
going on?  Is this the correct way to fix the problem?  (Seems like the
patched declaration puts the filesystemType & string_flags variables in
a different area of memory.)

Regards,
Matt

diff --exclude CVS -uNr busybox-1.00/util-linux/mount.c 
busybox-1.00.modified/util-linux/mount.c
--- busybox-1.00/util-linux/mount.c     2004-08-02 18:14:02.000000000 -0600
+++ busybox-1.00.modified/util-linux/mount.c    2005-08-03 14:52:10.306707442 -0600
@@ -367,10 +367,10 @@
  extern int mount_main(int argc, char **argv)
  {
         struct stat statbuf;
-       char *string_flags = bb_xstrdup("");
+       char *string_flags = xmalloc(PATH_MAX);
         char *extra_opts;
         int flags = 0;
-       char *filesystemType = "auto";
+       char *filesystemType = xmalloc(PATH_MAX);
         int got_filesystemType = 0;
         char *device = xmalloc(PATH_MAX);
         char *directory = xmalloc(PATH_MAX);
@@ -382,6 +382,9 @@
         FILE *f = 0;
         int opt;

+       strcpy(string_flags, "");
+       strcpy(filesystemType, "auto");
+
         /* Parse options */
         while ((opt = getopt(argc, argv, "o:rt:wafnv")) > 0) {
                 switch (opt) {
@@ -460,7 +463,7 @@

                         strcpy(device, m->mnt_fsname);
                         strcpy(directory, m->mnt_dir);
-                       filesystemType = bb_xstrdup(m->mnt_type);
+                       strcpy(filesystemType, m->mnt_type);
                   singlemount:
                         extra_opts = string_flags;
                         rc = EXIT_SUCCESS;



More information about the busybox mailing list