NetBSD-Bugs archive

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

Re: kern/47806 ("Abort trap" when running Linux lddconfig)



The following reply was made to PR kern/47806; it has been noted by GNATS.

From: Thomas Klausner <wiz%NetBSD.org@localhost>
To: Sergio Lopez <slp%sinrega.org@localhost>
Cc: gnats-bugs%NetBSD.org@localhost
Subject: Re: kern/47806 ("Abort trap" when running Linux lddconfig)
Date: Sun, 1 Sep 2013 19:27:05 +0200

 Hi Sergio!
 
 On Tue, Aug 27, 2013 at 10:14:39PM +0000, Sergio Lopez wrote:
 > ldconfig uses dirent's d_type to determine whether an entry is a
 > regular file or a link, and it's getting confused by bogus values on
 > said field.
 > 
 > The emulation code puts d_type just after the d_name string, but glibc
 > expects to find it at the end of the record, which, as the structure
 > is ALIGN'ed, could be at a different offset.
 > 
 > Something like the change in the attached diff should make the trick.
 
 Thanks for investigating this!
 
 > Index: linux_misc.c
 > ===================================================================
 > RCS file: /cvsroot/src/sys/compat/linux/common/linux_misc.c,v
 > retrieving revision 1.224
 > diff -u -r1.224 linux_misc.c
 > --- linux_misc.c     11 Aug 2013 09:07:15 -0000      1.224
 > +++ linux_misc.c     27 Aug 2013 21:01:06 -0000
 > @@ -786,7 +786,7 @@
 >                      idb.d_reclen = (u_short)linux_reclen;
 >              }
 >              strcpy(idb.d_name, bdp->d_name);
 > -            idb.d_name[strlen(idb.d_name) + 1] = bdp->d_type;
 > +            *((char *)&idb + idb.d_reclen - 1) = bdp->d_type;
 >              if ((error = copyout((void *)&idb, outp, linux_reclen)))
 >                      goto out;
 >              /* advance past this real entry */
 
 I've built a kernel (from -current sources of Aug 29) with this change
 and deleted and reinstalled every Linux emulation package -- there
 wasn't a single ldconfig coredump. So this seems to fix the problem,
 thank you! Can you please commit it (or a variant -- ISTR there are
 macros for playing around with alignment.)?
  Thomas
 


Home | Main Index | Thread Index | Old Index