Bug 150315 - [ata] sizeof(union ccb) changed between 7.x and 8.x
Summary: [ata] sizeof(union ccb) changed between 7.x and 8.x
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 8.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-06 05:20 UTC by Garrett Wollman
Modified: 2016-08-22 16:45 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Garrett Wollman freebsd_committer freebsd_triage 2010-09-06 05:20:04 UTC
sizeof(union ccb) changed when ATA support was added to the CAM
framework in the 8.x branch.  However, the CAMIOCOMMAND ioctl request,
used by many userland utilities that send direct SCSI commands, takes
a "union ccb" as its argument; this encodes sizeof(union ccb) into the
ioctl number and breaks binary compatibility between 7.x and 8.x for
these tools, even when COMPAT_FREEBSD7 is defined in the kernel
configuration.

This may be the same problem was originally reported in misc/138622,
which does not appear to have garnered any responses.

Fix: 

It's not clear to me whether there's a good fix here.  The best fix
would be to define a (private) "union occb" and OCAMIOCOMMAND ioctl
which is compatible with 7.x, but I'm not sure if that's actually safe
to do when there are ATA devices actually in use.  Possibly just
recognizing the generic form of CAMIOCOMMAND and logging a
"CAMIOCOMMAND used with wrong size CCB" to the console would be a
stopgap if it's not practical to implement full compatability.
How-To-Repeat: 
Try to run any 7.x program which uses CAMIOCOMMAND to send SCSI
commands directly to devices (e.g., smartctl) and watch it fail
mysteriously when ioctl returns [ENOTTY].
Comment 1 Alexander Motin freebsd_committer freebsd_triage 2011-07-18 11:43:08 UTC
The main problem is not just in union ccb size change. Problem is that
elements newly added to several structures were added not to the ends,
and in some places there are arrays of structures used. As result
providing compatibility layer would required to repack all requests and
responses, reordering their fields.

I am not sure that supporting it now (1.5 years after 8.0 release) worth
polluting code. Speaking about smartctl -- the best way is to rebuild
it, as new version also supports CAM ATA.

-- 
Alexander Motin