Skip to contentSkip to conversation

staging: r8188eu: Fix return type for implementation of ndo_start_xmit

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

lore
Share & tools
lore

GUO Zihua

author
#0 lore raw

PATCH v4 1/1 staging: r8188eu: 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.

Use enums from netdev_tx_t as return value instead, then change return type to netdev_tx_t.

Fixes cf68fffb66d6 ("add support for Clang CFI")

---

v4:
Added Fixes tag.

v3:
Provide detail on CFI.

v2:
Fix truncated subject.

---
 drivers/staging/r8188eu/include/xmit_osdep.h | 2 +-
 drivers/staging/r8188eu/os_dep/xmit_linux.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/r8188eu/include/xmit_osdep.h +1 -1
index 00658681fef9..947242486144 100644
@@ -28,7 +28,7 @@ struct sta_xmit_priv;
 struct xmit_frame;
 struct xmit_buf;
 
-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);
 
 void rtw_os_xmit_schedule(struct adapter *padapter);
 
drivers/staging/r8188eu/os_dep/xmit_linux.c +2 -2
index 91a1e4e3219a..0b04010d6d82 100644
@@ -198,7 +198,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 	return true;
 }
 
-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)
 {
 	struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -233,5 +233,5 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct  net_device *pnetdev)
 
 exit:
 
-	return 0;
+	return NETDEV_TX_OK;
 }
Signature · 1 line
2.17.1
#1 lore raw
Quoted 58 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.

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.

Use enums from netdev_tx_t as return value instead, then change return type to netdev_tx_t.

Fixes cf68fffb66d6 ("add support for Clang CFI")

---

v4:
Added Fixes tag.

v3:
Provide detail on CFI.

v2:
Fix truncated subject.

---
  drivers/staging/r8188eu/include/xmit_osdep.h | 2 +-
  drivers/staging/r8188eu/os_dep/xmit_linux.c  | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/r8188eu/include/xmit_osdep.h +1 -1
index 00658681fef9..947242486144 100644
@@ -28,7 +28,7 @@ struct sta_xmit_priv;
  struct xmit_frame;
  struct xmit_buf;
 
-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);
 
  void rtw_os_xmit_schedule(struct adapter *padapter);
 
drivers/staging/r8188eu/os_dep/xmit_linux.c +1 -1
index 91a1e4e3219a..0b04010d6d82 100644
@@ -198,7 +198,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
  	return true;
  }
 
-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)
  {
  	struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
  	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;

drivers/staging/r8188eu/os_dep/xmit_linux.c int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) · line 237

Quoted 6 lines
drivers/staging/r8188eu/os_dep/xmit_linux.c +1 -1
@@ -233,5 +233,5 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct  net_device *pnetdev)
 
  exit:
 
-	return 0;
+	return NETDEV_TX_OK;
  }

Hi,

I cannot apply your patch:

Applying: staging: r8188eu: Fix return type for implementation of ndo_start_xmit
error: drivers/staging/r8188eu/include/xmit_osdep.h: does not exist in index
error: drivers/staging/r8188eu/os_dep/xmit_linux.c: does not exist in index Patch failed at 0001 staging: r8188eu: Fix return type for implementation of ndo_start_xmit

Fetch URL: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

branch staging-testing

Do you know why?

Bye Philipp

#2 lore raw
Quoted 74 lines · Philipp Hortmann
Quoted 58 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.

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.

Use enums from netdev_tx_t as return value instead, then change return type to netdev_tx_t.

Fixes cf68fffb66d6 ("add support for Clang CFI")

---

v4:
   Added Fixes tag.

v3:
   Provide detail on CFI.

v2:
   Fix truncated subject.

---
  drivers/staging/r8188eu/include/xmit_osdep.h | 2 +- drivers/staging/r8188eu/os_dep/xmit_linux.c  | 4 ++--

  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/r8188eu/include/xmit_osdep.h +1 -1
index 00658681fef9..947242486144 100644
@@ -28,7 +28,7 @@ struct sta_xmit_priv;
   struct xmit_frame;
   struct xmit_buf;
-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);
   void rtw_os_xmit_schedule(struct adapter *padapter);
drivers/staging/r8188eu/os_dep/xmit_linux.c +1 -1
index 91a1e4e3219a..0b04010d6d82 100644
@@ -198,7 +198,7 @@ static int rtw_mlcst2unicst(struct adapter 
 *padapter, struct sk_buff *skb)
       return true;
   }
-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)
   {
       struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);

      struct xmit_priv *pxmitpriv = &padapter->xmitpriv;

drivers/staging/r8188eu/os_dep/xmit_linux.c +0 -0
@@ -233,5 +233,5 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct  
 net_device *pnetdev)
Quoted 4 lines

  exit:
-    return 0;
+    return NETDEV_TX_OK;
  }

Hi,

I cannot apply your patch:

Applying: staging: r8188eu: Fix return type for implementation of ndo_start_xmit
error: drivers/staging/r8188eu/include/xmit_osdep.h: does not exist in index
error: drivers/staging/r8188eu/os_dep/xmit_linux.c: does not exist in index Patch failed at 0001 staging: r8188eu: Fix return type for implementation of ndo_start_xmit

Quoted 8 lines

Fetch URL: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

branch staging-testing

Do you know why?

Bye Philipp
.

Hi Philipp,

It seems that folder drivers/staging/r8188eu no longer presents on the branch you mentioned. However, they are still there on master branch.

Signature · 2 lines
Best
GUO Zihua
maintainer
#3 lore raw
Quoted 87 lines · Guozihua (Scott)
Quoted 86 lines · Philipp Hortmann
Quoted 61 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.

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.

Use enums from netdev_tx_t as return value instead, then change return type to netdev_tx_t.

Fixes cf68fffb66d6 ("add support for Clang CFI")

---

v4:
   Added Fixes tag.

v3:
   Provide detail on CFI.

v2:
   Fix truncated subject.

---
  drivers/staging/r8188eu/include/xmit_osdep.h | 2 +- drivers/staging/r8188eu/os_dep/xmit_linux.c  | 4 ++--

  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/r8188eu/include/xmit_osdep.h +1 -1
index 00658681fef9..947242486144 100644
@@ -28,7 +28,7 @@ struct sta_xmit_priv;
   struct xmit_frame;
   struct xmit_buf;
-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);
   void rtw_os_xmit_schedule(struct adapter *padapter);
drivers/staging/r8188eu/os_dep/xmit_linux.c +1 -1
index 91a1e4e3219a..0b04010d6d82 100644
@@ -198,7 +198,7 @@ static int rtw_mlcst2unicst(struct adapter
 *padapter, struct sk_buff *skb)
       return true;
   }
-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)
   {

      struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
      struct xmit_priv *pxmitpriv = &padapter->xmitpriv;

drivers/staging/r8188eu/os_dep/xmit_linux.c +0 -0
@@ -233,5 +233,5 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct
 net_device *pnetdev)
Quoted 4 lines

  exit:
-    return 0;
+    return NETDEV_TX_OK;
  }

Hi,

I cannot apply your patch:

Applying: staging: r8188eu: Fix return type for implementation of ndo_start_xmit
error: drivers/staging/r8188eu/include/xmit_osdep.h: does not exist in index
error: drivers/staging/r8188eu/os_dep/xmit_linux.c: does not exist in index Patch failed at 0001 staging: r8188eu: Fix return type for implementation of ndo_start_xmit

Fetch URL: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

branch staging-testing

Do you know why?

Quoted 7 lines
Quoted 2 lines

Bye Philipp
.

Hi Philipp,

It seems that folder drivers/staging/r8188eu no longer presents on the branch you mentioned. However, they are still there on master branch.

As my bot says, always work against either linux-next, or the development branch of the subsystem you are wanting to submit a patch to. Otherwise your patch will be rejected as it can not be applied for obvious reasons.

thanks,

greg k-h

maintainer
#4 lore raw
In reply to GUO Zihua
Quoted 68 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.

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.

Use enums from netdev_tx_t as return value instead, then change return type to netdev_tx_t.

Fixes cf68fffb66d6 ("add support for Clang CFI")

---

v4:
Added Fixes tag.

v3:
Provide detail on CFI.

v2:
Fix truncated subject.

---
 drivers/staging/r8188eu/include/xmit_osdep.h | 2 +-
 drivers/staging/r8188eu/os_dep/xmit_linux.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/r8188eu/include/xmit_osdep.h +1 -1
index 00658681fef9..947242486144 100644
@@ -28,7 +28,7 @@ struct sta_xmit_priv;
 struct xmit_frame;
 struct xmit_buf;
 
-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);
 
 void rtw_os_xmit_schedule(struct adapter *padapter);
 
drivers/staging/r8188eu/os_dep/xmit_linux.c +2 -2
index 91a1e4e3219a..0b04010d6d82 100644
@@ -198,7 +198,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 	return true;
 }
 
-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)
 {
 	struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -233,5 +233,5 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct  net_device *pnetdev)
 
 exit:
 
-	return 0;
+	return NETDEV_TX_OK;
 }
Signature · 1 line
2.17.1

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- Your patch did not apply to any known trees that Greg is in control of. Possibly this is because you made it against Linus's tree, not the linux-next tree, which is where all of the development for the next version of the kernel is at. Please refresh your patch against the linux-next tree, or even better yet, the development tree specified in the MAINTAINERS file for the subsystem you are submitting a patch for, and resend it.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot