2.6.8 and CD recording
[Posted August 18, 2004 by corbet]
By far the loudest chorus of complaints about the 2.6.8.1 kernel comes from
users who have found that they can no longer burn CDs. In most cases, the
problem can be worked around by running the recording program from a root
shell (setuid is not sufficient), but
that is an unsatisfying alternative for many. Why, ask inquiring minds,
did CD recording have to break with the new kernel?
It's all a matter of trying to get the permissions right. Burning a CD
requires sending a number of special-purpose SCSI commands to the drive, so
the operation is performed outside of the regular I/O paths. But once you
can send arbitrary commands, you can do more than write CDs. In pushing
for changes, Alan Cox put it this way:
With the current code I can destroy all your hard disks given read
access to the drive. With checks on writable I can destroy all your
hard disks/cdroms as appropriate with write access. Destroy here
means "dead, defunct, pushing up the daisies, go order a new one
kind of dead".
Seeing this outcome as undesirable, Linus threw in a patch shortly before releasing 2.6.8. This
patch creates an array of known SCSI commands, associating each with "safe
for read" and "safe for write" flags. Those flags are tested when a
process attempts to execute the given command. If the device has been
opened for read access, the set of allowed commands is relatively small:
read, request sense, play CD, etc. A process with write access can execute
more commands, but not the whole set. Any command not explicitly flagged
as safe for the given open mode is restricted to processes with the
CAP_SYS_RAWIO capability - root, for all practical purposes.
This patch broke CD burning in multiple ways. Users of growisofs were
burned (so to speak) because that utility opens the device for read access.
That should never have worked, but did until now; fixing that problem will
require a patch to the application. Beyond that, however, is the simple
fact that numerous SCSI commands needed for CD burning were omitted from
the "safe for write" list. These vary from locking the door to "send OPC,"
"blank", and many others. Enabling CD writing from an unprivileged process
with write access to the drive will require adding several commands to the
list.
Unfortunately, expanding the list in that manner can bring back the
original problem. Many commands which are safe to execute in one context
can destroy data, firmware, or hardware in other contexts. And it can be
very hard for the kernel to tell the difference between the two. There has
been talk of expanding the checking framework to better understand the
target device's operating modes and, perhaps, giving high- or low-level
drivers a say in the decision. Down that road lies complexity, however,
and it would be hard to reach a point where the developers could declare
victory and call the problem solved. It may well be that, despite other
faults in his reasoning on CD recording, Jörg Schilling got
it right when he suggested that the most secure mode of operation is to
simply restrict device access and run the CD recording application in a
setuid mode.
(
Log in to post comments)