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