diff options
author | Trent Piepho <xyzzy@speakeasy.org> | 2007-01-30 21:25:41 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 10:35:10 -0500 |
commit | 62d50addf0774115adaa9e01e09099c3d7daa13d (patch) | |
tree | 5490c0acef3aa645c6974437b3ca7a508ed755a3 /drivers/media/video/usbvision/usbvision-video.c | |
parent | e7b58f5259a81dbd9fbfea79408d272f44eb894f (diff) |
V4L/DVB (5163): Add checks for CAP_SYS_ADMIN to VIDIOC_DBG_G_REGISTER
Before, root privileges were only needed to set hardware registers, not
to read them. On some hardware, reading from the wrong place at the
wrong time can hang the machine. So, to be consistent, root privileges
are required to read registers on all hardware.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index b6fabeeb8ab8..6a61ebcdf130 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -520,25 +520,6 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
520 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 520 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
521 | /* ioctls to allow direct acces to the NT100x registers */ | 521 | /* ioctls to allow direct acces to the NT100x registers */ |
522 | case VIDIOC_DBG_G_REGISTER: | 522 | case VIDIOC_DBG_G_REGISTER: |
523 | { | ||
524 | struct v4l2_register *reg = arg; | ||
525 | int errCode; | ||
526 | |||
527 | if (reg->i2c_id != 0) | ||
528 | return -EINVAL; | ||
529 | /* NT100x has a 8-bit register space */ | ||
530 | errCode = usbvision_read_reg(usbvision, reg->reg&0xff); | ||
531 | if (errCode < 0) { | ||
532 | err("%s: VIDIOC_DBG_G_REGISTER failed: error %d", __FUNCTION__, errCode); | ||
533 | } | ||
534 | else { | ||
535 | reg->val=(unsigned char)errCode; | ||
536 | PDEBUG(DBG_IOCTL, "VIDIOC_DBG_G_REGISTER reg=0x%02X, value=0x%02X", | ||
537 | (unsigned int)reg->reg, reg->val); | ||
538 | errCode = 0; // No error | ||
539 | } | ||
540 | return errCode; | ||
541 | } | ||
542 | case VIDIOC_DBG_S_REGISTER: | 523 | case VIDIOC_DBG_S_REGISTER: |
543 | { | 524 | { |
544 | struct v4l2_register *reg = arg; | 525 | struct v4l2_register *reg = arg; |
@@ -548,15 +529,22 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
548 | return -EINVAL; | 529 | return -EINVAL; |
549 | if (!capable(CAP_SYS_ADMIN)) | 530 | if (!capable(CAP_SYS_ADMIN)) |
550 | return -EPERM; | 531 | return -EPERM; |
551 | errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); | 532 | /* NT100x has a 8-bit register space */ |
533 | if (cmd == VIDIOC_DBG_G_REGISTER) | ||
534 | errCode = usbvision_read_reg(usbvision, reg->reg&0xff); | ||
535 | else | ||
536 | errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); | ||
552 | if (errCode < 0) { | 537 | if (errCode < 0) { |
553 | err("%s: VIDIOC_DBG_S_REGISTER failed: error %d", __FUNCTION__, errCode); | 538 | err("%s: VIDIOC_DBG_%c_REGISTER failed: error %d", __FUNCTION__, |
554 | } | 539 | cmd == VIDIOC_DBG_G_REGISTER ? 'G' : 'S', errCode); |
555 | else { | 540 | return errCode; |
556 | PDEBUG(DBG_IOCTL, "VIDIOC_DBG_S_REGISTER reg=0x%02X, value=0x%02X", | ||
557 | (unsigned int)reg->reg, reg->val); | ||
558 | errCode = 0; | ||
559 | } | 541 | } |
542 | if (cmd == VIDIOC_DBG_S_REGISTER) | ||
543 | reg->val = (u8)errCode; | ||
544 | |||
545 | PDEBUG(DBG_IOCTL, "VIDIOC_DBG_%c_REGISTER reg=0x%02X, value=0x%02X", | ||
546 | cmd == VIDIOC_DBG_G_REGISTER ? 'G' : 'S', | ||
547 | (unsigned int)reg->reg, reg->val); | ||
560 | return 0; | 548 | return 0; |
561 | } | 549 | } |
562 | #endif | 550 | #endif |