Skip to contentSkip to conversation

mt76: mt7615: fix a precision vs width bug in printk

PATCH Superseded Dan Carpenter 2 participants 6 messages Apr 21, 2021

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

PATCH 1/3 mt76: mt7615: fix a precision vs width bug in printk

Precision "%.*s" was intended instead of width "%*s". The original code will print garbage from beyond the end of the skb->data.

Fixes d76d6c3ba2b0 ("mt76: mt7615: limit firmware log message printk to buffer length")
---
 drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +1 -1
index 9b9f8d88e9bb..00b1b657cb21 100644
@@ -424,7 +424,7 @@ mt7615_mcu_rx_log_message(struct mt7615_dev *dev, struct sk_buff *skb)
 		break;
 	}
 
-	wiphy_info(mt76_hw(dev)->wiphy, "%s: %*s", type,
+	wiphy_info(mt76_hw(dev)->wiphy, "%s: %.*s", type,
 		   (int)(skb->len - sizeof(*rxd)), data);
 }
 
Signature · 7 lines
2.30.2


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
#1 lore raw

PATCH 2/3 mt76: mt7915: fix a precision vs width bug in printk

Precision %.*s was intended instead of width %.*s. The original code will still print unintended data from beyond the end of skb->data.

Fixes 665b2c780d63 ("mt76: mt7915: limit firmware log message printk to buffer length")
---
 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
index 908e74a6b8e6..94195a1ad3b8 100644
@@ -521,7 +521,7 @@ mt7915_mcu_rx_log_message(struct mt7915_dev *dev, struct sk_buff *skb)
 		break;
 	}
 
-	wiphy_info(mt76_hw(dev)->wiphy, "%s: %*s", type,
+	wiphy_info(mt76_hw(dev)->wiphy, "%s: %.*s", type,
 		   (int)(skb->len - sizeof(*rxd)), data);
 }
 
Signature · 7 lines
2.30.2


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
#2 lore raw

Re: [PATCH 2/3] mt76: mt7915: fix a precision vs width bug in printk

Quoted 2 lines · Dan Carpenter

Precision %.*s was intended instead of width %.*s.

typo there, the second instance should say "width %*s" :-)

johannes

#3 lore raw

Re: [PATCH 2/3] mt76: mt7915: fix a precision vs width bug in printk

Quoted 5 lines · Johannes Berg
Quoted 2 lines · Dan Carpenter

Precision %.*s was intended instead of width %.*s.

typo there, the second instance should say "width %*s" :-)

The hunter has become the hunted. *dramatic music. dah dah dah.*

:P

Thanks.

regards,
dan carpenter

#4 lore raw

PATCH v2 2/3 mt76: mt7915: fix a precision vs width bug in printk

In reply to Johannes Berg

Precision %.*s was intended instead of width %*s. The original code will still print unintended data from beyond the end of skb->data.

Fixes 665b2c780d63 ("mt76: mt7915: limit firmware log message printk to buffer length")

---
v2: fix a typo in the commit message

 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
index 908e74a6b8e6..94195a1ad3b8 100644
@@ -521,7 +521,7 @@ mt7915_mcu_rx_log_message(struct mt7915_dev *dev, struct sk_buff *skb)
 		break;
 	}
 
-	wiphy_info(mt76_hw(dev)->wiphy, "%s: %*s", type,
+	wiphy_info(mt76_hw(dev)->wiphy, "%s: %.*s", type,
 		   (int)(skb->len - sizeof(*rxd)), data);
 }
 
Signature · 1 line
2.30.2
#5 lore raw

PATCH 3/3 mt76: mt7921: fix a precision vs width bug in printk

In reply to Dan Carpenter

Precision %.*s was intended instead of width %*s. The original code is potentially an information leak.

Fixes c7cc5ec57303 ("mt76: mt7921: rework mt7921_mcu_debug_msg_event routine")
---
 drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +1 -1
index aa55667b6ed7..45ad2c337d41 100644
@@ -500,7 +500,7 @@ mt7921_mcu_debug_msg_event(struct mt7921_dev *dev, struct sk_buff *skb)
 			if (!msg->content[i])
 				msg->content[i] = ' ';
 		}
-		wiphy_info(mt76_hw(dev)->wiphy, "%*s", len, msg->content);
+		wiphy_info(mt76_hw(dev)->wiphy, "%.*s", len, msg->content);
 	}
 }
 
Signature · 7 lines
2.30.2


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek