drm: not to read outside the boundary for CRC source name.
Subsystems (2)
PATCH 1/2 drm: not to read outside the boundary for CRC source name.
'n-1' is the index to access the last character of CRC source name.
--- drivers/gpu/drm/drm_debugfs_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_debugfs_crc.c +2 -2
@@ -131,8 +131,8 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,if (IS_ERR (source))return PTR_ERR (source); -if (source[len] =='\n' ) - source[len] ='\0' ; +if (source[len-1 ] =='\n' ) + source[len-1 ] ='\0' ; ret = crtc->funcs->verify_crc_source (crtc, source, &values_cnt);if (ret)
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm: Set crc->opened = false before setting crc source to NULL.
to terminate the while-loop in drm_dp_aux_crc_work when drm_dp_start/stop_crc are called in the hook to set crc source.
--- drivers/gpu/drm/drm_debugfs_crc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/drm_debugfs_crc.c +7 -0
@@ -249,6 +249,13 @@ static int crtc_crc_release(struct inode *inode, struct file *filep)struct drm_crtc *crtc = filep->f_inode->i_private;struct drm_crtc_crc *crc = &crtc->crc; +/* terminate the infinite while loop if 'drm_dp_aux_crc_work' running */ +if (crc->opened) { +spin_lock_irq (&crc->lock); + crc->opened = false; +spin_unlock_irq (&crc->lock); + } + crtc->funcs->set_crc_source (crtc,NULL );spin_lock_irq (&crc->lock);
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm: Set crc->opened = false before setting crc source to NULL.
Hi Dingchen
I do not know this code, so please await feedback from others on the patch itself.
Quoted 4 lines · Dingchen Zhang
to terminate the while-loop in
drm_dp_aux_crc_workwhen drm_dp_start/stop_crc are called in the hook to set crc source.Cc Leo Li <[email protected]>, Harry <[email protected]>, Nick <[email protected]>
Only one pair of name/email per line.
And try to use the full name as reported by scripts/get_maintainer.pl
Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm: Set crc->opened = false before setting crc source to NULL.
In reply to Dingchen ZhangQuoted 5 lines · Dingchen Zhang
to terminate the while-loop in
drm_dp_aux_crc_workwhen drm_dp_start/stop_crc are called in the hook to set crc source.Cc Leo Li <[email protected]>, Harry <[email protected]>, Nick <[email protected]>Signed-off-by Dingchen Zhang <[email protected]>
I wonder how this isn't creating problems for Rockchip with the Analogix bridge.
Harry
Quoted 13 lines
--- drivers/gpu/drm/drm_debugfs_crc.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/drm_debugfs_crc.c +0
-0@@ -249,6 +249,13 @@ static int crtc_crc_release(struct inode *inode, struct file *filep)struct drm_crtc *crtc = filep->f_inode->i_private;struct drm_crtc_crc *crc = &crtc->crc;
drivers/gpu/drm/drm_debugfs_crc.c static int crtc_crc_release(struct inode *inode, struct file *filep) · line 261
Quoted 10 lines
drivers/gpu/drm/drm_debugfs_crc.c +7
-0+/* terminate the infinite while loop if 'drm_dp_aux_crc_work' running */ +if (crc->opened) { +spin_lock_irq (&crc->lock); + crc->opened = false; +spin_unlock_irq (&crc->lock); + } + crtc->funcs->set_crc_source (crtc,NULL );spin_lock_irq (&crc->lock);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm: Set crc->opened = false before setting crc source to NULL.
Quoted 26 lines · Harry Wentland
Quoted 5 lines · Dingchen Zhang
to terminate the while-loop in
drm_dp_aux_crc_workwhen drm_dp_start/stop_crc are called in the hook to set crc source.Cc Leo Li <[email protected]>, Harry <[email protected]>, Nick <[email protected]>Signed-off-by Dingchen Zhang <[email protected]>I wonder how this isn't creating problems for Rockchip with the Analogix bridge.
Reviewed-by Harry Wentland <[email protected]>Harry
Quoted 12 lines
--- drivers/gpu/drm/drm_debugfs_crc.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/drm_debugfs_crc.c +0
-0@@ -249,6 +249,13 @@ static int crtc_crc_release(struct inode *inode, struct file *filep)struct drm_crtc *crtc = filep->f_inode->i_private;struct drm_crtc_crc *crc = &crtc->crc;
Quoted 6 lines
drivers/gpu/drm/drm_debugfs_crc.c static int crtc_crc_release(struct inode *inode, struct file *filep) · line 257
Quoted 6 lines
drivers/gpu/drm/drm_debugfs_crc.c +6
-0+/* terminate the infinite while loop if 'drm_dp_aux_crc_work' running */ +if (crc->opened) { +spin_lock_irq (&crc->lock); + crc->opened = false; +spin_unlock_irq (&crc->lock); + }
Either you don't need a lock to look at ->opened, or you need it. Not both. Too lazy check which way this is, it's practically w/e here :-) -Daniel
Quoted 9 lines
drivers/gpu/drm/drm_debugfs_crc.c static int crtc_crc_release(struct inode *inode, struct file *filep) · line 261
Quoted 5 lines
drivers/gpu/drm/drm_debugfs_crc.c +1
-0+ crtc->funcs->set_crc_source (crtc,NULL );spin_lock_irq (&crc->lock);_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Kazlauskas, Nicholas
Reviewed-byRe: [PATCH 2/2] drm: Set crc->opened = false before setting crc source to NULL.
Quoted 6 lines · Daniel Vetter
Quoted 5 lines · Harry Wentland
Quoted 4 lines · Dingchen Zhang
to terminate the while-loop in
drm_dp_aux_crc_workwhen drm_dp_start/stop_crc are called in the hook to set crc source.Cc Leo Li <[email protected]>, Harry <[email protected]>, Nick <[email protected]>
The Cc: need to be cleaned up before merge like you did with your other patch.
Quoted 21 lines
Quoted 21 lines
Quoted 1 line
Signed-off-by Dingchen Zhang <[email protected]>I wonder how this isn't creating problems for Rockchip with the Analogix bridge.
Reviewed-by Harry Wentland <[email protected]>Harry
Quoted 12 lines
--- drivers/gpu/drm/drm_debugfs_crc.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/drm_debugfs_crc.c +0
-0@@ -249,6 +249,13 @@ static int crtc_crc_release(struct inode *inode, struct file *filep)struct drm_crtc *crtc = filep->f_inode->i_private;struct drm_crtc_crc *crc = &crtc->crc;
Quoted 10 lines
Quoted 6 lines
drivers/gpu/drm/drm_debugfs_crc.c static int crtc_crc_release(struct inode *inode, struct file *filep) · line 257
Quoted 6 lines
drivers/gpu/drm/drm_debugfs_crc.c +6
-0+/* terminate the infinite while loop if 'drm_dp_aux_crc_work' running */ +if (crc->opened) { +spin_lock_irq (&crc->lock); + crc->opened = false; +spin_unlock_irq (&crc->lock); + }Either you don't need a lock to look at ->opened, or you need it. Not both. Too lazy check which way this is, it's practically w/e here :-) -Daniel
The check on crc->opened should probably just be dropped since it's not actually doing anything here.
With those fixed, this patch is:
Nicholas Kazlauskas
Quoted 11 lines
Quoted 10 lines
drivers/gpu/drm/drm_debugfs_crc.c static int crtc_crc_release(struct inode *inode, struct file *filep) · line 261
Quoted 6 lines
drivers/gpu/drm/drm_debugfs_crc.c +1
-0+ crtc->funcs->set_crc_source (crtc,NULL );spin_lock_irq (&crc->lock);_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm: Set crc->opened = false before setting crc source to NULL.
In reply to Daniel VetterQuoted 27 lines · Daniel Vetter
Quoted 26 lines · Harry Wentland
Quoted 5 lines · Dingchen Zhang
to terminate the while-loop in
drm_dp_aux_crc_workwhen drm_dp_start/stop_crc are called in the hook to set crc source.Cc Leo Li <[email protected]>, Harry <[email protected]>, Nick <[email protected]>Signed-off-by Dingchen Zhang <[email protected]>I wonder how this isn't creating problems for Rockchip with the Analogix bridge.
Reviewed-by Harry Wentland <[email protected]>Harry
Quoted 12 lines
--- drivers/gpu/drm/drm_debugfs_crc.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/drm_debugfs_crc.c +0
-0@@ -249,6 +249,13 @@ static int crtc_crc_release(struct inode *inode, struct file *filep)struct drm_crtc *crtc = filep->f_inode->i_private;struct drm_crtc_crc *crc = &crtc->crc;
Quoted 11 lines
Quoted 6 lines
drivers/gpu/drm/drm_debugfs_crc.c static int crtc_crc_release(struct inode *inode, struct file *filep) · line 257
Quoted 6 lines
drivers/gpu/drm/drm_debugfs_crc.c +6
-0+/* terminate the infinite while loop if 'drm_dp_aux_crc_work' running */ +if (crc->opened) { +spin_lock_irq (&crc->lock); + crc->opened = false; +spin_unlock_irq (&crc->lock); + }Either you don't need a lock to look at ->opened, or you need it. Not both. Too lazy check which way this is, it's practically w/e here :-) -Daniel
Hi Daniel,
Thanks for pointing out and sorry for late reply. Will create the new patch for that.
-Dingchen
Quoted 10 lines
Quoted 9 lines
drivers/gpu/drm/drm_debugfs_crc.c static int crtc_crc_release(struct inode *inode, struct file *filep) · line 261
Quoted 5 lines
drivers/gpu/drm/drm_debugfs_crc.c +1
-0+ crtc->funcs->set_crc_source (crtc,NULL );spin_lock_irq (&crc->lock);_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Dingchen.
Thanks for the patch!
Quoted 3 lines · Dingchen Zhang
'n-1' is the index to access the last character of CRC source name.
Cc Leo Li <[email protected]>, Harry Wentland<[email protected]>
Please add only one person (mail address) per Cc: line
I dunno if this is a hard rule, but this is what we always do.
Quoted 10 lines
Signed-off-by Dingchen Zhang <[email protected]>--- drivers/gpu/drm/drm_debugfs_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_debugfs_crc.c +0
-0
drivers/gpu/drm/drm_debugfs_crc.c static ssize_t crc_control_write(struct file *file, const char __user *ubuf, · line 135
Quoted 7 lines
drivers/gpu/drm/drm_debugfs_crc.c +2
-2@@ -131,8 +131,8 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,if (IS_ERR (source))return PTR_ERR (source); -if (source[len] =='\n' ) - source[len] ='\0' ; +if (source[len-1 ] =='\n' ) + source[len-1 ] ='\0' ;
In the kernel code we add spaces around operators. So the above should be: source[len - 1]
Details aside.memdup_user_nul() which is called gurantee that the buffer is null terminated. The buffer allocated is len + 1 and the last byte in the buffer is set to '\0' in memdup_user_nul().
So the right fix is to kill the two lines since they have no effect. Could you please verify my analysis, and if you agree submit a new patch.
Thanks,
Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thanks for the reply, Sam.
Quoted 37 lines · Sam Ravnborg
Hi Dingchen.
Thanks for the patch!
Quoted 3 lines · Dingchen Zhang
'n-1' is the index to access the last character of CRC source name.
Cc Leo Li <[email protected]>, Harry Wentland<[email protected]>Please add only one person (mail address) per Cc: line
I dunno if this is a hard rule, but this is what we always do.
Quoted 10 lines
Signed-off-by Dingchen Zhang <[email protected]>--- drivers/gpu/drm/drm_debugfs_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_debugfs_crc.c +0
-0drivers/gpu/drm/drm_debugfs_crc.c static ssize_t crc_control_write(struct file *file, const char __user *ubuf, · line 135
Quoted 7 lines
drivers/gpu/drm/drm_debugfs_crc.c +2
-2@@ -131,8 +131,8 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,if (IS_ERR (source))return PTR_ERR (source); -if (source[len] =='\n' ) - source[len] ='\0' ; +if (source[len-1 ] =='\n' ) + source[len-1 ] ='\0' ;In the kernel code we add spaces around operators. So the above should be: source[len - 1]
Details aside.
memdup_user_nul()which is called gurantee that the buffer is null terminated. The buffer allocated is len + 1 and the last byte in the buffer is set to '\0' inmemdup_user_nul().
Quoted 6 lines
So the right fix is to kill the two lines since they have no effect. Could you please verify my analysis, and if you agree submit a new patch.
Thanks,
Sam
You are right the buffer is null terminated at 'len+1'th. However, the patch is to actually remove the new line character. For example, if you type 'echo "abcd" > /sys/kernel/debugfs/dri/0/crtc-x/crc/control' in debugfs, the 'len' here is 5, where the 5th is the new line.
I will submit a new patch with a clear title and modify the format.
Thanks,
Dingchen
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel