bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20210: tests/df/skip-duplicates fails on Debian-kFreeBSD due to call


From: Assaf Gordon
Subject: bug#20210: tests/df/skip-duplicates fails on Debian-kFreeBSD due to calling 'strstr(NULL, )'
Date: Thu, 26 Mar 2015 20:28:40 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

Hello,

A somewhat exotic test failure:

On Debian/kFreeBSD 'tests/df/skip-duplicates' fails with 'df' segfaulting like 
so:

     ...
     ./tests/df/skip-duplicates.sh: line 113:  7741 Segmentation fault      
LD_PRELOAD=./k.so df
     ...

The flow is:
1. the "k.so" file (inlined C code in 'tests/df/skip-duplicates.sh') returns 
'struct mntent' in which '.mnt_opts' is NULL (not just empty string)
2. read_file_system_list() calls dev_from_mount_options(mnt->mnt_opts) .
3. in dev_from_mount_options()  "__linux__" is not defined (using FreeBSD 
kernel v9).
4. strstr() is called with 'mount_options==NULL'.
5. libc segfaults.

The direct culprit is 'dev_from_mount_options' in gnulib's mountlist.c, which 
has:

     static dev_t
     dev_from_mount_options (char const *mount_options)
     {
       /* GNU/Linux allows file system implementations to define their own
          meaning for "dev=" mount options, so don't trust the meaning
          here.  */
     # ifndef __linux__
       static char const dev_pattern[] = ",dev=";
       char const *devopt = strstr (mount_options, dev_pattern);
     ...


Using gdb, the stack-trace is:
     $ gdb ../src/df
     (gdb) set environment LD_PRELOAD=./k.so
     (gdb) start
     Program received signal SIGSEGV, Segmentation fault.
     0x0000000800abcc04 in strstr () from /lib/x86_64-kfreebsd-gnu/libc.so.0.1
     (gdb) bt
     #0  0x0000000800abcc04 in strstr () from 
/lib/x86_64-kfreebsd-gnu/libc.so.0.1
     #1  0x000000000040f7ed in dev_from_mount_options (mount_options=0x0) at 
lib/mountlist.c:363
     #2  0x000000000040fb6c in read_file_system_list (need_fs_type=false) at 
lib/mountlist.c:449
     #3  0x0000000000405751 in main (argc=1, argv=0x7fffffffd648) at 
src/df.c:1647


I'm not sure what is the correct,clean fix, attached are two options (one fixes 
the test, one avoids the call in lib/mountlist.c).

Regards,
  - assaf

P.S.
On FReeBSD-10.1 the test is skipped:
   skip-duplicates.sh: skipped test: $CC -shared ... failed to build a shared 
lib
   SKIP: tests/df/skip-duplicates.sh


Attachment: fix-df-skip-dups1.patch
Description: Text Data

Attachment: fix-lib-mountlist.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]