v4l: ioctl: Validate num_planes for debug messages
Subsystems (2)
PATCH 1/1 v4l: ioctl: Validate num_planes for debug messages
The num_planes field in struct v4l2_pix_format_mplane is used in a loop before validating it. As the use is printing a debug message in this case, just cap the value to the maximum allowed.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ioctl.c +3 -1
@@ -287,6 +287,7 @@ static void v4l_print_format(const void *arg, bool write_only)const struct v4l2_window *win;const struct v4l2_sdr_format *sdr;const struct v4l2_meta_format *meta; +u32 planes;unsigned i;pr_cont ("type=%s" ,prt_names (p->type, v4l2_type_names));
@@ -317,7 +318,8 @@ static void v4l_print_format(const void *arg, bool write_only)prt_names (mp->field, v4l2_field_names), mp->colorspace, mp->num_planes, mp->flags, mp->ycbcr_enc, mp->quantization, mp->xfer_func); -for (i =0 ; i < mp->num_planes; i++) + planes =min_t (u32, mp->num_planes,VIDEO_MAX_PLANES ); +for (i =0 ; i < planes; i++)printk (KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n" , i, mp->plane_fmt[i].bytesperline, mp->plane_fmt[i].sizeimage);
Signature · 1 line
2.11.0
Quoted 9 lines · Sakari Ailus
The
num_planesfield in structv4l2_pix_format_mplaneis used in a loop before validating it. As the use is printing a debug message in this case, just cap the value to the maximum allowed.Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Seems reasonable:
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 44 lines · Sasha Levin
Hi,
[This is an automated email]
This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all
The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150, v4.4.170, v3.18.132.
v4.20.2: Build OK!
v4.19.15: Build OK!
v4.14.93: Build OK!
v4.9.150: Failed to apply! Possible dependencies:
fb9ffa6a7f7e("[media] v4l: Add metadata buffer type and format")v4.4.170: Failed to apply! Possible dependencies:
0579e6e3a326 ("doc-rst: linux_tv: remove whitespaces") 17defc282fe6 ("Documentation: add meta-documentation for Sphinx and kernel-doc") 22cba31bae9d ("Documentation/sphinx: add basic working Sphinx configuration and build") 234d549662a7 ("doc-rst: video: use reference for VIDIOC_ENUMINPUT") 5377d91f3e88 ("doc-rst: linux_tv DocBook to reST migration (docs-next)") 7347081e8a52 ("doc-rst: linux_tv: simplify references") 789818845202 ("doc-rst: audio: Fix some cross references") 94fff0dc5333 ("doc-rst: dmx_fcalls: improve man-like format") 9e00ffca8cc7 ("doc-rst: querycap: fix troubles on some references") af4a4d0db8ab ("doc-rst: linux_tv: Replace reference names to match ioctls") c2b66cafdf02 ("[media] v4l: doc: Remove row numbers from tables") e6702ee18e24 ("doc-rst: app-pri: Fix a bad reference") fb9ffa6a7f7e ("[media] v4l: Add metadata buffer type and format")v3.18.132: Failed to apply! Possible dependencies:
0579e6e3a326("doc-rst:linux_tv: remove whitespaces")
17defc282fe6("Documentation: add meta-documentation for Sphinx and kernel-doc")22cba31bae9d("Documentation/sphinx: add basic working Sphinx configuration and build")5377d91f3e88("doc-rst:linux_tvDocBook to reST migration (docs-next)")5699f871d2d5("scripts/kernel-doc: Adding cross-reference links to html documentation.")7347081e8a52("doc-rst:linux_tv: simplify references")
af4a4d0db8ab("doc-rst:linux_tv: Replace reference names to match ioctls")b479bfd00e46("DocBook: Use a fixed encoding for output")
c2b66cafdf02("[media] v4l: doc: Remove row numbers from tables")e6702ee18e24("doc-rst: app-pri: Fix a bad reference")
fb9ffa6a7f7e("[media] v4l: Add metadata buffer type and format")
Quoted 1 line
How should we proceed with this patch?
The Cc to stable of this patch in the pending pull request has a 'for v4.12 and up':
So no need to patch pre-4.12 kernels.
Regards,
Hans