Skip to contentSkip to conversation

rt2x00: fix "buffer size not provably correct" build warning

PATCH Superseded Arnaud Patard (Rtp) 2 participants 2 messages Aug 22, 2010 – Aug 23, 2010 1 message not in the archive Networking drivers (wireless)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 rt2x00: fix "buffer size not provably correct" build warning

rt2x00 debugfs interface doesn't check the size of the data coming from userspace, leading to a build warning. Fix That.

drivers/net/wireless/rt2x00/rt2x00debug.c +2 -0
Index: rt2x00/drivers/net/wireless/rt2x00/rt2x00debug.c
===================================================================
@@ -480,6 +480,8 @@ static ssize_t rt2x00debug_write_##__nam
 	if (index >= debug->__name.word_count)			\
 		return -EINVAL;					\
 								\
+	if (length > sizeof(line))				\
+		length = sizeof(line);				\
 	if (copy_from_user(line, buf, length))			\
 		return -EFAULT;					\
 								\
#2 lore raw
Quoted 10 lines · Arnaud Patard

rt2x00 debugfs interface doesn't check the size of the data coming from userspace, leading to a build warning. Fix That.

Index: rt2x00/drivers/net/wireless/rt2x00/rt2x00debug.c
===================================================================

drivers/net/wireless/rt2x00/rt2x00debug.c    2010-08-23 00:33:41.237941022 +0200 static ssize_t rt2x00debug_write_##__nam · line 487

Quoted 8 lines
drivers/net/wireless/rt2x00/rt2x00debug.c    2010-08-23 00:33:41.237941022 +0200 renamed from drivers/net/wireless/rt2x00/rt2x00debug.c       2010-08-23 00:21:42.637941244 +0200 +2 -0
@@ -480,6 +480,8 @@ static ssize_t rt2x00debug_write_##__nam
        if (index >= debug->__name.word_count)                  \
                return -EINVAL;                                 \
                                                                \
+       if (length > sizeof(line))                              \
+               length = sizeof(line);                          \
        if (copy_from_user(line, buf, length))                  \
                return -EFAULT;                                 \
                                                                \

I think it should actually return -EINVAL to clearly indicate that the input is invalid,
rather then alter the value. rt2x00debug_write_* alters registers, so we should not
assume anything when writing into it.

Ivo