public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v3] staging: rtl8723bs: Fix return type for implementation of ndo_start_xmit
@ 2022-09-05 13:03 GUO Zihua
  2022-09-09  7:46 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: GUO Zihua @ 2022-09-05 13:03 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging

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.

Signed-off-by: GUO Zihua <guozihua@huawei.com>
---

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(-)

diff --git a/drivers/staging/rtl8723bs/include/xmit_osdep.h b/drivers/staging/rtl8723bs/include/xmit_osdep.h
index e781cd5dfd01..7ac8cf589f90 100644
--- a/drivers/staging/rtl8723bs/include/xmit_osdep.h
+++ b/drivers/staging/rtl8723bs/include/xmit_osdep.h
@@ -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);
 
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 530e7a6c67c5..d42fd0878dcd 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -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;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] staging: rtl8723bs: Fix return type for implementation of ndo_start_xmit
  2022-09-05 13:03 [PATCH v3] staging: rtl8723bs: Fix return type for implementation of ndo_start_xmit GUO Zihua
@ 2022-09-09  7:46 ` Greg KH
  2022-09-09  8:05   ` Guozihua (Scott)
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2022-09-09  7:46 UTC (permalink / raw)
  To: GUO Zihua; +Cc: linux-staging

On Mon, Sep 05, 2022 at 09:03:10PM +0800, GUO Zihua wrote:
> 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.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] staging: rtl8723bs: Fix return type for implementation of ndo_start_xmit
  2022-09-09  7:46 ` Greg KH
@ 2022-09-09  8:05   ` Guozihua (Scott)
  0 siblings, 0 replies; 3+ messages in thread
From: Guozihua (Scott) @ 2022-09-09  8:05 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-staging

On 2022/9/9 15:46, Greg KH wrote:
> On Mon, Sep 05, 2022 at 09:03:10PM +0800, GUO Zihua wrote:
>> 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.
> 
> 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
> .

Sure Greg

-- 
Best
GUO Zihua

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-09  8:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-05 13:03 [PATCH v3] staging: rtl8723bs: Fix return type for implementation of ndo_start_xmit GUO Zihua
2022-09-09  7:46 ` Greg KH
2022-09-09  8:05   ` Guozihua (Scott)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox