A misconfigured disklabel can crash the kernel on listing its mounted directory contents (5.4)

classic Classic list List threaded Threaded
5 messages Options
Z
Reply | Threaded
Open this post in threaded view
|

A misconfigured disklabel can crash the kernel on listing its mounted directory contents (5.4)

Z
Hi, I've never used mailing lists so please correct mistakes and forgive
me if this is not a bug, but as I understand it you should not be able
to crash the kernel as an unpriviledged user.

In brief, I was trying to format a usb stick as ext2, and was going back
and forth between linux and openbsd to get it working on both (I'm
fairly new to openbsd). The disklabel I ended up with is pasted below.
It seems misconfigured, but is the result of using (on arch linux)
cfdisk to delete all partitions and create a new one, and then mkfs.ext2
to create the filesystem. Previously I had created a working ext2
partition on openbsd, but linux could not read it.

I can mount this disk fine, but when I go to list the mount directory
with ls -l, the whole computer crashes. I've verified this is true many
times both at the console and also when ssh'd into the pc. It just
freezes and accepts no input. The ssh connection hangs. Nothing except a
physical poweroff does anything.

I should point out that the usb stick can be read and written to
normally on linux, so it doesn't seem to be a physical hardware problem.
I should also say that the method I'm using to mount the stick as a non
priviledged user seems a little fishy - namely chmodding 660 /dev/sd1*
and making my user a member of the operators group. Or perhaps this is
the normal way on OpenBSD, I don't know.

I'm using 5.4 on an IBM Thinkpad T60. I'm happy to post a full
dmesg/usbdevs/pcidump etc if it helps, but thought it might be too much
for a first post.

> disklabel sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Cruzer Blade
duid: 704ebc363be23fd4
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 973
total sectors: 15633408
boundstart: 0
boundend: 15633408
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:         15633408                0  ext2fs                   # /home/z/mounts/key
  c:         15633408                0 ISO9660

> disklabel -d sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Cruzer Blade
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 973
total sectors: 15633408
boundstart: 0
boundend: 15633408
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  c:         15633408                0  unused
  i:         15633346               62  ext2fs


PS - excuse the email username "z" - I haven't got around to properly
configuring smtpd yet.

Reply | Threaded
Open this post in threaded view
|

Re: A misconfigured disklabel can crash the kernel on listing its mounted directory contents (5.4)

Kevin Chadwick-2
previously on this list Z contributed:

> In brief, I was trying to format a usb stick as ext2, and was going back
> and forth between linux and openbsd to get it working on both (I'm
> fairly new to openbsd). The disklabel I ended up with is pasted below.
> It seems misconfigured,

You shouldn't need to use disklabel for a usb stick.

Not sure if this is still needed but mkfs.ext2 -I 128 became needed
for OpenBSD to mount it but that was made obvious from the xconsole
output.

ext2fs works fine for me but I have seen some panics when unplugging;
ext2fs doesn't get that much love on OpenBSD so you may get more
reliability (no panics) using msdosfs or ntfs-3g from ports. The latter
requires raw access though for some strange reason and so won't work
with securelevel=2 (not default).

You can also mount ffs (ufs) on linux read only by specifying ufs type
44bsd to mount.

--
_______________________________________________________________________

'Write programs that do one thing and do it well. Write programs to work
together. Write programs to handle text streams, because that is a
universal interface'

(Doug McIlroy)

In Other Words - Don't design like polkit or systemd
_______________________________________________________________________

I have no idea why RTFM is used so aggressively on LINUX mailing lists
because whilst 'apropos' is traditionally the most powerful command on
Unix-like systems it's 'modern' replacement 'apropos' on Linux is a tool
to help psychopaths learn to control their anger.

(Kevin Chadwick)

_______________________________________________________________________

Reply | Threaded
Open this post in threaded view
|

Re: A misconfigured disklabel can crash the kernel on listing its mounted directory contents (5.4)

Kevin Chadwick-3
In reply to this post by Z
previously on this list Z contributed:

> In brief, I was trying to format a usb stick as ext2, and was going back
> and forth between linux and openbsd to get it working on both (I'm
> fairly new to openbsd). The disklabel I ended up with is pasted below.
> It seems misconfigured,

forgot to say make sure you zero atleast the first megabyte of the usb
if your having problems.

/bin/dd if=/dev/zero of=/dev/sd?c

wait a few seconds then press ^C (control-C)

--
_______________________________________________________________________

'Write programs that do one thing and do it well. Write programs to work
together. Write programs to handle text streams, because that is a
universal interface'

(Doug McIlroy)

In Other Words - Don't design like polkit or systemd
_______________________________________________________________________

I have no idea why RTFM is used so aggressively on LINUX mailing lists
because whilst 'apropos' is traditionally the most powerful command on
Unix-like systems it's 'modern' replacement 'apropos' on Linux is a tool
to help psychopaths learn to control their anger.

(Kevin Chadwick)

_______________________________________________________________________

Reply | Threaded
Open this post in threaded view
|

Re: A misconfigured disklabel can crash the kernel on listing its mounted directory contents (5.4)

Kenneth Westerback
In reply to this post by Z
I'm pretty sure that Linux does not manufacture disklabels that are
compatible with OpenBSD. And visa versa! And if you're
creating/mounting filesystems you are *not* an unprivileged user and
you *definitely* can crash systems if you're not careful. :-)

That said, if you can provide details on the crash this particular one
may be avoidable.

.... Ken


On 26 April 2014 11:41, Z <[hidden email]> wrote:

> Hi, I've never used mailing lists so please correct mistakes and forgive
> me if this is not a bug, but as I understand it you should not be able
> to crash the kernel as an unpriviledged user.
>
> In brief, I was trying to format a usb stick as ext2, and was going back
> and forth between linux and openbsd to get it working on both (I'm
> fairly new to openbsd). The disklabel I ended up with is pasted below.
> It seems misconfigured, but is the result of using (on arch linux)
> cfdisk to delete all partitions and create a new one, and then mkfs.ext2
> to create the filesystem. Previously I had created a working ext2
> partition on openbsd, but linux could not read it.
>
> I can mount this disk fine, but when I go to list the mount directory
> with ls -l, the whole computer crashes. I've verified this is true many
> times both at the console and also when ssh'd into the pc. It just
> freezes and accepts no input. The ssh connection hangs. Nothing except a
> physical poweroff does anything.
>
> I should point out that the usb stick can be read and written to
> normally on linux, so it doesn't seem to be a physical hardware problem.
> I should also say that the method I'm using to mount the stick as a non
> priviledged user seems a little fishy - namely chmodding 660 /dev/sd1*
> and making my user a member of the operators group. Or perhaps this is
> the normal way on OpenBSD, I don't know.
>
> I'm using 5.4 on an IBM Thinkpad T60. I'm happy to post a full
> dmesg/usbdevs/pcidump etc if it helps, but thought it might be too much
> for a first post.
>
>> disklabel sd1
> # /dev/rsd1c:
> type: SCSI
> disk: SCSI disk
> label: Cruzer Blade
> duid: 704ebc363be23fd4
> flags:
> bytes/sector: 512
> sectors/track: 63
> tracks/cylinder: 255
> sectors/cylinder: 16065
> cylinders: 973
> total sectors: 15633408
> boundstart: 0
> boundend: 15633408
> drivedata: 0
>
> 16 partitions:
> #                size           offset  fstype [fsize bsize  cpg]
>   a:         15633408                0  ext2fs                   # /home/z/mounts/key
>   c:         15633408                0 ISO9660
>
>> disklabel -d sd1
> # /dev/rsd1c:
> type: SCSI
> disk: SCSI disk
> label: Cruzer Blade
> duid: 0000000000000000
> flags:
> bytes/sector: 512
> sectors/track: 63
> tracks/cylinder: 255
> sectors/cylinder: 16065
> cylinders: 973
> total sectors: 15633408
> boundstart: 0
> boundend: 15633408
> drivedata: 0
>
> 16 partitions:
> #                size           offset  fstype [fsize bsize  cpg]
>   c:         15633408                0  unused
>   i:         15633346               62  ext2fs
>
>
> PS - excuse the email username "z" - I haven't got around to properly
> configuring smtpd yet.

Reply | Threaded
Open this post in threaded view
|

Re: A misconfigured disklabel can crash the kernel on listing its mounted directory contents (5.4)

Kevin Chadwick-2
In reply to this post by Kevin Chadwick-3
previously on this list Kevin Chadwick contributed:

> /bin/dd if=/dev/zero of=/dev/sd?c

Whoops, you should use the raw device on OpenBSD too. The following is
much faster at zeroing

/bin/dd if=/dev/zero of=/dev/rsd?c bs=32k

--
_______________________________________________________________________

'Write programs that do one thing and do it well. Write programs to work
together. Write programs to handle text streams, because that is a
universal interface'

(Doug McIlroy)

In Other Words - Don't design like polkit or systemd
_______________________________________________________________________

I have no idea why RTFM is used so aggressively on LINUX mailing lists
because whilst 'apropos' is traditionally the most powerful command on
Unix-like systems it's 'modern' replacement 'apropos' on Linux is a tool
to help psychopaths learn to control their anger.

(Kevin Chadwick)

_______________________________________________________________________