Question about <linux/loop.h> - PR libc/786
Andreas Jaeger
aj@arthur.rhein-neckar.de
Fri Oct 2 08:45:00 GMT 1998
I'm appending PR libc/786 and my correspondence with Andi Kleen. What
shall we do?
Linux 2.1.12x contains now in <linux/loop.h>:
/*
* Note that this structure gets the wrong offsets when directly used
* from a glibc program, because glibc has a 32bit dev_t.
* Prevent people from shooting in their own foot.
*/
#if __GLIBC__ >= 2 && !defined(dev_t)
#error "Wrong dev_t in loop.h"
#endif
Andreas
>Number: 786
>Category: libc
>Synopsis: loop_info is missing in glibc, and linux/loop.h is incompatible
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: libc-gnats
>State: open
>Class: sw-bug
>Submitter-Id: unknown
>Arrival-Date: Sat Sep 12 01:30:01 EDT 1998
>Last-Modified: Sat Sep 12 03:10:02 EDT 1998
>Originator: Andi Kleen
>Organization:
unorganized
>Release: libc-2.0.7
>Environment:
Host type: i686-pc-linux-gnu
System: Linux kali 2.1.119 #306 Sun Sep 6 10:57:12 MEST 1998 i686 unknown
Architecture: i686
RedHat 5.0
Addons: crypt linuxthreads localedata
Build CFLAGS: -O2 -m486 -fno-strength-reduce -DNDEBUG=1
Build CC: gcc -B$(common-objpfx)
Build shared: yes
Build profile: yes
Build omitfp: no
Stdio: libio
>Description:
glibc does not define the loop_info structure needed to configure the linux
loopback block device. losetup/mount simply include linux/loop.h. The problem
is that loop_info contains dev_t members, which are 16bit in the kernel and
32bit in glibc userland. Result is that losetup messes up all structure offsets
after the dev_t members and the loopback device is not correctly configured.
>How-To-Repeat:
Use a losetup.c that was compiled under glibc and set up a encrypting
loopback device.
>Fix:
Either:
- Add a translation layer for the ioctl that converts the 32bit dev_t into
16bit dev_t. It would require a general hook in ioctl() and thus be very slow
and add costs for everything.
- Use some hack to have a 16bit dev_t for loop_info (that is what I did to
get it to work)
- Add a new function "configure_loop_dev" that does the appropiate
conversion and hides the kernel interface.
-Andi
>Audit-Trail:
From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
To: andi@fred.muc.de
Cc: bugs@gnu.org
Subject: Re: libc/786: Missing declaration of loop_info for Linux loop device
Date: 12 Sep 1998 07:59:26 +0200
>>>>> andi writes:
>> Number: 786
>> Category: libc
>> Synopsis: loop_info is missing in glibc, and linux/loop.h is incompatible
>> Description:
> glibc does not define the loop_info structure needed to configure the linux
> loopback block device. losetup/mount simply include linux/loop.h. The problem
> is that loop_info contains dev_t members, which are 16bit in the kernel and
> 32bit in glibc userland. Result is that losetup messes up all structure offsets
> after the dev_t members and the loopback device is not correctly configured.
>> How-To-Repeat:
> Use a losetup.c that was compiled under glibc and set up a encrypting
> loopback device.
>> Fix:
> Either:
> - Add a translation layer for the ioctl that converts the 32bit dev_t into
> 16bit dev_t. It would require a general hook in ioctl() and thus be very slow
> and add costs for everything.
> - Use some hack to have a 16bit dev_t for loop_info (that is what I did to
> get it to work)
> - Add a new function "configure_loop_dev" that does the appropiate
> conversion and hides the kernel interface.
Or: make linux/loop.h compatible. Can't we just change dev_t to
kdev_t?
Andreas
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de
From: Andi Kleen <ak@muc.de>
To: Andreas Jaeger <aj@arthur.rhein-neckar.de>, andi@fred.muc.de
Cc: bugs@gnu.org
Subject: Re: libc/786: Missing declaration of loop_info for Linux loop device
Date: Sat, 12 Sep 1998 08:04:19 +0200
On Sat, Sep 12, 1998 at 07:59:26AM +0200, Andreas Jaeger wrote:
> >>>>> andi writes:
>
> >> Number: 786
> >> Category: libc
> >> Synopsis: loop_info is missing in glibc, and linux/loop.h is incompatible
>
> >> Description:
>
> > glibc does not define the loop_info structure needed to configure the linux
> > loopback block device. losetup/mount simply include linux/loop.h. The problem
> > is that loop_info contains dev_t members, which are 16bit in the kernel and
> > 32bit in glibc userland. Result is that losetup messes up all structure offsets
> > after the dev_t members and the loopback device is not correctly configured.
> >> How-To-Repeat:
>
> > Use a losetup.c that was compiled under glibc and set up a encrypting
> > loopback device.
> >> Fix:
>
> > Either:
> > - Add a translation layer for the ioctl that converts the 32bit dev_t into
> > 16bit dev_t. It would require a general hook in ioctl() and thus be very slow
> > and add costs for everything.
>
> > - Use some hack to have a 16bit dev_t for loop_info (that is what I did to
> > get it to work)
>
> > - Add a new function "configure_loop_dev" that does the appropiate
> > conversion and hides the kernel interface.
> Or: make linux/loop.h compatible. Can't we just change dev_t to
> kdev_t?
That would be my second option (.. "some hack to"). Problem is that it makes
it hard to write loop configuring programs, because they all have to know how
to convert a dev_t into kdev_t, and need to know the kernel internal
representation of kdev_t (which may change without notice).
Does glibc supply a standard mechanism for the user to convert dev_t into
kdev_t ?
-Andi
From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
To: Andi Kleen <ak@muc.de>
Cc: bugs@gnu.org
Subject: Re: libc/786: Missing declaration of loop_info for Linux loop device
Date: 12 Sep 1998 08:36:27 +0200
>>>>> Andi Kleen writes:
>> > Either:
>> > - Add a translation layer for the ioctl that converts the 32bit dev_t into
>> > 16bit dev_t. It would require a general hook in ioctl() and thus be very slow
>> > and add costs for everything.
>>
>> > - Use some hack to have a 16bit dev_t for loop_info (that is what I did to
>> > get it to work)
>>
>> > - Add a new function "configure_loop_dev" that does the appropiate
>> > conversion and hides the kernel interface.
>> Or: make linux/loop.h compatible. Can't we just change dev_t to
>> kdev_t?
AK> That would be my second option (.. "some hack to"). Problem is that it makes
AK> it hard to write loop configuring programs, because they all have to know how
AK> to convert a dev_t into kdev_t, and need to know the kernel internal
AK> representation of kdev_t (which may change without notice).
Either the loop programs have to know kdev_t or glibc has to know it -
and in both cases a change of kdev_t might lead to problems.
AK> Does glibc supply a standard mechanism for the user to convert dev_t into
AK> kdev_t ?
Not that I know, check sysdeps/unix/sysv/linux/* how each file does it
individually:-(.
Uli, can you look into this?
Andreas
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de
More information about the Libc-hacker
mailing list