cxl: Fix error path on bad ioctl
PATCH 1/1 cxl: Fix error path on bad ioctl
Fix error path if we can't copy user structure onCXL_IOCTL_START_WORK ioctl.
--- drivers/misc/cxl/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/misc/cxl/file.c +2 -4
@@ -160,10 +160,8 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,/* Do this outside the status_mutex to avoid a circular dependency with * the locking in cxl_mmap_fault() */ if (copy_from_user (&work, uwork, -sizeof (struct cxl_ioctl_start_work ))) { - rc = -EFAULT ; - goto out; - } +sizeof (struct cxl_ioctl_start_work ))) +return -EFAULT ;mutex_lock (&ctx->status_mutex);if (ctx->status !=OPENED ) {
Signature · 1 line
2.11.0
Hi Fred,
Good catch.
Quoted 14 lines · Frederic Barrat
Fix error path if we can't copy user structure on
CXL_IOCTL_START_WORKioctl.Signed-off-by Frederic Barrat <[email protected]>--- drivers/misc/cxl/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/misc/cxl/file.c +0
-0
drivers/misc/cxl/file.c static long afu_ioctl_start_work(struct cxl_context *ctx, · line 163
Quoted 8 lines
drivers/misc/cxl/file.c +1
-4@@ -160,10 +160,8 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,/* Do this outside the status_mutex to avoid a circular dependency with * the locking in cxl_mmap_fault() */ if (copy_from_user (&work, uwork, -sizeof (struct cxl_ioctl_start_work ))) { - rc = -EFAULT ; - goto out; - } +sizeof (struct cxl_ioctl_start_work )))
Bike-shedding a bit, but
s/sizeof(struct cxl_ioctl_start_work)))/sizeof(work)/ would look much cleaner
Quoted 5 lines · Frederic Barrat
Fix error path if we can't copy user structure on
CXL_IOCTL_START_WORKioctl.Signed-off-by Frederic Barrat <[email protected]>
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Quoted 2 lines · Frederic Barrat
Fix error path if we can't copy user structure on
CXL_IOCTL_START_WORKioctl.
To be clear the error is that returning via the out label will unlock cxl->status_mutex, which has not been locked.
Please spell it out for me :)
This should be:
Am I right?
cheers
Quoted 19 lines
drivers/misc/cxl/file.c +2
-4@@ -160,10 +160,8 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,/* Do this outside the status_mutex to avoid a circular dependency with * the locking in cxl_mmap_fault() */ if (copy_from_user (&work, uwork, -sizeof (struct cxl_ioctl_start_work ))) { - rc = -EFAULT ; - goto out; - } +sizeof (struct cxl_ioctl_start_work ))) +return -EFAULT ;mutex_lock (&ctx->status_mutex);if (ctx->status !=OPENED ) {Signature · 1 line
2.11.0
Quoted 8 lines · Michael Ellerman
Quoted 2 lines · Frederic Barrat
Fix error path if we can't copy user structure on
CXL_IOCTL_START_WORKioctl.To be clear the error is that returning via the out label will unlock
cxl->status_mutex, which has not been locked.
Quoted 7 lines
Please spell it out for me :)
This should be:
Fixes 0712dc7e73e5 ("cxl: Fix issues when unmapping contexts")Am I right?
That's correct. I'm about to send a v2 to address Vaibhav's comment and I'll fix the above as well.
Thanks,
Fred
Quoted 22 lines
cheers
Quoted 19 lines
drivers/misc/cxl/file.c +2
-4@@ -160,10 +160,8 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,/* Do this outside the status_mutex to avoid a circular dependency with * the locking in cxl_mmap_fault() */ if (copy_from_user (&work, uwork, -sizeof (struct cxl_ioctl_start_work ))) { - rc = -EFAULT ; - goto out; - } +sizeof (struct cxl_ioctl_start_work ))) +return -EFAULT ;mutex_lock (&ctx->status_mutex);if (ctx->status !=OPENED ) {Signature · 1 line
2.11.0
Quoted 17 lines · Frederic Barrat
Le 06/06/2017 =C3=A0 11:20, Michael Ellerman a =C3=A9crit :
Quoted 12 lines
Frederic Barrat <[email protected]> writes:
=20Quoted 2 lines
Fix error path if we can't copy user structure on
CXL_IOCTL_START_WORKioctl.=20
To be clear the error is that returning via the out label will unlockcxl->status_mutex, which has not been locked.
=20
Please spell it out for me :)
=20
This should be:
=20Quoted 3 lines
Fixes 0712dc7e73e5 ("cxl: Fix issues when unmapping contexts")=20
Am I right?
Quoted 2 lines
That's correct. I'm about to send a v2 to address Vaibhav's comment and=20 I'll fix the above as well.
Thanks.
cheers