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: Sergio Lopez <slp%sinrega.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: David Laight <david%l8s.co.uk@localhost>
Subject: Re: kern/47806 ("Abort trap" when running Linux lddconfig)
Date: Wed, 4 Sep 2013 21:15:40 +0000

 --k1lZvvs/B4yU6o8G
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Tue, Sep 03, 2013 at 08:41:34AM +0100, David Laight wrote:
 > On Tue, Aug 27, 2013 at 10:20:01PM +0000, Sergio Lopez wrote:
 > >  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 */
 > 
 > FWIW I'd guess that the strcpy() can be replaced by a faster memcpy()
 > since the length must already be known.
 
 You're right about this, but I'd prefer to avoid doing changes
 unrelated to this PR.
 
 I've attached a newer version of the patch which avoids writting d_type
 if the application is using the old call convention. Linux doesn't
 insert d_type in its old call implementation (still present nowadays),
 and doing it as my previous patch does, could potentially corrupt the
 structure, as Enami Tsugutomo noticed.
 
 Sergio.
 
 --k1lZvvs/B4yU6o8G
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="linux_dtype.diff"
 
 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        4 Sep 2013 20:39:51 -0000
 @@ -784,9 +784,10 @@
                         }
                         idb.d_off = (linux_off_t)off;
                         idb.d_reclen = (u_short)linux_reclen;
 +                       /* Linux puts d_type at the end of each record */
 +                       *((char *)&idb + idb.d_reclen - 1) = bdp->d_type;
                 }
                 strcpy(idb.d_name, bdp->d_name);
 -               idb.d_name[strlen(idb.d_name) + 1] = bdp->d_type;
                 if ((error = copyout((void *)&idb, outp, linux_reclen)))
                         goto out;
                 /* advance past this real entry */
 
 --k1lZvvs/B4yU6o8G--
 


Home | Main Index | Thread Index | Old Index