Skip to contentSkip to conversation

f_ops flag to speed up compatible ioctls in linux kernel

DISCUSSION Albert Cahalan 3 participants 5 messages Sep 1, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines · Arjan van de Ven
Quoted 5 lines · On Wed, Sep 01, 2004 at 03:50:11AM -0600, [email protected] wrote:

Stop being arrogant. Can you please elaborate on how to make Linux kernel support e.g. motion controllers? They do not fit *any* known to me driver interface. They have several axes, they have about twenty parameters (float or integer), and

parameters nicely fit in sysfs.

Per-command parameters included?

People really do want private syscalls. An ioctl is that, in a namespace defined by the file descriptor. So ioctl() provides local scope to something that would otherwise be global.

The alternative is to add a zillion odd syscalls.

Life is messy.

Quoted 6 lines
Quoted 5 lines

they have several commands, a-la start, graceful stop, abrupt stop. Plus obviously diagnostics - about ten another commands with absolutely different parameters. And about ten motion monitoring commands. And this is one example I were need to program.

Quoted 6 lines

a write() interface doesn't work???
Hard to believe, you even call them commands.
fd = open("/dev/funkydevice");
write(fd, "start");

doesn't sound insane to me

That's just a double-crufty ioctl in disguise. See also: "the /proc filesystem"

It looks like encouragement of choices that will tend toward the creation of buffer overflows in the kernel. Nearly all buffer overflows involve parsing ASCII. Sure, nobody should make mistakes...

People won't do that though. Know what you'll get if ioctl isn't used? Here you go:

/////////////////////// Look ma, no ioctl! ///// struct ctldata scd;
struct ctldata *scdp = &scd;

scd.command = GET_MOTOR_TEMPERATURE; scd.arg[0] = MOTOR_Z;

// Arjan wants it this way.
// (for Viro, must print the pointer in decimal) write(fd, &scdp, sizeof ctldata);

motor_temp.current = scd.ret[0];
motor_temp.peak = scd.ret[1];
/////////////////////////////////////////////////

#1 lore raw

Albert> Per-command parameters included?

Albert> People really do want private syscalls. An ioctl is that, Albert> in a namespace defined by the file descriptor. So ioctl() Albert> provides local scope to something that would otherwise be Albert> global.

Yes, this is exactly right. One issue raised by this thread is that the ioctl32 compatibility code only allows one compatibility handler per ioctl number. It seems that this creates all sorts of possibilities for mayhem because it makes the ioctl namespace global in scope in some situations. Does anyone have any thoughts on if/how this should be addressed.

- Roland

#2 lore raw

Hello!
Quoting r. Roland Dreier ([email protected]) "Re: f_ops flag to speed up compatible ioctls in linux kernel":

Quoted 7 lines

Albert> Per-command parameters included?

Albert> People really do want private syscalls. An ioctl is that, Albert> in a namespace defined by the file descriptor. So ioctl() Albert> provides local scope to something that would otherwise be Albert> global.

Quoted 7 lines

Yes, this is exactly right. One issue raised by this thread is that the ioctl32 compatibility code only allows one compatibility handler per ioctl number. It seems that this creates all sorts of possibilities for mayhem because it makes the ioctl namespace global in scope in some situations. Does anyone have any thoughts on if/how this should be addressed.

Thats what my original patch attempts to address
http://www.uwsg.indiana.edu/hypermail/linux/kernel/0409.0/0025.html
What do you think?

#3 lore raw

Roland> Yes, this is exactly right. One issue raised by this Roland> thread is that the ioctl32 compatibility code only allows Roland> one compatibility handler per ioctl number. It seems that Roland> this creates all sorts of possibilities for mayhem because Roland> it makes the ioctl namespace global in scope in some Roland> situations. Does anyone have any thoughts on if/how this Roland> should be addressed?

Michael> Thats what my original patch attempts to address Michael> http://www.uwsg.indiana.edu/hypermail/linux/kernel/0409.0/0025.html
Michael> What do you think?

That patch seems somewhat orthogonal to the issue I raised. You're just fixing the problem for devices that don't use the ioctl32 compat layer.

- Roland

#4 lore raw

Quoting r. Roland Dreier ([email protected]) "Re: f_ops flag to speed up compatible ioctls in linux kernel":

Quoted 8 lines

Roland> Yes, this is exactly right. One issue raised by this Roland> thread is that the ioctl32 compatibility code only allows Roland> one compatibility handler per ioctl number. It seems that Roland> this creates all sorts of possibilities for mayhem because Roland> it makes the ioctl namespace global in scope in some Roland> situations. Does anyone have any thoughts on if/how this Roland> should be addressed?

Quoted 8 lines

Michael> Thats what my original patch attempts to address Michael> http://www.uwsg.indiana.edu/hypermail/linux/kernel/0409.0/0025.html
Michael> What do you think?

That patch seems somewhat orthogonal to the issue I raised. You're just fixing the problem for devices that don't use the ioctl32 compat layer.

No I'm removing the need for ioctls to go through the compat layer. No compat layer, no problem.

I see the compat layer as a hack to support legacy devices without touching all of their code.
I dont see why a new driver would use the compat hacks instead of simply building a 32/64 bit compatible interface, and legacy drivers have the uniqueness for commands solved one way or another.

So the only interesting problem left is for new char devices.

MST