Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: Remove restrictions on signal numbers in devio.c

Just over a year ago (!) I had this brief exchange with Alan Stern:

>> It seems that the signal that can be used with USBDEVFS_DISCSIGNAL and
>> in usbdevfs_urb.signr is limited to the real-time signals SIGRTMIN to
>> SIGRTMAX. What's the rationale for this restriction? I believe that a
>> process can kill() itself with any signal number, can't it? I was
>> planning to use SIGIO for usbdevfs_urb.signr and SIGTERM (uncaught) for
>> USBDEVFS_DISCSIGNAL. I don't think I'll have a problem with using
>> SIGRTMIN+n instead, but I'm curious to know if there's some subtle
>> problem with the non-real-time signals that I should be aware of.
>
> I don't know of any reason for this restriction.

Since no-one else could think of a reason either, I offer the following
patch which allows any signal to be used with USBDEVFS_DISCSIGNAL and
usbdevfs_urb.signr.

Signed-off-by: Phil Endecott <usbpatch@chezphil.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Phil Endecott and committed by
Greg Kroah-Hartman
ff8973d9 d767d888

-5
-5
drivers/usb/core/devio.c
··· 981 981 return -EINVAL; 982 982 if (!uurb->buffer) 983 983 return -EINVAL; 984 - if (uurb->signr != 0 && (uurb->signr < SIGRTMIN || 985 - uurb->signr > SIGRTMAX)) 986 - return -EINVAL; 987 984 if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && 988 985 (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { 989 986 ifnum = findintfep(ps->dev, uurb->endpoint); ··· 1398 1401 1399 1402 if (copy_from_user(&ds, arg, sizeof(ds))) 1400 1403 return -EFAULT; 1401 - if (ds.signr != 0 && (ds.signr < SIGRTMIN || ds.signr > SIGRTMAX)) 1402 - return -EINVAL; 1403 1404 ps->discsignr = ds.signr; 1404 1405 ps->disccontext = ds.context; 1405 1406 return 0;