Skip to contentSkip to conversation

staging: rtl8723bs: Fix return type for implementation of ndo_start_xmit

PATCH Superseded GUO Zihua 2 participants 3 messages Sep 5, 2022 – Sep 9, 2022 Staging

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

GUO Zihua

author
#0 lore raw

PATCH v3 1/1 staging: rtl8723bs: Fix return type for implementation of ndo_start_xmit

CFI (Control Flow Integrity) is a safety feature allowing the system to detect and react should a potential control flow hijacking occurs. In particular, the Forward-Edge CFI protects indirect function calls by ensuring the prototype of function that is actually called matches the definition of the function hook.

Since Linux now supports CFI, it will be a good idea to fix mismatched return type for implementation of hooks. Otherwise this would get cought out by CFI and cause a panic.

As returns from _rtw_xmit_entry() would always be 0, remove unneeded variable ret and use enums from netdev_tx_t as return value instead. Then change return type to netdev_tx_t.

---

v3:
Provide detail on CFI.

v2:
Fix truncated subject.

---
 drivers/staging/rtl8723bs/include/xmit_osdep.h | 2 +-
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c  | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/staging/rtl8723bs/include/xmit_osdep.h +1 -1
index e781cd5dfd01..7ac8cf589f90 100644
@@ -26,7 +26,7 @@ struct xmit_frame;
 struct xmit_buf;
 
 extern int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev);
-extern int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev);
+extern netdev_tx_t rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev);
 
 void rtw_os_xmit_schedule(struct adapter *padapter);
 
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +3 -5
index 530e7a6c67c5..d42fd0878dcd 100644
@@ -220,12 +220,10 @@ int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
 	return 0;
 }
 
-int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
+netdev_tx_t rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
 {
-	int ret = 0;
-
 	if (pkt)
-		ret = _rtw_xmit_entry(pkt, pnetdev);
+		_rtw_xmit_entry(pkt, pnetdev);
 
-	return ret;
+	return NETDEV_TX_OK;
 }
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 6 lines · GUO Zihua

CFI (Control Flow Integrity) is a safety feature allowing the system to detect and react should a potential control flow hijacking occurs. In particular, the Forward-Edge CFI protects indirect function calls by ensuring the prototype of function that is actually called matches the definition of the function hook.

Quoted 7 lines

Since Linux now supports CFI, it will be a good idea to fix mismatched return type for implementation of hooks. Otherwise this would get cought out by CFI and cause a panic.

As returns from _rtw_xmit_entry() would always be 0, remove unneeded variable ret and use enums from netdev_tx_t as return value instead. Then change return type to netdev_tx_t.

If _rtw_xmit_entry() can never fail, then it needs to not have a return value at all, and that needs to also be fixed. Can you make this a patch series that does the return type change for _rtw_xmit_entry() first, and then this change on top of that one.

thanks,

greg k-h

#2 lore raw
Quoted 20 lines · Greg KH
Quoted 6 lines · GUO Zihua

CFI (Control Flow Integrity) is a safety feature allowing the system to detect and react should a potential control flow hijacking occurs. In particular, the Forward-Edge CFI protects indirect function calls by ensuring the prototype of function that is actually called matches the definition of the function hook.

Quoted 7 lines

Since Linux now supports CFI, it will be a good idea to fix mismatched return type for implementation of hooks. Otherwise this would get cought out by CFI and cause a panic.

As returns from _rtw_xmit_entry() would always be 0, remove unneeded variable ret and use enums from netdev_tx_t as return value instead. Then change return type to netdev_tx_t.

If _rtw_xmit_entry() can never fail, then it needs to not have a return value at all, and that needs to also be fixed. Can you make this a patch series that does the return type change for _rtw_xmit_entry() first, and then this change on top of that one.

Quoted 4 lines

thanks,

greg k-h
.

Sure Greg

Signature · 2 lines
Best
GUO Zihua