Subject: scsipi/physio trouble
To: None <tech-kern@netbsd.org>
From: Reinoud Zandijk <reinoud@netbsd.org>
List: tech-kern
Date: 01/24/2005 03:37:51
--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hiya folks,
i'm having trouble calling an VOP_IOCTL() call. It tries to call the
SCIOCCOMMAND ioctl, but as the data to be transferd is allways just assumed
to be from userspace (dev/scsipi/scsipi_ioctl.c:351) it fails :
...
si->si_uio.uio_resid = len;
si->si_uio.uio_offset = 0;
si->si_uio.uio_segflg = UIO_USERSPACE;
si->si_uio.uio_rw =
(screq->flags & SCCMD_READ) ? UIO_READ : UIO_WRITE;
si->si_uio.uio_procp = p;
error = physio(scsistrategy, &si->si_bp, dev,
(screq->flags & SCCMD_READ) ? B_READ : B_WRITE,
periph->periph_channel->chan_adapter->adapt_minphys,
&si->si_uio);
...
wouldn't it be better to set the uio_segflg depending on whether `struct
proc *p' is non zero like all others do?
If this is fixed, there is another problem arising; phyio(9) tells me:
...
uio The description of the entire transfer as requested by the user
process. Currently, the results of passing a uio structure with
the `uio_segflg' set to anything other than UIO_USERSPACE, are
undefined.
...
and the source around sys/kern/kern_physio.c:171 tells me :
.....
/*
* [mark the buffer busy for physical I/O]
* (i.e. set B_PHYS (because it's an I/O to user
* memory, and B_RAW, because B_RAW is to be
* "Set by physio for raw transfers.", in addition
* to the "busy" and read/write flag.)
*/
bp->b_flags = B_BUSY | B_PHYS | B_RAW | flags;
.....
It seems to be that this also needs to be conditional on the uio_segflg
flag.
What do you guys think? should either scsipi be fixed to not use physio? or
should physio be fixed to allow transfers to kernel memeory too?
Feedback would be much apreciated for this means that a lot of IOCTL's like
SCIOCCOMMAND (scsi command) can't be be executed from kernel-space.
Cheers,
Reinoud
--EeQfGwPcQSOJBaQU
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)
iQEVAwUBQfRfdoKcNwBDyKpoAQIAKQf/fZSEbXMmyAnW69qQK/Q8Y36D91QFVTAi
swl/x2l1o+Kb/2lkwcKOjVi/uYCTlN6dbwgac7dU6CCziuzsr9jpWEKDyofK19tS
RlqeJXR24qbdcWiaMWL2EcJ7Ct+JuknLSVf8MD1uLlcNbZbnMo/aXHJRWl07+pEz
dGm6zEcr/9ufb9MFi0LYap0hGNYrDdkbFHpcDryVtIqB2/tNEio4e7/4T5M6ZK6Y
pmqQbhILiY2+KctOS3mkTEIlrUYZHfgSMEoJnJozIvDC0epprGw5ZlJKxJphwLVL
DJKf9swcNzuG2chxs/S8szbKQsFOV8ZPPcy9U6U4Fnb+r9sMykd5JA==
=QKrY
-----END PGP SIGNATURE-----
--EeQfGwPcQSOJBaQU--