Skip to contentSkip to conversation

ide-cd problems

DISCUSSION Zinx Verituse 12 participants 52 messages Jul 30, 2004 – Aug 9, 2004 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.
* You can't open the device unless there is media in the drive
* Still seems to be no way to specify scatter gather/dma buffers yourself, though I'm not entirely sure that matters anyway.

The read-only granting write/blank seems like a pretty serious security issue to me. Not being able to open the device without media is merely extremely annoying (and I suspect fixing it would break a lot of programs).

Signature · 1 line
Zinx Verituse                                    http://zinx.xmms.org/
#1 lore raw
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

That's by design. Search linux-scsi or this list for why that is so.

Quoted 1 line

* You can't open the device unless there is media in the drive

False, you use O_NONBLOCK.

Quoted 2 lines

* Still seems to be no way to specify scatter gather/dma buffers yourself, though I'm not entirely sure that matters anyway.

That's true, later implementation of block layer SG_IO adds that as well. It's really a minor thing though, I don't think I've ever seen anyone use it outside of regression testing scripts.

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 9 lines · Jens Axboe
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

That's by design. Search linux-scsi or this list for why that is so.

The only thing I can find on the linux-scsi list is refering to sg devices, which are on a different device node from the non-generic device. This means you can still allow users read access to the disk without allowing them to send random commands to the disk -- this isn't currently possible with the IDE interface, since the device with generic access is the same as the one with the original read/cdrom commands access.

As it is, it's impossible grant users read-only access to an IDE cd-rom without allowing them to do things like replacing the firmware with a malicious/non-working one.

Generic access allowing such things is fine; but only if we can grant non-generic access without granting generic access.

Quoted 4 lines
Quoted 2 lines

* You can't open the device unless there is media in the drive

False, you use O_NONBLOCK.

Thanks, I didn't know about this one -- works great :)

Quoted 1 line

[snip stuff about scatter gather/manual dma]

Quoted 3 lines
Signature · 2 lines
-- 
Jens Axboe
Signature · 1 line
Zinx Verituse                                    http://zinx.xmms.org/
#3 lore raw
Quoted 19 lines · Zinx Verituse
Quoted 9 lines · Jens Axboe
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

That's by design. Search linux-scsi or this list for why that is so.

The only thing I can find on the linux-scsi list is refering to sg devices, which are on a different device node from the non-generic device. This means you can still allow users read access to the disk without allowing them to send random commands to the disk -- this isn't currently possible with the IDE interface, since the device with generic access is the same as the one with the original read/cdrom commands access.

Quoted 6 lines

As it is, it's impossible grant users read-only access to an IDE cd-rom without allowing them to do things like replacing the firmware with a malicious/non-working one.

Generic access allowing such things is fine; but only if we can grant non-generic access without granting generic access.

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

If you have access to issue ioctls to the device, you have access to send it arbitrary commands - period.

Signature · 1 line
Jens Axboe
#4 lore raw
Quoted 27 lines · Jens Axboe
Quoted 19 lines · Zinx Verituse
Quoted 9 lines · Jens Axboe
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

That's by design. Search linux-scsi or this list for why that is so.

The only thing I can find on the linux-scsi list is refering to sg devices, which are on a different device node from the non-generic device. This means you can still allow users read access to the disk without allowing them to send random commands to the disk -- this isn't currently possible with the IDE interface, since the device with generic access is the same as the one with the original read/cdrom commands access.

Quoted 6 lines

As it is, it's impossible grant users read-only access to an IDE cd-rom without allowing them to do things like replacing the firmware with a malicious/non-working one.

Generic access allowing such things is fine; but only if we can grant non-generic access without granting generic access.

Quoted 7 lines

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

If you have access to issue ioctls to the device, you have access to send it arbitrary commands - period.

I don't believe command filtering is neccessary, since all of the ide-cd ioctls are still there (ioctls that allow playing, reading, etc) Only the SG_IO ioctl itself would have to be checked (i.e., not each individual command available with SG_IO, just the overall ioctl itself, categorizing all of SG_IO more or less as raw IO. If this isn't doable with the current design, then the ide-cd interface should at least be very conspicuously documented as being extremely insecure as far as "read" access is concerned, as I know I wouldn't expect users to be able to overwrite my drive's firmware simply by granting the read access.

Signature · 1 line
Zinx Verituse                                    http://zinx.xmms.org/
#5 lore raw
Quoted 10 lines · Zinx Verituse

I don't believe command filtering is neccessary, since all of the ide-cd ioctls are still there (ioctls that allow playing, reading, etc) Only the SG_IO ioctl itself would have to be checked (i.e., not each individual command available with SG_IO, just the overall ioctl itself, categorizing all of SG_IO more or less as raw IO. If this isn't doable with the current design, then the ide-cd interface should at least be very conspicuously documented as being extremely insecure as far as "read" access is concerned, as I know I wouldn't expect users to be able to overwrite my drive's firmware simply by granting the read access.

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

cdrecord dev=ATAPI:1,1,0 image.iso

Signature · 1 line
Alexander E. Patrakov
#6 lore raw
Quoted 12 lines · Alexander E. Patrakov
Quoted 10 lines · Zinx Verituse

I don't believe command filtering is neccessary, since all of the ide-cd ioctls are still there (ioctls that allow playing, reading, etc) Only the SG_IO ioctl itself would have to be checked (i.e., not each individual command available with SG_IO, just the overall ioctl itself, categorizing all of SG_IO more or less as raw IO. If this isn't doable with the current design, then the ide-cd interface should at least be very conspicuously documented as being extremely insecure as far as "read" access is concerned, as I know I wouldn't expect users to be able to overwrite my drive's firmware simply by granting the read access.

Quoted 4 lines

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

cdrecord dev=ATAPI:1,1,0 image.iso

(don't trim cc lists on linux-kernel!)

Don't ever use that interface, period. It's not just the cdrecord code that may be alpha (I doubt it matters, it's easy to use), the interface it uses is not worth the lines of code it occupies.

Signature · 1 line
Jens Axboe
#7 lore raw
Quoted 1 line · Jens Axboe

On Sun, Aug 01 2004, Alexander E. Patrakov wrote:

[...]

Quoted 4 lines
Quoted 4 lines

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

cdrecord dev=ATAPI:1,1,0 image.iso

[...]

Quoted 1 line

Don't ever use that interface, period.

Great! So I won't be able to use any of the CD burners I have now.

Quoted 3 lines

It's not just the cdrecord code
that may be alpha (I doubt it matters, it's easy to use), the interface it uses is not worth the lines of code it occupies.

What do you suggest then? ide-scsi is gone, so AFAIK this is the only way to burn CDs right now on 2.6.x

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#8 lore raw
Quoted 8 lines · Horst von Brand
Quoted 1 line · Jens Axboe

On Sun, Aug 01 2004, Alexander E. Patrakov wrote:

[...]

Quoted 3 lines
Quoted 3 lines

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

Quoted 7 lines
Quoted 1 line
Quoted 1 line

cdrecord dev=ATAPI:1,1,0 image.iso

[...]

Quoted 1 line

Don't ever use that interface, period.

Great! So I won't be able to use any of the CD burners I have now.

Use the SG_IO interface, it should be the default if you just specify dev=/dev/hdc instead of faking some SCSI like device enumeration for ATAPI.

Quoted 6 lines
Quoted 3 lines

It's not just the cdrecord code
that may be alpha (I doubt it matters, it's easy to use), the interface it uses is not worth the lines of code it occupies.

What do you suggest then? ide-scsi is gone, so AFAIK this is the only way to burn CDs right now on 2.6.x

If you read the above, it was about 2.4 and using ide-cd instead of ide-scsi there. In 2.6 you have two options outside of ide-scsi: one is the CDROM_SEND_PACKET (which is what the dev=ATAPI:1,1,0 above used) which works in both 2.4 and 2.6, but is absolutely crap and not recommended. The other is the SG_IO method, which is the recommended approach.

Signature · 1 line
Jens Axboe
#10 lore raw
In reply to Jens Axboe

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 16 lines · Jens Axboe
Quoted 15 lines · Alexander E. Patrakov
Quoted 10 lines · Zinx Verituse

I don't believe command filtering is neccessary, since all of the ide-cd ioctls are still there (ioctls that allow playing, reading, etc) Only the SG_IO ioctl itself would have to be checked (i.e., not each individual command available with SG_IO, just the overall ioctl itself, categorizing all of SG_IO more or less as raw IO. If this isn't doable with the current design, then the ide-cd interface should at least be very conspicuously documented as being extremely insecure as far as "read" access is concerned, as I know I wouldn't expect users to be able to overwrite my drive's firmware simply by granting the read access.

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

Quoted 7 lines
Quoted 1 line

cdrecord dev=ATAPI:1,1,0 image.iso

(don't trim cc lists on linux-kernel!)

Don't ever use that interface, period. It's not just the cdrecord code that may be alpha (I doubt it matters, it's easy to use), the interface it uses is not worth the lines of code it occupies.

Then we have a severe disagreement between the cdrecord code (or at
least the runtime warnings) and the Linux-Kernel IDE folks. specifically, these lines, while running with cdrecord dev=/dev/cdrom

scsidev: '/dev/cdrom'
devname: '/dev/cdrom'
scsibus: -2 target: -2 lun: -2
Warning: Open by 'devname' is unintentional and not supported.

I've attached two logs, one using the ATAPI interface, one using your
suggested interface. Frankly, both have rather nasty warnings on them, and one gets to wondering what the cdrecord authors want...

Maybe we should be cc:ing the authors of cdrecord as well?

- --
tabris
- -
Remember, Grasshopper, falling down 1000 stairs begins by tripping over the first one.
-- Confusion
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBDkVf1U5ZaPMbKQcRAukeAJ9y33IURJFheeJ39rtvJXHI6Ii5AwCgihup Vo50HwMaGJe53L/zPFayGEY=
=udwi
-----END PGP SIGNATURE-----

cdrecord: No write mode specified.
cdrecord: Asuming -tao mode.
cdrecord: Future versions of cdrecord may have different drive dependent defaults.
scsidev: 'ATAPI:0,0,0'
devname: 'ATAPI'
scsibus: 0 target: 0 lun: 0
Warning: Using ATA Packet interface.
Warning: The related libscg interface code is in pre alpha.
Warning: There may be fatal problems.
SCSI buffer size: 64512
Cdrecord-Clone 2.01a27-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling
Note: This version is an unofficial (modified) version with DVD support
Note: and therefore may have bugs that are not present in the original.
Note: Please send bug reports or support requests to <[email protected]>.
Note: The author of cdrecord should not be bothered with problems in this version. TOC Type: 1 = CD-ROM
Using libscg version 'schily-0.8'.
atapi: 1
Device type : Removable CD-ROM
Version : 0
Response Format: 2
Capabilities :
Vendor_info : 'TDK '
Identifikation : 'CDRW241040B '
Revision : '57S2'
Device seems to be: Generic mmc CD-RW.
Current: 0x0009
Profile: 0x000A
Profile: 0x0009 (current)
Profile: 0x0008
Profile: 0x0002 (current)
Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).
Driver flags : MMC-3 SWABAUDIO BURNFREE
Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R16 RAW/R96P RAW/R96R Drive buf size : 1966272 = 1920 KB
FIFO size : 4194304 = 4096 KB

cdrecord: No write mode specified.
cdrecord: Asuming -tao mode.
cdrecord: Future versions of cdrecord may have different drive dependent defaults.
scsidev: '/dev/cdrom'
devname: '/dev/cdrom'
scsibus: -2 target: -2 lun: -2
Warning: Open by 'devname' is unintentional and not supported.
Linux sg driver version: 3.5.27
cdrecord: Warning: using inofficial libscg transport code version (warly-scsi-linux-sg.c-1.80-mdk '@(#)scsi-linux-sg.c 1.80 04/03/08 Copyright 1997 J. Schilling').
SCSI buffer size: 64512
Cdrecord-Clone 2.01a27-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling
Note: This version is an unofficial (modified) version with DVD support
Note: and therefore may have bugs that are not present in the original.
Note: Please send bug reports or support requests to <[email protected]>.
Note: The author of cdrecord should not be bothered with problems in this version. TOC Type: 1 = CD-ROM
Using libscg version 'schily-0.8'.
atapi: 1
Device type : Removable CD-ROM
Version : 0
Response Format: 2
Capabilities :
Vendor_info : 'TDK '
Identifikation : 'CDRW241040B '
Revision : '57S2'
Device seems to be: Generic mmc CD-RW.
Current: 0x0009
Profile: 0x000A
Profile: 0x0009 (current)
Profile: 0x0008
Profile: 0x0002 (current)
Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).

Driver flags   : MMC-3 SWABAUDIO BURNFREE 
Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R16 RAW/R96P RAW/R96R
Drive buf size : 1966272 = 1920 KB
FIFO size      : 4194304 = 4096 KB
Track 01: data   405 MB        
Total size:      466 MB (46:10.90) = 207818 sectors
Lout start:      466 MB (46:12/68) = 207818 sectors
Current Secsize: 2048

ATIP info from disk:
Indicated writing power: 4
Is not unrestricted
Is not erasable
Disk sub type: Medium Type A, high Beta category (A+) (3) ATIP start of lead in: -11849 (97:24/01)
ATIP start of lead out: 359848 (79:59/73)

Disk type:    Long strategy type (Cyanine, AZO or similar)
Manuf. index: 25
Manufacturer: Taiyo Yuden Company Limited
Blocks total: 359848 Blocks current: 359848 Blocks remaining: 152030

Starting to write CD/DVD at speed 8.0 in dummy TAO mode for single session.
Last chance to quit, starting dummy write in 9 seconds. 8 seconds.cdrecord: fifo had 64 puts and 0 gets.
cdrecord: fifo was 0 times empty and 1 times full, min fill was 0%.

#11 lore raw
Quoted 27 lines · tabris

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 16 lines · Jens Axboe
Quoted 15 lines · Alexander E. Patrakov
Quoted 10 lines · Zinx Verituse

I don't believe command filtering is neccessary, since all of the ide-cd ioctls are still there (ioctls that allow playing, reading, etc) Only the SG_IO ioctl itself would have to be checked (i.e., not each individual command available with SG_IO, just the overall ioctl itself, categorizing all of SG_IO more or less as raw IO. If this isn't doable with the current design, then the ide-cd interface should at least be very conspicuously documented as being extremely insecure as far as "read" access is concerned, as I know I wouldn't expect users to be able to overwrite my drive's firmware simply by granting the read access.

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

Quoted 7 lines
Quoted 1 line

cdrecord dev=ATAPI:1,1,0 image.iso

(don't trim cc lists on linux-kernel!)

Don't ever use that interface, period. It's not just the cdrecord code that may be alpha (I doubt it matters, it's easy to use), the interface it uses is not worth the lines of code it occupies.

Quoted 8 lines

Then we have a severe disagreement between the cdrecord code (or at
least the runtime warnings) and the Linux-Kernel IDE folks. specifically, these lines, while running with cdrecord dev=/dev/cdrom

scsidev: '/dev/cdrom'
devname: '/dev/cdrom'
scsibus: -2 target: -2 lun: -2
Warning: Open by 'devname' is unintentional and not supported.

Kernel and cdrecord disagreement, news at 11.

Quoted 6 lines

I've attached two logs, one using the ATAPI interface, one using your suggested interface. Frankly, both have rather nasty warnings on them, and one gets to wondering what the cdrecord authors want...

Maybe we should be cc:ing the authors of cdrecord as well?

I appreciate the good intentions, but perhaps you should research a bit of background on this before going over board here. Don't think it hasn't been suggested to Joerg before to kill that message.

Look at the errors as well - one is about the transport used:

Quoted 6 lines

devname: 'ATAPI'
scsibus: 0 target: 0 lun: 0
Warning: Using ATA Packet interface.
Warning: The related libscg interface code is in pre alpha.
Warning: There may be fatal problems.
SCSI buffer size: 64512

The other (for SG_IO)

Quoted 4 lines

scsidev: '/dev/cdrom'
devname: '/dev/cdrom'
scsibus: -2 target: -2 lun: -2
Warning: Open by 'devname' is unintentional and not supported.

just says that open-by-device name is unintentional, it doesn't give you warnings on the transport.

So in short (and repeating): don't use ATAPI (CDROM_SEND_PACKET), it sucks. Use SG_IO (which means using open-by-device, which works at least as well as the stupid faked ATAPI bus/id/lun crap and has the much better transport). Don't compare apples and oranges.

Signature · 1 line
Jens Axboe
#12 lore raw

Jens Axboe <[email protected]> wrote:
[...]

Quoted 7 lines

just says that open-by-device name is unintentional, it doesn't give you warnings on the transport.

So in short (and repeating): don't use ATAPI (CDROM_SEND_PACKET), it sucks. Use SG_IO (which means using open-by-device, which works at least as well as the stupid faked ATAPI bus/id/lun crap and has the much better transport). Don't compare apples and oranges.

FWIW cdrecord's author prefers dev=ATA:x,y,z, which uses SG_IO *and* gets rid of the open-by-device-warning.
cu andreas

#13 lore raw
Quoted 5 lines · Andreas Metzler

Jens Axboe <[email protected]> wrote:
[...]

Quoted 3 lines

just says that open-by-device name is unintentional, it doesn't give you warnings on the transport.

Quoted 7 lines
Quoted 4 lines

So in short (and repeating): don't use ATAPI (CDROM_SEND_PACKET), it sucks. Use SG_IO (which means using open-by-device, which works at least as well as the stupid faked ATAPI bus/id/lun crap and has the much better transport). Don't compare apples and oranges.

FWIW cdrecord's author prefers dev=ATA:x,y,z, which uses SG_IO *and* gets rid of the open-by-device-warning.

(don't trim linux-kernel cc lists!)

Well good for him, that's why he didn't drop that idiotic warning. I think the x,y,z naming for ATAPI devices is utter stupidity.

Signature · 1 line
Jens Axboe
#14 lore raw
In reply to Jens Axboe

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 4 lines · Jens Axboe
Quoted 3 lines · tabris
Quoted 2 lines · Jens Axboe
Quoted 1 line · Alexander E. Patrakov

Zinx Verituse wrote:

<snip>

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

Don't ever use that interface, period. It's not just the cdrecord code that may be alpha (I doubt it matters, it's easy to use), the interface it uses is not worth the lines of code it occupies.

Then we have a severe disagreement between the cdrecord code (or
at least the runtime warnings) and the Linux-Kernel IDE folks. specifically, these lines, while running with cdrecord dev=/dev/cdrom

<snip>

Quoted 9 lines

Warning: Open by 'devname' is unintentional and not supported.

just says that open-by-device name is unintentional, it doesn't give you warnings on the transport.

So in short (and repeating): don't use ATAPI (CDROM_SEND_PACKET), it sucks. Use SG_IO (which means using open-by-device, which works at least as well as the stupid faked ATAPI bus/id/lun crap and has the much better transport). Don't compare apples and oranges.

I'll take your point on the technical merits.

But now I get to wondering what to do about all the old HOWTOs. the cdrecord folks aren't helping.

Maybe instead what should be done is a BIG FAT WARNING in the syslog?
that the CDROM_SEND_PACKET interface is deprecated in kernel 2.6? I know that I personally can listen and take your advice, but I worry more about the rest of the users, who either will not hear, or will hear too many conflicting things. Perhaps it won't help, but I'd really like to be able to sell this stuff. And among the necessary things is to be able to have sane warnings, and not have warnings that will scare my customers off!

	Yes, this isn't really your (you==Jens) problem, but probably the 

distro maintainers (cc:d ArkLinux) to put in patches silencing some of these warnings, and/or change the default behaviour of their front-end tools.

I merely hope to find some sanity. Though I have a feeling I'm looking
in the wrong places (Free and Open Source).

- --
tabris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBDlHY1U5ZaPMbKQcRAnrhAJwPM+sSRInlRy5kmpqQ+nlwS+1D5QCbBZc6 8NsRqRQqLddQgY8FuCzEvck=
=BhCR
-----END PGP SIGNATURE-----

#15 lore raw
Quoted 32 lines · tabris

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 4 lines · Jens Axboe
Quoted 3 lines · tabris
Quoted 2 lines · Jens Axboe
Quoted 1 line · Alexander E. Patrakov

Zinx Verituse wrote:

<snip>

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

Don't ever use that interface, period. It's not just the cdrecord code that may be alpha (I doubt it matters, it's easy to use), the interface it uses is not worth the lines of code it occupies.

Then we have a severe disagreement between the cdrecord code (or
at least the runtime warnings) and the Linux-Kernel IDE folks. specifically, these lines, while running with cdrecord dev=/dev/cdrom

<snip>

Quoted 9 lines

Warning: Open by 'devname' is unintentional and not supported.

just says that open-by-device name is unintentional, it doesn't give you warnings on the transport.

So in short (and repeating): don't use ATAPI (CDROM_SEND_PACKET), it sucks. Use SG_IO (which means using open-by-device, which works at least as well as the stupid faked ATAPI bus/id/lun crap and has the much better transport). Don't compare apples and oranges.

I'll take your point on the technical merits.

But now I get to wondering what to do about all the old HOWTOs. the cdrecord folks aren't helping.

Quoted 8 lines

Maybe instead what should be done is a BIG FAT WARNING in the syslog? that the CDROM_SEND_PACKET interface is deprecated in kernel 2.6? I know that I personally can listen and take your advice, but I worry more about the rest of the users, who either will not hear, or will hear too many conflicting things. Perhaps it won't help, but I'd really like to be able to sell this stuff. And among the necessary things is to be able to have sane warnings, and not have warnings that will scare my customers off!

CDROM_SEND_PACKET isn't anymore deprecated in 2.6 than it is in 2.4. It's equally silly to use it with cdrecord in either kernel. In hind sight, adding that interface was a mistake. It was never meant for anything serious like a cd burning interface. It lacks good error reporting, and it basically could not do worse when it comes to performance. So if you are in 2.4, use ide-scsi! If you are in 2.6, use ide-cd with SG_IO (eg ATA: method from cdrecord). As it was mentioned a little up in this thread, you can actually use x,y,z naming to adresse your given devices, if you have some weird urge to do so. This will kill the open-by-devname warning from cdrecord. Or you can just ignore this warning, it means absolutely nothing.

Quoted 4 lines

Yes, this isn't really your (you==Jens) problem, but probably the distro maintainers (cc:d ArkLinux) to put in patches silencing some of these warnings, and/or change the default behaviour of their front-end tools.

And we did, SUSE killed that stupid warning :-)

Quoted 2 lines

I merely hope to find some sanity. Though I have a feeling I'm looking in the wrong places (Free and Open Source).

Like any other place, free/open source communities have their sane and insane members.

Signature · 1 line
Jens Axboe
#16 lore raw
In reply to Alexander E. Patrakov
Quoted 4 lines · Alexander E. Patrakov

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

cdrecord dev=ATAPI:1,1,0 image.iso

But... doesn't that require access to the sg device?

Signature · 3 lines
   -bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me
#51 lore raw
In reply to Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

That's by design. Search linux-scsi or this list for why that is so.

So is the only solution to disallow user access to the device? Operationally that is inconvenient in some cases, but every user community has a few ill-intentioned people, and student groups may be somewhat heavy on that. Security is more important than convenience, but both are desirable.

We could go to burning all local reference data on CD-R instead of CD-RW, have a separate CD-R drive, but as noted all of those are undesirable drains on time and money. Clearly having some twit rewite the CD-RW with their own information is even more undesirable, if that wasn't clear ;-)

Signature · 3 lines
   -bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me
#18 lore raw
In reply to Zinx Verituse
Quoted 36 lines · Zinx Verituse
Quoted 27 lines · Jens Axboe
Quoted 19 lines · Zinx Verituse
Quoted 9 lines · Jens Axboe
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

That's by design. Search linux-scsi or this list for why that is so.

The only thing I can find on the linux-scsi list is refering to sg devices, which are on a different device node from the non-generic device. This means you can still allow users read access to the disk without allowing them to send random commands to the disk -- this isn't currently possible with the IDE interface, since the device with generic access is the same as the one with the original read/cdrom commands access.

Quoted 6 lines

As it is, it's impossible grant users read-only access to an IDE cd-rom without allowing them to do things like replacing the firmware with a malicious/non-working one.

Generic access allowing such things is fine; but only if we can grant non-generic access without granting generic access.

Quoted 7 lines

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

If you have access to issue ioctls to the device, you have access to send it arbitrary commands - period.

Quoted 9 lines

I don't believe command filtering is neccessary, since all of the ide-cd ioctls are still there (ioctls that allow playing, reading, etc) Only the SG_IO ioctl itself would have to be checked (i.e., not each individual command available with SG_IO, just the overall ioctl itself, categorizing all of SG_IO more or less as raw IO. If this isn't doable with the current design, then the ide-cd interface should at least be very conspicuously documented as being extremely insecure as far as "read" access is concerned, as I know I wouldn't expect users to be able to overwrite my drive's firmware simply by granting the read access.

I'm replying to this because this message was never addressed, and instead fell in to Yet Another war on cdrecord's stupid naming scheme. The two have nothing to do with each other, and this issue (i.e., not the stupid naming scheme) needs addressed.

Signature · 1 line
Zinx Verituse                                    http://zinx.xmms.org/
#9 lore raw
In reply to Horst von Brand
Quoted 22 lines · Horst von Brand
Quoted 1 line · Jens Axboe

On Sun, Aug 01 2004, Alexander E. Patrakov wrote:

[...]

Quoted 3 lines
Quoted 3 lines

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

cdrecord dev=ATAPI:1,1,0 image.iso

[...]

Quoted 1 line

Don't ever use that interface, period.

Great! So I won't be able to use any of the CD burners I have now.

Quoted 7 lines
Quoted 3 lines

It's not just the cdrecord code
that may be alpha (I doubt it matters, it's easy to use), the interface it uses is not worth the lines of code it occupies.

What do you suggest then? ide-scsi is gone, so AFAIK this is the only way to burn CDs right now on 2.6.x

Actually ide-scsi isn't gone, and what you want is ATA: not ATAPI: here. But if ATAPI: works for you, it's slow and grotty, but I think it does work. I've been using ide-scsi on 2.4 and don't plan to stop while it works, but ATAPI: is the one of choice for 2.6, particularly for burning audio.

Signature · 3 lines
   -bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me
#36 lore raw
In reply to Jens Axboe
Quoted 4 lines · Jens Axboe

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

I disagree providing you turn it the other way around. The majority of scsi commands have to be protected because you can destroy the drive with some of them or bypass the I/O layers. (Eg using SG_IO to do writes to raw disk to bypass auditing layers)

So you need CAP_SYS_RAWIO for most commands. You can easily build a list of sane commands for a given media type that are harmless and it fits the kernel role of a gatekeeper to do that.

Providing the 'allowed' function is driver level and we also honour read/write properly for that case (so it doesnt bypass block I/O restrictions and fail the least suprise test) then it seems quite doable.

For such I/O you'd then do

	if(capable(CAP_SYS_RAWIO) || driver->allowed(driver, blah, cmdblock))

If the allowed function filters positively "unknown is not allowed" and the default allowed function is simply "no" it works.

We'd end up with a list of allowed commands for all sorts of operations that don't threaten the machine while blocking vendor specific wonders and also cases where users can do stuff like firmware erase.

Alan

#37 lore raw
Quoted 6 lines · Alan Cox
Quoted 4 lines · Jens Axboe

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

Quoted 8 lines

I disagree providing you turn it the other way around. The majority of scsi commands have to be protected because you can destroy the drive with some of them or bypass the I/O layers. (Eg using SG_IO to do writes to raw disk to bypass auditing layers)

So you need CAP_SYS_RAWIO for most commands. You can easily build a list of sane commands for a given media type that are harmless and it fits the kernel role of a gatekeeper to do that.

So that's where we vehemently disagree - it fits the kernel role, if you allow it to control policy all of a sudden. And it's not easy, unless you do it per specific device (not just type, make and model).

Quoted 11 lines

Providing the 'allowed' function is driver level and we also honour read/write properly for that case (so it doesnt bypass block I/O restrictions and fail the least suprise test) then it seems quite doable.

For such I/O you'd then do

	if(capable(CAP_SYS_RAWIO) || driver->allowed(driver, blah, cmdblock))

If the allowed function filters positively "unknown is not allowed" and the default allowed function is simply "no" it works.

Until there's a new valid command for some device, in which case you have to update your kernel?

Quoted 3 lines

We'd end up with a list of allowed commands for all sorts of operations that don't threaten the machine while blocking vendor specific wonders and also cases where users can do stuff like firmware erase.

Sorry, I think this model is totally bogus and I'd absolutely refuse to merge any such beast into the block layer sg code.

Signature · 1 line
Jens Axboe
#17 lore raw
In reply to Bill Davidsen
Quoted 8 lines · Bill Davidsen
Quoted 5 lines · Alexander E. Patrakov

Remember that it is still possible to write CDs through ide-cd in 2.4.x using some pre-alpha code in cdrecord:

cdrecord dev=ATAPI:1,1,0 image.iso

But... doesn't that require access to the sg device?

(don't snip cc lists...)

No, it goes through /dev/hdX or /dev/srX

Signature · 1 line
Jens Axboe
#48 lore raw
In reply to Alan Cox
Quoted 11 lines · Alan Cox
Quoted 4 lines · Jens Axboe

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

I disagree providing you turn it the other way around. The majority of scsi commands have to be protected because you can destroy the drive with some of them or bypass the I/O layers. (Eg using SG_IO to do writes to raw disk to bypass auditing layers)

Where would the case of firmware download fit? For x86 ATA/ATAPI devices, the vendor usually supplies a dos disk to accomplish this. However, that method is absolutely broken a PPC system. We have to use a proprietary driver that was written using vendor specific commands. I assume that all vendors have their own set of proprietary commands, specific to the device to be updated.

Usually one does not need to do firmware updates, but when necessary, it is generally a requirement to do it on the system with the device, not to remove the device and carry it to a system where it can be done.

If there was an interface to allow wide open operations, including a non-interrupt (polling) mode of operation, this would cover a large portion of devices.

Quoted 12 lines

So you need CAP_SYS_RAWIO for most commands. You can easily build a list of sane commands for a given media type that are harmless and it fits the kernel role of a gatekeeper to do that.

Providing the 'allowed' function is driver level and we also honour read/write properly for that case (so it doesnt bypass block I/O restrictions and fail the least suprise test) then it seems quite doable.

For such I/O you'd then do

Quoted 8 lines
	if(capable(CAP_SYS_RAWIO) || driver->allowed(driver, blah, cmdblock))

If the allowed function filters positively "unknown is not allowed" and the default allowed function is simply "no" it works.

We'd end up with a list of allowed commands for all sorts of operations that don't threaten the machine while blocking vendor specific wonders and also cases where users can do stuff like firmware erase.

Allowed commands are really on a device specfic basis. And a RAS requirement, for at least those of use that have funny endianess hardware. :)

++doug

#52 lore raw
In reply to Bill Davidsen
Quoted 10 lines · Bill Davidsen
Quoted 8 lines · Jens Axboe
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

Quoted 7 lines
Quoted 1 line

That's by design. Search linux-scsi or this list for why that is so.

So is the only solution to disallow user access to the device? Operationally that is inconvenient in some cases, but every user community has a few ill-intentioned people, and student groups may be somewhat heavy on that. Security is more important than convenience, but both are desirable.

Right. It is called "compromise".

Quoted 5 lines

We could go to burning all local reference data on CD-R instead of CD-RW, have a separate CD-R drive, but as noted all of those are undesirable drains on time and money. Clearly having some twit rewite the CD-RW with their own information is even more undesirable, if that wasn't clear ;-)

OK, what prevents said twit from bringing in their own (doctored) CD-R in any case?

Signature · 4 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
#38 lore raw
In reply to Jens Axboe
Quoted 12 lines · Jens Axboe
Quoted 11 lines · Alan Cox
Quoted 4 lines · Jens Axboe

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

I disagree providing you turn it the other way around. The majority of scsi commands have to be protected because you can destroy the drive with some of them or bypass the I/O layers. (Eg using SG_IO to do writes to raw disk to bypass auditing layers)

Quoted 8 lines
Quoted 3 lines

So you need CAP_SYS_RAWIO for most commands. You can easily build a list of sane commands for a given media type that are harmless and it fits the kernel role of a gatekeeper to do that.

So that's where we vehemently disagree - it fits the kernel role, if you allow it to control policy all of a sudden. And it's not easy, unless you do it per specific device (not just type, make and model).

Vendor commands would be tricky (it would probably be best to limit vendor commands to well-established ones, and just disallow the rest without CAP_SYS_RAWIO or such), but standard commands wouldn't have a problem, and those don't get added very often.

Quoted 7 lines
Quoted 7 lines

Providing the 'allowed' function is driver level and we also honour read/write properly for that case (so it doesnt bypass block I/O restrictions and fail the least suprise test) then it seems quite doable.

For such I/O you'd then do

Quoted 8 lines
Quoted 4 lines
	if(capable(CAP_SYS_RAWIO) || driver->allowed(driver, blah, cmdblock))

If the allowed function filters positively "unknown is not allowed" and the default allowed function is simply "no" it works.

Until there's a new valid command for some device, in which case you have to update your kernel?

As standard commands don't get added very often, that's not a huge problem, but.. see the attached patch.

Quoted 7 lines
Quoted 3 lines

We'd end up with a list of allowed commands for all sorts of operations that don't threaten the machine while blocking vendor specific wonders and also cases where users can do stuff like firmware erase.

Sorry, I think this model is totally bogus and I'd absolutely refuse to merge any such beast into the block layer sg code.

Well, would something like this patch be acceptable? It just makes SG_IO require write access to the device (cdrecord and cdrdao both open it this way already, so users shouldn't have a problem with it). I probably forgot some stuff, etc. I'm not terribly familiar with the code in question.

Signature · 1 line
Zinx Verituse                                    http://zinx.xmms.org/

Only in linux-2.6.8-rc2: .config

drivers/block/paride/pcd.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/block/paride/pcd.c linux-2.6.8-rc2/drivers/block/paride/pcd.c
@@ -259,7 +259,7 @@
 				unsigned cmd, unsigned long arg)
 {
 	struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data;
-	return cdrom_ioctl(&cd->info, inode, cmd, arg);
+	return cdrom_ioctl(&cd->info, inode, file, cmd, arg);
 }
 
 static int pcd_block_media_changed(struct gendisk *disk)
drivers/cdrom/cdrom.c +7 -4
diff -ru linux-2.6.8-rc2.orig/drivers/cdrom/cdrom.c linux-2.6.8-rc2/drivers/cdrom/cdrom.c
@@ -2065,15 +2065,18 @@
  * mmc_ioct().
  */
 int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip,
-		unsigned int cmd, unsigned long arg)
+		struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct cdrom_device_ops *cdo = cdi->ops;
 	int ret;
 
 	/* Try the generic SCSI command ioctl's first.. */
-	ret = scsi_cmd_ioctl(ip->i_bdev->bd_disk, cmd, (void __user *)arg);
-	if (ret != -ENOTTY)
-		return ret;
+	/* But only if the user has write access: open(,O_RDWR | O_NONBLOCK) */
+	if (file->f_mode & FMODE_WRITE) {
+		ret = scsi_cmd_ioctl(ip->i_bdev->bd_disk, cmd, (void __user *)arg);
+		if (ret != -ENOTTY)
+			return ret;
+	}
 
 	/* the first few commands do not deal with audio drive_info, but
 	   only with routines in cdrom device operations. */
drivers/cdrom/cdu31a.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/cdrom/cdu31a.c linux-2.6.8-rc2/drivers/cdrom/cdu31a.c
@@ -3179,7 +3179,7 @@
 static int scd_block_ioctl(struct inode *inode, struct file *file,
 				unsigned cmd, unsigned long arg)
 {
-	return cdrom_ioctl(&scd_info, inode, cmd, arg);
+	return cdrom_ioctl(&scd_info, inode, file, cmd, arg);
 }
 
 static int scd_block_media_changed(struct gendisk *disk)
drivers/cdrom/cm206.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/cdrom/cm206.c linux-2.6.8-rc2/drivers/cdrom/cm206.c
@@ -1363,7 +1363,7 @@
 static int cm206_block_ioctl(struct inode *inode, struct file *file,
 				unsigned cmd, unsigned long arg)
 {
-	return cdrom_ioctl(&cm206_info, inode, cmd, arg);
+	return cdrom_ioctl(&cm206_info, inode, file, cmd, arg);
 }
 
 static int cm206_block_media_changed(struct gendisk *disk)
drivers/cdrom/mcd.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/cdrom/mcd.c linux-2.6.8-rc2/drivers/cdrom/mcd.c
@@ -227,7 +227,7 @@
 static int mcd_block_ioctl(struct inode *inode, struct file *file,
 				unsigned cmd, unsigned long arg)
 {
-	return cdrom_ioctl(&mcd_info, inode, cmd, arg);
+	return cdrom_ioctl(&mcd_info, inode, file, cmd, arg);
 }
 
 static int mcd_block_media_changed(struct gendisk *disk)
drivers/cdrom/mcdx.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/cdrom/mcdx.c linux-2.6.8-rc2/drivers/cdrom/mcdx.c
@@ -233,7 +233,7 @@
 				unsigned cmd, unsigned long arg)
 {
 	struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
-	return cdrom_ioctl(&p->info, inode, cmd, arg);
+	return cdrom_ioctl(&p->info, inode, file, cmd, arg);
 }
 
 static int mcdx_block_media_changed(struct gendisk *disk)
drivers/cdrom/sbpcd.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/cdrom/sbpcd.c linux-2.6.8-rc2/drivers/cdrom/sbpcd.c
@@ -5372,7 +5372,7 @@
 				unsigned cmd, unsigned long arg)
 {
 	struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
-	return cdrom_ioctl(p->sbpcd_infop, inode, cmd, arg);
+	return cdrom_ioctl(p->sbpcd_infop, inode, file, cmd, arg);
 }
 
 static int sbpcd_block_media_changed(struct gendisk *disk)
drivers/cdrom/viocd.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/cdrom/viocd.c linux-2.6.8-rc2/drivers/cdrom/viocd.c
@@ -199,7 +199,7 @@
 		unsigned cmd, unsigned long arg)
 {
 	struct disk_info *di = inode->i_bdev->bd_disk->private_data;
-	return cdrom_ioctl(&di->viocd_info, inode, cmd, arg);
+	return cdrom_ioctl(&di->viocd_info, inode, file, cmd, arg);
 }
 
 static int viocd_blk_media_changed(struct gendisk *disk)
drivers/ide/ide-cd.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/ide/ide-cd.c linux-2.6.8-rc2/drivers/ide/ide-cd.c
@@ -3394,7 +3394,7 @@
 	int err = generic_ide_ioctl(bdev, cmd, arg);
 	if (err == -EINVAL) {
 		struct cdrom_info *info = drive->driver_data;
-		err = cdrom_ioctl(&info->devinfo, inode, cmd, arg);
+		err = cdrom_ioctl(&info->devinfo, inode, file, cmd, arg);
 	}
 	return err;
 }
drivers/scsi/sr.c +1 -1
diff -ru linux-2.6.8-rc2.orig/drivers/scsi/sr.c linux-2.6.8-rc2/drivers/scsi/sr.c
@@ -504,7 +504,7 @@
                 case SCSI_IOCTL_GET_BUS_NUMBER:
                         return scsi_ioctl(sdev, cmd, (void __user *)arg);
 	}
-	return cdrom_ioctl(&cd->cdi, inode, cmd, arg);
+	return cdrom_ioctl(&cd->cdi, inode, file, cmd, arg);
 }
 
 static int sr_block_media_changed(struct gendisk *disk)
include/linux/cdrom.h +1 -1
diff -ru linux-2.6.8-rc2.orig/include/linux/cdrom.h linux-2.6.8-rc2/include/linux/cdrom.h
@@ -985,7 +985,7 @@
 			struct file *fp);
 extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp);
 extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip,
-		unsigned int cmd, unsigned long arg);
+		struct file *file, unsigned int cmd, unsigned long arg);
 extern int cdrom_media_changed(struct cdrom_device_info *);
 
 extern int register_cdrom(struct cdrom_device_info *cdi);
#49 lore raw
In reply to Doug Maxey
Quoted 2 lines · Doug Maxey

Where would the case of firmware download fit? For x86 ATA/ATAPI devices, the vendor usually supplies a dos disk to accomplish this.

We already have CAP_SYS_RAWIO methods for such things so that is ok. As to the claim that allowed commands vary by device I disagree. At the "user safe" level the list is somewhat smaller and consistent

#39 lore raw
In reply to Zinx Verituse
Quoted 8 lines · Zinx Verituse
Quoted 7 lines
Quoted 3 lines

We'd end up with a list of allowed commands for all sorts of operations that don't threaten the machine while blocking vendor specific wonders and also cases where users can do stuff like firmware erase.

Sorry, I think this model is totally bogus and I'd absolutely refuse to merge any such beast into the block layer sg code.

Quoted 5 lines

Well, would something like this patch be acceptable? It just makes SG_IO require write access to the device (cdrecord and cdrdao both open it this way already, so users shouldn't have a problem with it). I probably forgot some stuff, etc. I'm not terribly familiar with the code in question.

Absolutely not. I've already outlined why in my previous mails I don't want to see anything like this, and this patch is even worse than filtering. Additionally, you risk breaking existing programs.

Signature · 1 line
Jens Axboe
#19 lore raw
In reply to Zinx Verituse
Quoted 36 lines · Zinx Verituse
Quoted 27 lines · Jens Axboe
Quoted 19 lines · Zinx Verituse
Quoted 9 lines · Jens Axboe
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

That's by design. Search linux-scsi or this list for why that is so.

The only thing I can find on the linux-scsi list is refering to sg devices, which are on a different device node from the non-generic device. This means you can still allow users read access to the disk without allowing them to send random commands to the disk -- this isn't currently possible with the IDE interface, since the device with generic access is the same as the one with the original read/cdrom commands access.

Quoted 6 lines

As it is, it's impossible grant users read-only access to an IDE cd-rom without allowing them to do things like replacing the firmware with a malicious/non-working one.

Generic access allowing such things is fine; but only if we can grant non-generic access without granting generic access.

Quoted 7 lines

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

If you have access to issue ioctls to the device, you have access to send it arbitrary commands - period.

Quoted 9 lines

I don't believe command filtering is neccessary, since all of the ide-cd ioctls are still there (ioctls that allow playing, reading, etc) Only the SG_IO ioctl itself would have to be checked (i.e., not each individual command available with SG_IO, just the overall ioctl itself, categorizing all of SG_IO more or less as raw IO. If this isn't doable with the current design, then the ide-cd interface should at least be very conspicuously documented as being extremely insecure as far as "read" access is concerned, as I know I wouldn't expect users to be able to overwrite my drive's firmware simply by granting the read access.

Ok, that is definitely more acceptable. But then it should be done to CDROM_SEND_PACKET as well, and we risk breaking programs doing so (ie cdrecord run by user currently).

Signature · 1 line
Jens Axboe
#40 lore raw
In reply to Jens Axboe
Quoted 3 lines · Jens Axboe

Absolutely not. I've already outlined why in my previous mails I don't want to see anything like this, and this patch is even worse than filtering. Additionally, you risk breaking existing programs.

Existing broken programs.

Once you do filtering so you don't need CAP_SYS_RAWIO to lob some commands at a device that becomes the place to enforce sensible policies because the filter knows what is "read" and what is "write" so it can do different checks for say "eject" (read) "write" (write) and "erase firmware" (raw I/O)

#41 lore raw
Quoted 5 lines · Alan Cox
Quoted 3 lines · Jens Axboe

Absolutely not. I've already outlined why in my previous mails I don't want to see anything like this, and this patch is even worse than filtering. Additionally, you risk breaking existing programs.

Quoted 7 lines

Existing broken programs.

Once you do filtering so you don't need CAP_SYS_RAWIO to lob some commands at a device that becomes the place to enforce sensible policies because the filter knows what is "read" and what is "write" so it can do different checks for say "eject" (read) "write" (write) and "erase firmware" (raw I/O)

Alan, there will be _no_ filtering.

Signature · 1 line
Jens Axboe
#44 lore raw
In reply to Jens Axboe
Quoted 31 lines · Jens Axboe
Quoted 7 lines · Alan Cox
Quoted 4 lines · Jens Axboe

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

Quoted 8 lines

I disagree providing you turn it the other way around. The majority of scsi commands have to be protected because you can destroy the drive with some of them or bypass the I/O layers. (Eg using SG_IO to do writes to raw disk to bypass auditing layers)

So you need CAP_SYS_RAWIO for most commands. You can easily build a list of sane commands for a given media type that are harmless and it fits the kernel role of a gatekeeper to do that.

So that's where we vehemently disagree - it fits the kernel role, if you allow it to control policy all of a sudden. And it's not easy, unless you do it per specific device (not just type, make and model).

Quoted 7 lines

Providing the 'allowed' function is driver level and we also honour read/write properly for that case (so it doesnt bypass block I/O restrictions and fail the least suprise test) then it seems quite doable.

For such I/O you'd then do

Quoted 8 lines
Quoted 4 lines
	if(capable(CAP_SYS_RAWIO) || driver->allowed(driver, blah, cmdblock))

If the allowed function filters positively "unknown is not allowed" and the default allowed function is simply "no" it works.

Until there's a new valid command for some device, in which case you have to update your kernel?

As opposed to now when a new command comes along and the driver doesn't generate it until you update your kernel? Reading a CD doesn't take exotic commands, and given the choice of having users able to send arbitrary commands to the device and not access it at all, I would say "not at all" would be good.

Quoted 5 lines
Quoted 5 lines

We'd end up with a list of allowed commands for all sorts of operations that don't threaten the machine while blocking vendor specific wonders and also cases where users can do stuff like firmware erase.

There was a note on another list titled "Why did this work?" (from memory) where someone accidentally run a firmware update as a normal user and it worked. While this was a benign event, it points out that there is a hole here far beyond my earlier worry that someone would update a CD-RW.

Quoted 5 lines

Sorry, I think this model is totally bogus and I'd absolutely refuse to merge any such beast into the block layer sg code.

So what is your solution? Or do you believe that allowing users to have unmonitored access to devices is acceptable?

Is this problem only in ide-cd, or does it affect other devices like ZIP, USB, etc, which do or may look like SCSI?

Signature · 3 lines
   -bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me
#43 lore raw
In reply to Alan Cox
Quoted 7 lines · Alan Cox
Quoted 3 lines · Jens Axboe

Absolutely not. I've already outlined why in my previous mails I don't want to see anything like this, and this patch is even worse than filtering. Additionally, you risk breaking existing programs.

Quoted 7 lines

Existing broken programs.

Once you do filtering so you don't need CAP_SYS_RAWIO to lob some commands at a device that becomes the place to enforce sensible policies because the filter knows what is "read" and what is "write" so it can do different checks for say "eject" (read) "write" (write) and "erase firmware" (raw I/O)

Would it be reasonable to have a general list (SCSI-II standard or so) and then a list of vendor commands in the driver? I really think that legitimate user programs will be using well-defined commands, after all that's why there is a standard. So requiring raw access for that may not be an issue.

Signature · 3 lines
   -bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me
#45 lore raw
In reply to Bill Davidsen
Quoted 38 lines · Bill Davidsen
Quoted 37 lines · Jens Axboe
Quoted 7 lines · Alan Cox
Quoted 4 lines · Jens Axboe

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

Quoted 8 lines

I disagree providing you turn it the other way around. The majority of scsi commands have to be protected because you can destroy the drive with some of them or bypass the I/O layers. (Eg using SG_IO to do writes to raw disk to bypass auditing layers)

So you need CAP_SYS_RAWIO for most commands. You can easily build a list of sane commands for a given media type that are harmless and it fits the kernel role of a gatekeeper to do that.

So that's where we vehemently disagree - it fits the kernel role, if you allow it to control policy all of a sudden. And it's not easy, unless you do it per specific device (not just type, make and model).

Quoted 11 lines

Providing the 'allowed' function is driver level and we also honour read/write properly for that case (so it doesnt bypass block I/O restrictions and fail the least suprise test) then it seems quite doable.

For such I/O you'd then do

	if(capable(CAP_SYS_RAWIO) || driver->allowed(driver, blah, cmdblock))

If the allowed function filters positively "unknown is not allowed" and the default allowed function is simply "no" it works.

Quoted 5 lines
Quoted 2 lines

Until there's a new valid command for some device, in which case you have to update your kernel?

As opposed to now when a new command comes along and the driver doesn't generate it until you update your kernel? Reading a CD doesn't take

Weak example. Lots of commands aren't issued directly by the device driver, in fact very few are. The driver does not have to be updated to handle new commands. If you add policy filtering, it does.

Quoted 3 lines

exotic commands, and given the choice of having users able to send arbitrary commands to the device and not access it at all, I would say "not at all" would be good.

Then don't make your cdrom device accesable.

Quoted 12 lines
Quoted 3 lines
Quoted 3 lines

We'd end up with a list of allowed commands for all sorts of operations that don't threaten the machine while blocking vendor specific wonders and also cases where users can do stuff like firmware erase.

There was a note on another list titled "Why did this work?" (from memory) where someone accidentally run a firmware update as a normal user and it worked. While this was a benign event, it points out that there is a hole here far beyond my earlier worry that someone would update a CD-RW.

Quoted 2 lines
Quoted 5 lines
Quoted 3 lines

Sorry, I think this model is totally bogus and I'd absolutely refuse to merge any such beast into the block layer sg code.

So what is your solution? Or do you believe that allowing users to have unmonitored access to devices is acceptable?

If differentiating use of a cdrom implies filtering commands, then that's not acceptable to me. So they either have access to the device or they don't.

Quoted 2 lines

Is this problem only in ide-cd, or does it affect other devices like ZIP, USB, etc, which do or may look like SCSI?

Affects all devices that accept SG_IO.

Signature · 1 line
Jens Axboe
#42 lore raw
In reply to Jens Axboe
Quoted 1 line · Jens Axboe

Alan, there will be _no_ filtering.

This is a community project. You are not a dictator, you are not some all powerful all seeing all knowledgable master, and I don't work for you.

I think you should adjust your attitude. Linus/Andrew based on actual code and opinions decide that question. My own feeling is that the desktop realities will dictate filtering to allow some non CAP_SYS_RAWIO use, that or we'll be adding CD and DVD burning ioctls.

I'm not BTW saying you are wrong, just objecting to your attiude. Filtering may well turn out to be a stupid idea.

Alan

#46 lore raw
In reply to Jens Axboe
Quoted 5 lines · Jens Axboe
Quoted 3 lines

exotic commands, and given the choice of having users able to send arbitrary commands to the device and not access it at all, I would say "not at all" would be good.

Then don't make your cdrom device accesable.

Lets get rid of root, I mean you don't need root, you could just turn your computer off.

What planet are you living on Jens ?

End users have lots of reasons for being able to access /dev/cdrom directly and also often for groups of users to access a disk directly (for example Oracle databases).

That means any security model that isn't based around things beyond basic device access is flawed.

Quoted 1 line

Affects all devices that accept SG_IO.

Then if you refuse to fix SG_IO perhaps all device drivers should remove support for it ?

#20 lore raw
In reply to Jens Axboe
Quoted 3 lines · Jens Axboe

Ok, that is definitely more acceptable. But then it should be done to CDROM_SEND_PACKET as well, and we risk breaking programs doing so (ie cdrecord run by user currently).

Definitely. Irrespective of any questions like filtering commands having /dev device access allow you to compromise the entire system is not a good model. CAP_SYS_RAWIO is the capability for "can do anything" so seems appropriate here.

#47 lore raw
In reply to Alan Cox
Quoted 11 lines · Alan Cox
Quoted 5 lines · Jens Axboe
Quoted 3 lines

exotic commands, and given the choice of having users able to send arbitrary commands to the device and not access it at all, I would say "not at all" would be good.

Then don't make your cdrom device accesable.

Lets get rid of root, I mean you don't need root, you could just turn your computer off.

What planet are you living on Jens ?

I'm living on the planet where filtering is not possible, unless you want to have oodles of unmaintanable tables for different devices. And that means that if you don't trust a user with your cdrom currently, don't give him/her access to it.

Quoted 3 lines

End users have lots of reasons for being able to access /dev/cdrom directly and also often for groups of users to access a disk directly (for example Oracle databases).

Yes I know.

Quoted 2 lines

That means any security model that isn't based around things beyond basic device access is flawed.

Then we should require raw io capability, as I've stated I'm fine with that. I'm not fine with filtering.

Quoted 4 lines
Quoted 1 line

Affects all devices that accept SG_IO.

Then if you refuse to fix SG_IO perhaps all device drivers should remove support for it ?

Well they can't, it's a block layer property. The only thing the device sees is a regular struct request.

Signature · 1 line
Jens Axboe
#21 lore raw
In reply to Alan Cox
Quoted 9 lines · Alan Cox
Quoted 3 lines · Jens Axboe

Ok, that is definitely more acceptable. But then it should be done to CDROM_SEND_PACKET as well, and we risk breaking programs doing so (ie cdrecord run by user currently).

Definitely. Irrespective of any questions like filtering commands having /dev device access allow you to compromise the entire system is not a good model. CAP_SYS_RAWIO is the capability for "can do anything" so seems appropriate here.

We risk breaking lots of programs, but it might be the best option yes.

Signature · 1 line
Jens Axboe
#23 lore raw
In reply to a message not in the archive
Quoted 5 lines · Jens Axboe

Perhaps if you acknowledge that it wont be perfect, then it's becomes more acceptable imo. So you can issue some commands that do write to the drive even as a regular user, but none that permanently alter the state of the drive or its media (to the best of our knowledge). Other commands you let through.

The code you included is roughly the kind of filtering I mean except that unknown commands must not get through without CAP_SYS_RAWIO. Anything that is doubtful doesn't get through. As to the location you do it there are at least two ways to handle that. One is that you stick the CAP_SYS_RAWIO of the requester in a flag in the request block the other is that you do it at the top layer. Some BSD socket implementations take the former approach and it works very well as the driver can make a final decision but is told the rights attached to the command.

So once its

	switch()
	{
		case READ6:
		case READ10:
				...
			/* Always */
			break;
		case WRITE6:
		case WRITE10:
			...
			/* if write */
		default:
			if(capable(CAP_SYS_RAWIO))
			/* Only administrators get to do arbitary things */

I agree with it.

Alan

#24 lore raw
Quoted 33 lines · Alan Cox
Quoted 5 lines · Jens Axboe

Perhaps if you acknowledge that it wont be perfect, then it's becomes more acceptable imo. So you can issue some commands that do write to the drive even as a regular user, but none that permanently alter the state of the drive or its media (to the best of our knowledge). Other commands you let through.

The code you included is roughly the kind of filtering I mean except that unknown commands must not get through without CAP_SYS_RAWIO. Anything that is doubtful doesn't get through. As to the location you do it there are at least two ways to handle that. One is that you stick the CAP_SYS_RAWIO of the requester in a flag in the request block the other is that you do it at the top layer. Some BSD socket implementations take the former approach and it works very well as the driver can make a final decision but is told the rights attached to the command.

So once its

	switch()
	{
		case READ6:
		case READ10:
				...
			/* Always */
			break;
		case WRITE6:
		case WRITE10:
			...
			/* if write */
		default:
			if(capable(CAP_SYS_RAWIO))
			/* Only administrators get to do arbitary things */
Quoted 1 line

I agree with it.

That's the case I don't agree with, and why I didn't like the idea originally. That suddenly requires a patching of the kernel because of new commands in new devices. Like when dvd readers became common, you can't just require people to update their kernel because a few new commands are needed to drive them from user space.

Signature · 1 line
Jens Axboe
#25 lore raw
Quoted 10 lines · Jens Axboe
Quoted 3 lines · Alan Cox
		default:
			if(capable(CAP_SYS_RAWIO))
			/* Only administrators get to do arbitary things */

That's the case I don't agree with, and why I didn't like the idea originally. That suddenly requires a patching of the kernel because of new commands in new devices. Like when dvd readers became common, you can't just require people to update their kernel because a few new commands are needed to drive them from user space.

The problem is that what if one of the new commands is IGNITE_PLATTER? Unknown commands can do anything, are therefore extremely dangerous, and should be restricted.

Charles

Signature · 4 lines
-----------------------------------------------------------------------
Charles Cazabon                            <[email protected]>
GPL'ed software available at:     http://www.qcc.ca/~charlesc/software/
-----------------------------------------------------------------------
#26 lore raw
Quoted 12 lines · Charles Cazabon
Quoted 10 lines · Jens Axboe
Quoted 3 lines · Alan Cox
		default:
			if(capable(CAP_SYS_RAWIO))
			/* Only administrators get to do arbitary things */

That's the case I don't agree with, and why I didn't like the idea originally. That suddenly requires a patching of the kernel because of new commands in new devices. Like when dvd readers became common, you can't just require people to update their kernel because a few new commands are needed to drive them from user space.

Quoted 3 lines

The problem is that what if one of the new commands is IGNITE_PLATTER? Unknown commands can do anything, are therefore extremely dangerous, and should be restricted.

Well yes, that's exactly why there is a discussion. As I have written before, filtering cannot be perfect exactly because of this. Either you leave unknown commands unfiltered (and risk a problem with new commands until you update your kernels), or you add the _policy_ to filter unknown commands and risk not working with new devices for no good reason.

And if you really want to try and cover everything, you want to add filtering tables per _device_. Which is basically impossible to do, and is completely unmaintainable.

But I've already stated that before.

Signature · 1 line
Jens Axboe
#28 lore raw
In reply to Jens Axboe
Quoted 34 lines · Jens Axboe
Quoted 33 lines · Alan Cox
Quoted 5 lines · Jens Axboe

Perhaps if you acknowledge that it wont be perfect, then it's becomes more acceptable imo. So you can issue some commands that do write to the drive even as a regular user, but none that permanently alter the state of the drive or its media (to the best of our knowledge). Other commands you let through.

The code you included is roughly the kind of filtering I mean except that unknown commands must not get through without CAP_SYS_RAWIO. Anything that is doubtful doesn't get through. As to the location you do it there are at least two ways to handle that. One is that you stick the CAP_SYS_RAWIO of the requester in a flag in the request block the other is that you do it at the top layer. Some BSD socket implementations take the former approach and it works very well as the driver can make a final decision but is told the rights attached to the command.

So once its

	switch()
	{
		case READ6:
		case READ10:
				...
			/* Always */
			break;
		case WRITE6:
		case WRITE10:
			...
			/* if write */
		default:
			if(capable(CAP_SYS_RAWIO))
			/* Only administrators get to do arbitary things */
Quoted 7 lines
Quoted 1 line

I agree with it.

That's the case I don't agree with, and why I didn't like the idea originally. That suddenly requires a patching of the kernel because of new commands in new devices. Like when dvd readers became common, you can't just require people to update their kernel because a few new commands are needed to drive them from user space.

This is no different from having to build a new kernel whenever you happen to install a new revision of a videocard, nic, scsi controller, or random other device new enough that its pci_id isn't in pci_ids.h. New features and new devices frequently require new kernels.

Allowing specific commands while disallowing unknown commands to standard users is a far better scenario than any other proposals I've heard so far.

--
Douglas Leonard
[email protected]

#29 lore raw
Quoted 44 lines · On Fri, Aug 06 2004, [email protected] wrote:
Quoted 34 lines · Jens Axboe
Quoted 33 lines · Alan Cox
Quoted 5 lines · Jens Axboe

Perhaps if you acknowledge that it wont be perfect, then it's becomes more acceptable imo. So you can issue some commands that do write to the drive even as a regular user, but none that permanently alter the state of the drive or its media (to the best of our knowledge). Other commands you let through.

The code you included is roughly the kind of filtering I mean except that unknown commands must not get through without CAP_SYS_RAWIO. Anything that is doubtful doesn't get through. As to the location you do it there are at least two ways to handle that. One is that you stick the CAP_SYS_RAWIO of the requester in a flag in the request block the other is that you do it at the top layer. Some BSD socket implementations take the former approach and it works very well as the driver can make a final decision but is told the rights attached to the command.

So once its

	switch()
	{
		case READ6:
		case READ10:
				...
			/* Always */
			break;
		case WRITE6:
		case WRITE10:
			...
			/* if write */
		default:
			if(capable(CAP_SYS_RAWIO))
			/* Only administrators get to do arbitary things */
Quoted 7 lines
Quoted 1 line

I agree with it.

That's the case I don't agree with, and why I didn't like the idea originally. That suddenly requires a patching of the kernel because of new commands in new devices. Like when dvd readers became common, you can't just require people to update their kernel because a few new commands are needed to drive them from user space.

Quoted 4 lines

This is no different from having to build a new kernel whenever you happen to install a new revision of a videocard, nic, scsi controller, or random other device new enough that its pci_id isn't in pci_ids.h. New features and new devices frequently require new kernels.

It's completely different, that you say so shows you don't understand the issue at all. New devices work just fine even if the kernel doesn't understand the pci id, as long as you can drive it from user space. If you want a direct comparison, it would be comparable to disallow anyone to use a pci id you did not know about at kernel compile time. So if you get a new video card later on, it would not work properly until you got a new kernel with that id included.

But thanks for high lighting why filtering is bad for new devices.

Signature · 1 line
Jens Axboe
#32 lore raw
In reply to Jens Axboe
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"JA" == Jens Axboe <[email protected]> writes:

JA> Like when dvd readers became common, you can't just require people JA> to update their kernel because a few new commands are needed to JA> drive them from user space.

Perhaps I'm being completely dense, but why would the filtering tables have to be compiled into the kernel? Why not load them from user space via a mechanism requiring CAP_SYS_RAWIO?

How many commands are we talking about here? Is the mechanism workable by a simple bitmask, or is something more complex like a state machine required?

- J<

#27 lore raw
In reply to Charles Cazabon
Quoted 9 lines · Charles Cazabon
Quoted 5 lines

That's the case I don't agree with, and why I didn't like the idea originally. That suddenly requires a patching of the kernel because of new commands in new devices. Like when dvd readers became common, you can't just require people to update their kernel because a few new commands are needed to drive them from user space.

The problem is that what if one of the new commands is IGNITE_PLATTER? Unknown commands can do anything, are therefore extremely dangerous, and should be restricted.

The comands in question already include such gems as "format", "erase firmware" and the like. So if you've got read access to a 2.6 raw block device you can reformat your oracle database.

Alan

#30 lore raw
In reply to Jens Axboe
Quoted 1 line · Jens Axboe

But thanks for high lighting why filtering is bad for new devices.

Filtering is essential. If you have CAP_SYS_RAWIO set then anything goes. Root is entitled to reflash his hard disk to report all files having setuid bits, or to total the media or to password lock it.

End users are not and the only sane kernel behaviour for the "unsure" case is "-EPERM". If its not the right behaviour we have setuid bits. If it was the other way around your end user just password locked all your disks with a password you'll never recover.

Alan

#34 lore raw
In reply to Jens Axboe
Quoted 5 lines · Jens Axboe

That's the case I don't agree with, and why I didn't like the idea originally. That suddenly requires a patching of the kernel because of new commands in new devices. Like when dvd readers became common, you can't just require people to update their kernel because a few new commands are needed to drive them from user space.

I'm stunning we are even having this argument. You are talking about what appes to be a hardware destruction enabling security level bug in the 2.6 kernel and arguing about whether it is a feature or not.

In essence you are saying read access to any raw device node entitles the opener of the file to destroy the attached device (device even not just media). You are arguing that its ok that I can use raw scsi I/O to subvert the read/write permissions too.

In the example code I gave

Quoted 3 lines
              default:
                      if(capable(CAP_SYS_RAWIO))
                      /* Only administrators get to do arbitary things

*/

Quoted 1 line

means there is no need to recompile anything, you just need priviledges to do stuff the kernel doesn't *know* is safe. This is the correct behaviour for people who don't live in cloud cuckoo land.

Alan

#31 lore raw
In reply to Alan Cox

Actually there is a seperate complication here for disks that probably makes the problem a bit more complex for anything with partitions - that is that SCSI commands are not per partition and I agree with you that we don't want to get into filtering on that basis. Probably that means CAP_SYS_RAWIO for anything not the true "whole device" node.

That leaves commands to one device that affect another "disk" - eg a firmware upgrade on a big storage array but those are RAWIO things anyway

#33 lore raw
In reply to Jason L Tibbitts III
Quoted 6 lines · Jason L Tibbitts III
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"JA" == Jens Axboe <[email protected]> writes:

JA> Like when dvd readers became common, you can't just require people JA> to update their kernel because a few new commands are needed to JA> drive them from user space.

Quoted 7 lines

Perhaps I'm being completely dense, but why would the filtering tables have to be compiled into the kernel? Why not load them from user space via a mechanism requiring CAP_SYS_RAWIO?

How many commands are we talking about here? Is the mechanism workable by a simple bitmask, or is something more complex like a state machine required?

Could be done, it's quite some work though. The complexity isn't as much due to new commands being added (that doesn't happen very often), that's only problematic from the policy pov. The problem is defining the tables, it's definitely not trivial. And I still claim not very doable.

Signature · 1 line
Jens Axboe
#35 lore raw
In reply to Alan Cox
Quoted 10 lines · Alan Cox
Quoted 5 lines · Jens Axboe

That's the case I don't agree with, and why I didn't like the idea originally. That suddenly requires a patching of the kernel because of new commands in new devices. Like when dvd readers became common, you can't just require people to update their kernel because a few new commands are needed to drive them from user space.

I'm stunning we are even having this argument. You are talking about what appes to be a hardware destruction enabling security level bug in the 2.6 kernel and arguing about whether it is a feature or not.

Alan, stop putting words into my mouth. I'm not saying it's a feature.

Quoted 4 lines

In essence you are saying read access to any raw device node entitles the opener of the file to destroy the attached device (device even not just media). You are arguing that its ok that I can use raw scsi I/O to subvert the read/write permissions too.

In essence, yes. I'm arguing that it's not easily doable to differentiate between destructive and non-destructive commands. And that doing so requires extensive tables because commands are not the same across devices.

I'm not saying that I think it's a good thing! Or a feature, for that matter. I'm just arguing the feasibility of doing it, the maintenance involved, etc.

Quoted 11 lines

In the example code I gave

Quoted 3 lines
              default:
                      if(capable(CAP_SYS_RAWIO))
                      /* Only administrators get to do arbitary things

*/

Quoted 1 line

means there is no need to recompile anything, you just need priviledges to do stuff the kernel doesn't *know* is safe. This is the correct behaviour for people who don't live in cloud cuckoo land.

I'm well aware of the implications. The argument is only whether it's ok to policy filter unknown commands. I guess with capability elevating the app until the kernels are modified it would be ok, at least it enables the apps to work for root.

Signature · 1 line
Jens Axboe
#50 lore raw
In reply to Jens Axboe
Quoted 31 lines · Jens Axboe
Quoted 21 lines · Zinx Verituse
Quoted 10 lines · Jens Axboe
Quoted 6 lines · Zinx Verituse

I'm going to bump this topic a bit, since it's been a while.. There are still some issues with ide-cd's SG_IO, listed from most important as percieved by me to least:

* Read-only access grants you the ability to write/blank media in the drive
* (with above) You can open the device only in read-only mode.

That's by design. Search linux-scsi or this list for why that is so.

The only thing I can find on the linux-scsi list is refering to sg devices, which are on a different device node from the non-generic device. This means you can still allow users read access to the disk without allowing them to send random commands to the disk -- this isn't currently possible with the IDE interface, since the device with generic access is the same as the one with the original read/cdrom commands access.

Quoted 6 lines

As it is, it's impossible grant users read-only access to an IDE cd-rom without allowing them to do things like replacing the firmware with a malicious/non-working one.

Generic access allowing such things is fine; but only if we can grant non-generic access without granting generic access.

Quoted 8 lines

If you want it to work that way, you have the have a pass-through filter in the kernel knowing what commands are out there (including vendor specific ones). That's just too ugly and not really doable or maintainable, sorry.

If you have access to issue ioctls to the device, you have access to send it arbitrary commands - period.

Let me try this again... To do the normal "reasonable" things associated with raw read, the standard SCSI command set includes commands in the read and seek sets which seem to be what is needed. These are standard, and I fail to see how allowing them, and only them, could be so complicated in the case where only read access is allowed. There is no need to allow vendor commands or any kind to permit programs such as checks and backups of various kinds to be used.

I think the same is true of write, filtering out anything but the set of write commands in the common SCSI command set is fine, and in the rare case where it isn't, I'm happy to say that raw write capability is the answer.

read does not imply write
write does not imply anything but data

firmware reload, low level format, spin in the other direction, all would require capability.

If you disagree with the above in some technical way, please clarify. If you just are opposing filtration on general principles because you run everything as root or don't believe in levels of security, I sure can't change your mind if you're willing to disagree with Alan.

Signature · 3 lines
   -bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me