001-rt2x00-use-simple_read_from_buffer.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From f483039cf51acf30494cd754194562c22cf98764 Mon Sep 17 00:00:00 2001
  2. From: Dan Carpenter <[email protected]>
  3. Date: Wed, 22 Aug 2018 13:41:26 +0300
  4. Subject: [PATCH 01/28] rt2x00: use simple_read_from_buffer()
  5. The problem with this copy_to_user() calls is that they don't ensure
  6. that "size" is less than the "length" which the user provided.
  7. Obviously, this is debugfs and "size" is normally going to be very small
  8. so it probably doesn't matter, but this is the correct thing to do.
  9. Signed-off-by: Dan Carpenter <[email protected]>
  10. Acked-by: Stanislaw Gruszka <[email protected]>
  11. Signed-off-by: Kalle Valo <[email protected]>
  12. ---
  13. .../net/wireless/ralink/rt2x00/rt2x00debug.c | 18 +++---------------
  14. 1 file changed, 3 insertions(+), 15 deletions(-)
  15. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
  16. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
  17. @@ -464,11 +464,7 @@ static ssize_t rt2x00debug_read_##__name
  18. \
  19. size = sprintf(line, __format, value); \
  20. \
  21. - if (copy_to_user(buf, line, size)) \
  22. - return -EFAULT; \
  23. - \
  24. - *offset += size; \
  25. - return size; \
  26. + return simple_read_from_buffer(buf, length, offset, line, size); \
  27. }
  28. #define RT2X00DEBUGFS_OPS_WRITE(__name, __type) \
  29. @@ -545,11 +541,7 @@ static ssize_t rt2x00debug_read_dev_flag
  30. size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->flags);
  31. - if (copy_to_user(buf, line, size))
  32. - return -EFAULT;
  33. -
  34. - *offset += size;
  35. - return size;
  36. + return simple_read_from_buffer(buf, length, offset, line, size);
  37. }
  38. static const struct file_operations rt2x00debug_fop_dev_flags = {
  39. @@ -574,11 +566,7 @@ static ssize_t rt2x00debug_read_cap_flag
  40. size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->cap_flags);
  41. - if (copy_to_user(buf, line, size))
  42. - return -EFAULT;
  43. -
  44. - *offset += size;
  45. - return size;
  46. + return simple_read_from_buffer(buf, length, offset, line, size);
  47. }
  48. static const struct file_operations rt2x00debug_fop_cap_flags = {