diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-03-27 07:04:23 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-04-14 18:45:23 -0400 |
commit | cd634f1bfc182e564f33809fdca33027bb99fceb (patch) | |
tree | e81c3b626866a64b8152576cb500ee2fc2fe40a0 | |
parent | dfc2e12df02d49a1567bc90989ceef870cf5b147 (diff) |
[media] v4l2: put VIDIOC_DBG_G_CHIP_NAME under ADV_DEBUG
Only enable this ioctl if the VIDEO_ADV_DEBUG config option is set. This
prevents abuse from both userspace and kernelspace (some bridge drivers
abuse DBG_G_CHIP_IDENT, lets prevent that from happening again with this
ioctl).
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml | 3 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-video.c | 4 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-dev.c | 2 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 8 | ||||
-rw-r--r-- | include/media/v4l2-ioctl.h | 6 |
5 files changed, 13 insertions, 10 deletions
diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml index 4921346fabd7..5fce8d84288e 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml | |||
@@ -63,6 +63,9 @@ card. Regular applications must not use it. When you found a chip | |||
63 | specific bug, please contact the linux-media mailing list (&v4l-ml;) | 63 | specific bug, please contact the linux-media mailing list (&v4l-ml;) |
64 | so it can be fixed.</para> | 64 | so it can be fixed.</para> |
65 | 65 | ||
66 | <para>Additionally the Linux kernel must be compiled with the | ||
67 | <constant>CONFIG_VIDEO_ADV_DEBUG</constant> option to enable this ioctl.</para> | ||
68 | |||
66 | <para>To query the driver applications must initialize the | 69 | <para>To query the driver applications must initialize the |
67 | <structfield>match.type</structfield> and | 70 | <structfield>match.type</structfield> and |
68 | <structfield>match.addr</structfield> or <structfield>match.name</structfield> | 71 | <structfield>match.addr</structfield> or <structfield>match.name</structfield> |
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 792ead1025d7..39951f5731e1 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c | |||
@@ -1331,6 +1331,7 @@ static int vidioc_g_chip_ident(struct file *file, void *priv, | |||
1331 | return 0; | 1331 | return 0; |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1334 | static int vidioc_g_chip_name(struct file *file, void *priv, | 1335 | static int vidioc_g_chip_name(struct file *file, void *priv, |
1335 | struct v4l2_dbg_chip_name *chip) | 1336 | struct v4l2_dbg_chip_name *chip) |
1336 | { | 1337 | { |
@@ -1346,7 +1347,6 @@ static int vidioc_g_chip_name(struct file *file, void *priv, | |||
1346 | return 0; | 1347 | return 0; |
1347 | } | 1348 | } |
1348 | 1349 | ||
1349 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1350 | static int em28xx_reg_len(int reg) | 1350 | static int em28xx_reg_len(int reg) |
1351 | { | 1351 | { |
1352 | switch (reg) { | 1352 | switch (reg) { |
@@ -1796,8 +1796,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
1796 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | 1796 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, |
1797 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | 1797 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, |
1798 | .vidioc_g_chip_ident = vidioc_g_chip_ident, | 1798 | .vidioc_g_chip_ident = vidioc_g_chip_ident, |
1799 | .vidioc_g_chip_name = vidioc_g_chip_name, | ||
1800 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1799 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1800 | .vidioc_g_chip_name = vidioc_g_chip_name, | ||
1801 | .vidioc_g_register = vidioc_g_register, | 1801 | .vidioc_g_register = vidioc_g_register, |
1802 | .vidioc_s_register = vidioc_s_register, | 1802 | .vidioc_s_register = vidioc_s_register, |
1803 | #endif | 1803 | #endif |
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 670b9ca8ecbe..1c3b43cf773d 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c | |||
@@ -591,8 +591,8 @@ static void determine_valid_ioctls(struct video_device *vdev) | |||
591 | SET_VALID_IOCTL(ops, VIDIOC_G_FREQUENCY, vidioc_g_frequency); | 591 | SET_VALID_IOCTL(ops, VIDIOC_G_FREQUENCY, vidioc_g_frequency); |
592 | SET_VALID_IOCTL(ops, VIDIOC_S_FREQUENCY, vidioc_s_frequency); | 592 | SET_VALID_IOCTL(ops, VIDIOC_S_FREQUENCY, vidioc_s_frequency); |
593 | SET_VALID_IOCTL(ops, VIDIOC_LOG_STATUS, vidioc_log_status); | 593 | SET_VALID_IOCTL(ops, VIDIOC_LOG_STATUS, vidioc_log_status); |
594 | set_bit(_IOC_NR(VIDIOC_DBG_G_CHIP_NAME), valid_ioctls); | ||
595 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 594 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
595 | set_bit(_IOC_NR(VIDIOC_DBG_G_CHIP_NAME), valid_ioctls); | ||
596 | set_bit(_IOC_NR(VIDIOC_DBG_G_REGISTER), valid_ioctls); | 596 | set_bit(_IOC_NR(VIDIOC_DBG_G_REGISTER), valid_ioctls); |
597 | set_bit(_IOC_NR(VIDIOC_DBG_S_REGISTER), valid_ioctls); | 597 | set_bit(_IOC_NR(VIDIOC_DBG_S_REGISTER), valid_ioctls); |
598 | #endif | 598 | #endif |
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 336ed2dd607c..feac07e50293 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
@@ -1873,6 +1873,7 @@ static int v4l_dbg_g_chip_ident(const struct v4l2_ioctl_ops *ops, | |||
1873 | static int v4l_dbg_g_chip_name(const struct v4l2_ioctl_ops *ops, | 1873 | static int v4l_dbg_g_chip_name(const struct v4l2_ioctl_ops *ops, |
1874 | struct file *file, void *fh, void *arg) | 1874 | struct file *file, void *fh, void *arg) |
1875 | { | 1875 | { |
1876 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1876 | struct video_device *vfd = video_devdata(file); | 1877 | struct video_device *vfd = video_devdata(file); |
1877 | struct v4l2_dbg_chip_name *p = arg; | 1878 | struct v4l2_dbg_chip_name *p = arg; |
1878 | struct v4l2_subdev *sd; | 1879 | struct v4l2_subdev *sd; |
@@ -1880,12 +1881,10 @@ static int v4l_dbg_g_chip_name(const struct v4l2_ioctl_ops *ops, | |||
1880 | 1881 | ||
1881 | switch (p->match.type) { | 1882 | switch (p->match.type) { |
1882 | case V4L2_CHIP_MATCH_BRIDGE: | 1883 | case V4L2_CHIP_MATCH_BRIDGE: |
1883 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1884 | if (ops->vidioc_s_register) | 1884 | if (ops->vidioc_s_register) |
1885 | p->flags |= V4L2_CHIP_FL_WRITABLE; | 1885 | p->flags |= V4L2_CHIP_FL_WRITABLE; |
1886 | if (ops->vidioc_g_register) | 1886 | if (ops->vidioc_g_register) |
1887 | p->flags |= V4L2_CHIP_FL_READABLE; | 1887 | p->flags |= V4L2_CHIP_FL_READABLE; |
1888 | #endif | ||
1889 | if (ops->vidioc_g_chip_name) | 1888 | if (ops->vidioc_g_chip_name) |
1890 | return ops->vidioc_g_chip_name(file, fh, arg); | 1889 | return ops->vidioc_g_chip_name(file, fh, arg); |
1891 | if (p->match.addr) | 1890 | if (p->match.addr) |
@@ -1904,12 +1903,10 @@ static int v4l_dbg_g_chip_name(const struct v4l2_ioctl_ops *ops, | |||
1904 | break; | 1903 | break; |
1905 | v4l2_device_for_each_subdev(sd, vfd->v4l2_dev) { | 1904 | v4l2_device_for_each_subdev(sd, vfd->v4l2_dev) { |
1906 | if (v4l_dbg_found_match(&p->match, sd, idx++)) { | 1905 | if (v4l_dbg_found_match(&p->match, sd, idx++)) { |
1907 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1908 | if (sd->ops->core && sd->ops->core->s_register) | 1906 | if (sd->ops->core && sd->ops->core->s_register) |
1909 | p->flags |= V4L2_CHIP_FL_WRITABLE; | 1907 | p->flags |= V4L2_CHIP_FL_WRITABLE; |
1910 | if (sd->ops->core && sd->ops->core->g_register) | 1908 | if (sd->ops->core && sd->ops->core->g_register) |
1911 | p->flags |= V4L2_CHIP_FL_READABLE; | 1909 | p->flags |= V4L2_CHIP_FL_READABLE; |
1912 | #endif | ||
1913 | strlcpy(p->name, sd->name, sizeof(p->name)); | 1910 | strlcpy(p->name, sd->name, sizeof(p->name)); |
1914 | return 0; | 1911 | return 0; |
1915 | } | 1912 | } |
@@ -1917,6 +1914,9 @@ static int v4l_dbg_g_chip_name(const struct v4l2_ioctl_ops *ops, | |||
1917 | break; | 1914 | break; |
1918 | } | 1915 | } |
1919 | return -EINVAL; | 1916 | return -EINVAL; |
1917 | #else | ||
1918 | return -ENOTTY; | ||
1919 | #endif | ||
1920 | } | 1920 | } |
1921 | 1921 | ||
1922 | static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, | 1922 | static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, |
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index b273f0e81818..6b917d69e408 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h | |||
@@ -243,12 +243,12 @@ struct v4l2_ioctl_ops { | |||
243 | struct v4l2_dbg_register *reg); | 243 | struct v4l2_dbg_register *reg); |
244 | int (*vidioc_s_register) (struct file *file, void *fh, | 244 | int (*vidioc_s_register) (struct file *file, void *fh, |
245 | const struct v4l2_dbg_register *reg); | 245 | const struct v4l2_dbg_register *reg); |
246 | #endif | ||
247 | int (*vidioc_g_chip_ident) (struct file *file, void *fh, | ||
248 | struct v4l2_dbg_chip_ident *chip); | ||
249 | 246 | ||
250 | int (*vidioc_g_chip_name) (struct file *file, void *fh, | 247 | int (*vidioc_g_chip_name) (struct file *file, void *fh, |
251 | struct v4l2_dbg_chip_name *chip); | 248 | struct v4l2_dbg_chip_name *chip); |
249 | #endif | ||
250 | int (*vidioc_g_chip_ident) (struct file *file, void *fh, | ||
251 | struct v4l2_dbg_chip_ident *chip); | ||
252 | 252 | ||
253 | int (*vidioc_enum_framesizes) (struct file *file, void *fh, | 253 | int (*vidioc_enum_framesizes) (struct file *file, void *fh, |
254 | struct v4l2_frmsizeenum *fsize); | 254 | struct v4l2_frmsizeenum *fsize); |