Skip to contentSkip to conversation

net: usb: pegasus: fix improper read if get_registers() fail

PATCH Applied Denis Kirjanov 3 participants 7 messages Jul 30, 2019 – Aug 1, 2019 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: usb: pegasus: fix improper read if get_registers() fail

get_registers() may fail with -ENOMEM and in this case we can read a garbage from the status variable tmp.

---
 drivers/net/usb/pegasus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/pegasus.c +1 -1
index 6d25dea5ad4b..f7d117d80cfb 100644
@@ -282,7 +282,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
 static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
 {
 	int i;
-	__u8 tmp;
+	__u8 tmp = 0;
 	__le16 retdatai;
 	int ret;
 
Signature · 1 line
2.12.3
#2 lore raw
Quoted 12 lines · David Miller

From: Denis Kirjanov <[email protected]>
Date: Tue, 30 Jul 2019 15:13:57 +0200

Quoted 5 lines

get_registers() may fail with -ENOMEM and in this case we can read a garbage from the status variable tmp.

Why did you post this patch twice? What is different between the two versions?

Looks like it was the issue with git send-email. Sorry about that. Do you want me to figure out the reason and resend?

A message that is not in the archive (sent off-list or not yet received): CAHj3AVm2EZB7n9UBxiBmA+6XN+EgAC_FRoHjh6kO3WMT8KVd6g@mail.gmail.com

maintainer
#4 lore raw

From: Denis Kirjanov <[email protected]>
Date: Tue, 30 Jul 2019 21:19:46 +0300

Quoted 11 lines · David Miller
Quoted 10 lines

From: Denis Kirjanov <[email protected]>
Date: Tue, 30 Jul 2019 15:13:57 +0200

Quoted 5 lines

get_registers() may fail with -ENOMEM and in this case we can read a garbage from the status variable tmp.

Quoted 6 lines
Quoted 2 lines

Why did you post this patch twice? What is different between the two versions?

Looks like it’s the issue with git send-email :/ Do you want me to figure out the reason and resend?

No need, I was just curious.

maintainer
#5 lore raw
In reply to Denis Kirjanov
Quoted 14 lines · Denis Kirjanov

get_registers() may fail with -ENOMEM and in this case we can read a garbage from the status variable tmp.

---
 drivers/net/usb/pegasus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/pegasus.c +0 -0
index 6d25dea5ad4b..f7d117d80cfb 100644

drivers/net/usb/pegasus.c static void mdio_write(struct net_device *dev, int phy_id, int loc, int val) · line 287

Quoted 7 lines
drivers/net/usb/pegasus.c +1 -1
@@ -282,7 +282,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
 static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
 {
 	int i;
-	__u8 tmp;
+	__u8 tmp = 0;
 	__le16 retdatai;
 	int ret;

Unfortunately this patch does not fix anything. Even if get_registers() fail with -ENOMEM the "for" loop will cover for it and will exit only if the operation was successful or the device got disconnected. Please read the code carefully.

So while the patch is harmless it isn't solving a problem.

cheers,
Petko

maintainer
#6 lore raw
Quoted 28 lines · Petko Manolov
Quoted 14 lines · Denis Kirjanov

get_registers() may fail with -ENOMEM and in this case we can read a garbage from the status variable tmp.

---
 drivers/net/usb/pegasus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/pegasus.c +0 -0
index 6d25dea5ad4b..f7d117d80cfb 100644

drivers/net/usb/pegasus.c static void mdio_write(struct net_device *dev, int phy_id, int loc, int val) · line 287

Quoted 7 lines
drivers/net/usb/pegasus.c +1 -1
@@ -282,7 +282,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
 static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
 {
 	int i;
-	__u8 tmp;
+	__u8 tmp = 0;
 	__le16 retdatai;
 	int ret;

Unfortunately this patch does not fix anything. Even if get_registers() fail with -ENOMEM the "for" loop will cover for it and will exit only if the operation was successful or the device got disconnected. Please read the code carefully.

Quoted 1 line

So while the patch is harmless it isn't solving a problem.

Actually i am wrong - if "tmp" contains a random value it may accidentally have the EPROM_DONE bit set.

Dave, please apply the patch.

thanks,
Petko