Re: [PATCH 1/1] Char: moxa, prevent opening unavailable ports

From: Jiri Slaby
Date: Tue Jun 09 2009 - 15:36:23 EST


On 06/09/2009 09:27 PM, Andrew Morton wrote:
> btw, what's this code in moxa_open() doing?
>
> if (port == MAX_PORTS) {
> return capable(CAP_SYS_ADMIN) ? 0 : -EPERM;
> }
>
> why does it return 0 if CAP_SYS_ADMIN?

There is some global stats ioctl crap on that port number available only
to users with permissions. Look at moxa_ioctl, there is:

if (tty->index == MAX_PORTS) {
if (cmd != MOXA_GETDATACOUNT && cmd != MOXA_GET_IOQUEUE &&
cmd != MOXA_GETMSTATUS)
return -EINVAL;

Of course, there is also alloc_tty_driver(MAX_PORTS + 1).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/