* [PATCH] staging: rtl8723bs: use kfree_sensitive() for key material
@ 2026-07-13 23:34 Ivy Lopez
2026-07-13 23:37 ` Ivy Lopez
2026-07-14 7:20 ` Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Ivy Lopez @ 2026-07-13 23:34 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel, Ivy Lopez
The set_stakey_parm struct contains a 16-byte encryption key.
Use kfree_sensitive() instead of kfree() to ensure the key
material is zeroed before the memory is freed, preventing
potential information leaks.
Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
---
drivers/net/ethernet/faraday/ftmac100.c | 47 +++++-------------------
drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 ++--
2 files changed, 13 insertions(+), 42 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
index 5803a382f0ba..adb318925f44 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -49,7 +49,6 @@ struct ftmac100_descs {
};
struct ftmac100 {
- struct resource *res;
void __iomem *base;
int irq;
@@ -1137,11 +1136,9 @@ static int ftmac100_probe(struct platform_device *pdev)
return irq;
/* setup net_device */
- netdev = alloc_etherdev(sizeof(*priv));
- if (!netdev) {
- err = -ENOMEM;
- goto err_alloc_etherdev;
- }
+ netdev = devm_alloc_etherdev(&pdev->dev, sizeof(*priv));
+ if (!netdev)
+ return -ENOMEM;
SET_NETDEV_DEV(netdev, &pdev->dev);
netdev->ethtool_ops = &ftmac100_ethtool_ops;
@@ -1150,7 +1147,7 @@ static int ftmac100_probe(struct platform_device *pdev)
err = platform_get_ethdev_address(&pdev->dev, netdev);
if (err == -EPROBE_DEFER)
- goto defer_get_mac;
+ return err;
platform_set_drvdata(pdev, netdev);
@@ -1165,20 +1162,9 @@ static int ftmac100_probe(struct platform_device *pdev)
netif_napi_add(netdev, &priv->napi, ftmac100_poll);
/* map io memory */
- priv->res = request_mem_region(res->start, resource_size(res),
- dev_name(&pdev->dev));
- if (!priv->res) {
- dev_err(&pdev->dev, "Could not reserve memory region\n");
- err = -ENOMEM;
- goto err_req_mem;
- }
-
- priv->base = ioremap(res->start, resource_size(res));
- if (!priv->base) {
- dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
- err = -EIO;
- goto err_ioremap;
- }
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(priv->base))
+ return PTR_ERR(priv->base);
priv->irq = irq;
@@ -1208,32 +1194,17 @@ static int ftmac100_probe(struct platform_device *pdev)
return 0;
err_register_netdev:
- iounmap(priv->base);
-err_ioremap:
- release_resource(priv->res);
-err_req_mem:
netif_napi_del(&priv->napi);
-defer_get_mac:
- free_netdev(netdev);
-err_alloc_etherdev:
return err;
}
static void ftmac100_remove(struct platform_device *pdev)
{
- struct net_device *netdev;
- struct ftmac100 *priv;
-
- netdev = platform_get_drvdata(pdev);
- priv = netdev_priv(netdev);
+ struct net_device *netdev = platform_get_drvdata(pdev);
+ struct ftmac100 *priv = netdev_priv(netdev);
unregister_netdev(netdev);
-
- iounmap(priv->base);
- release_resource(priv->res);
-
netif_napi_del(&priv->napi);
- free_netdev(netdev);
}
static const struct of_device_id ftmac100_of_ids[] = {
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index b932670f5d63..a34ee407285b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -899,7 +899,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
if (enqueue) {
ph2c = kzalloc_obj(*ph2c);
if (!ph2c) {
- kfree(psetstakey_para);
+ kfree_sensitive(psetstakey_para);
res = _FAIL;
goto exit;
}
@@ -907,7 +907,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
psetstakey_rsp = kzalloc_obj(*psetstakey_rsp);
if (!psetstakey_rsp) {
kfree(ph2c);
- kfree(psetstakey_para);
+ kfree_sensitive(psetstakey_para);
res = _FAIL;
goto exit;
}
@@ -918,7 +918,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else {
set_stakey_hdl(padapter, (u8 *)psetstakey_para);
- kfree(psetstakey_para);
+ kfree_sensitive(psetstakey_para);
}
exit:
return res;
@@ -958,7 +958,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
psetstakey_rsp = kzalloc_obj(*psetstakey_rsp);
if (!psetstakey_rsp) {
kfree(ph2c);
- kfree(psetstakey_para);
+ kfree_sensitive(psetstakey_para);
res = _FAIL;
goto exit;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] staging: rtl8723bs: use kfree_sensitive() for key material
2026-07-13 23:34 [PATCH] staging: rtl8723bs: use kfree_sensitive() for key material Ivy Lopez
@ 2026-07-13 23:37 ` Ivy Lopez
2026-07-15 14:09 ` Greg KH
2026-07-14 7:20 ` Dan Carpenter
1 sibling, 1 reply; 5+ messages in thread
From: Ivy Lopez @ 2026-07-13 23:37 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel, Ivy Lopez
The set_stakey_parm struct contains a 16-byte encryption key.
Use kfree_sensitive() instead of kfree() to ensure the key
material is zeroed before the memory is freed, preventing
potential information leaks.
Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index b932670f5d63..a34ee407285b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -899,7 +899,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
if (enqueue) {
ph2c = kzalloc_obj(*ph2c);
if (!ph2c) {
- kfree(psetstakey_para);
+ kfree_sensitive(psetstakey_para);
res = _FAIL;
goto exit;
}
@@ -907,7 +907,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
psetstakey_rsp = kzalloc_obj(*psetstakey_rsp);
if (!psetstakey_rsp) {
kfree(ph2c);
- kfree(psetstakey_para);
+ kfree_sensitive(psetstakey_para);
res = _FAIL;
goto exit;
}
@@ -918,7 +918,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else {
set_stakey_hdl(padapter, (u8 *)psetstakey_para);
- kfree(psetstakey_para);
+ kfree_sensitive(psetstakey_para);
}
exit:
return res;
@@ -958,7 +958,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
psetstakey_rsp = kzalloc_obj(*psetstakey_rsp);
if (!psetstakey_rsp) {
kfree(ph2c);
- kfree(psetstakey_para);
+ kfree_sensitive(psetstakey_para);
res = _FAIL;
goto exit;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: rtl8723bs: use kfree_sensitive() for key material
2026-07-13 23:34 [PATCH] staging: rtl8723bs: use kfree_sensitive() for key material Ivy Lopez
2026-07-13 23:37 ` Ivy Lopez
@ 2026-07-14 7:20 ` Dan Carpenter
2026-07-14 21:20 ` Ivy Lopez
1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2026-07-14 7:20 UTC (permalink / raw)
To: Ivy Lopez; +Cc: gregkh, linux-staging, linux-kernel
On Mon, Jul 13, 2026 at 05:34:01PM -0600, Ivy Lopez wrote:
> The set_stakey_parm struct contains a 16-byte encryption key.
> Use kfree_sensitive() instead of kfree() to ensure the key
> material is zeroed before the memory is freed, preventing
> potential information leaks.
>
> Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
> ---
> drivers/net/ethernet/faraday/ftmac100.c | 47 +++++-------------------
> drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 ++--
> 2 files changed, 13 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
> index 5803a382f0ba..adb318925f44 100644
> --- a/drivers/net/ethernet/faraday/ftmac100.c
> +++ b/drivers/net/ethernet/faraday/ftmac100.c
> @@ -49,7 +49,6 @@ struct ftmac100_descs {
> };
>
> struct ftmac100 {
> - struct resource *res;
> void __iomem *base;
> int irq;
>
> @@ -1137,11 +1136,9 @@ static int ftmac100_probe(struct platform_device *pdev)
> return irq;
>
> /* setup net_device */
> - netdev = alloc_etherdev(sizeof(*priv));
> - if (!netdev) {
> - err = -ENOMEM;
> - goto err_alloc_etherdev;
> - }
> + netdev = devm_alloc_etherdev(&pdev->dev, sizeof(*priv));
> + if (!netdev)
> + return -ENOMEM;
This is unrelated...
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: rtl8723bs: use kfree_sensitive() for key material
2026-07-14 7:20 ` Dan Carpenter
@ 2026-07-14 21:20 ` Ivy Lopez
0 siblings, 0 replies; 5+ messages in thread
From: Ivy Lopez @ 2026-07-14 21:20 UTC (permalink / raw)
To: error27; +Cc: gregkh, linux-staging, linux-kernel
Thanks for the review. I noticed the same issue. v2 of this patch
fixes it and contains only the rtl8723bs change. Apologies for the
noise
Ivy Lopez <skunkolee@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: rtl8723bs: use kfree_sensitive() for key material
2026-07-13 23:37 ` Ivy Lopez
@ 2026-07-15 14:09 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2026-07-15 14:09 UTC (permalink / raw)
To: Ivy Lopez; +Cc: linux-staging, linux-kernel
On Mon, Jul 13, 2026 at 05:37:53PM -0600, Ivy Lopez wrote:
> The set_stakey_parm struct contains a 16-byte encryption key.
> Use kfree_sensitive() instead of kfree() to ensure the key
> material is zeroed before the memory is freed, preventing
> potential information leaks.
>
> Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
> ---
> drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> index b932670f5d63..a34ee407285b 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
> @@ -899,7 +899,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
> if (enqueue) {
> ph2c = kzalloc_obj(*ph2c);
> if (!ph2c) {
> - kfree(psetstakey_para);
> + kfree_sensitive(psetstakey_para);
> res = _FAIL;
> goto exit;
> }
> @@ -907,7 +907,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
> psetstakey_rsp = kzalloc_obj(*psetstakey_rsp);
> if (!psetstakey_rsp) {
> kfree(ph2c);
> - kfree(psetstakey_para);
> + kfree_sensitive(psetstakey_para);
> res = _FAIL;
> goto exit;
> }
> @@ -918,7 +918,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
> res = rtw_enqueue_cmd(pcmdpriv, ph2c);
> } else {
> set_stakey_hdl(padapter, (u8 *)psetstakey_para);
> - kfree(psetstakey_para);
> + kfree_sensitive(psetstakey_para);
> }
> exit:
> return res;
> @@ -958,7 +958,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
> psetstakey_rsp = kzalloc_obj(*psetstakey_rsp);
> if (!psetstakey_rsp) {
> kfree(ph2c);
> - kfree(psetstakey_para);
> + kfree_sensitive(psetstakey_para);
> res = _FAIL;
> goto exit;
> }
> --
> 2.55.0
>
>
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:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/process/submitting-patches.rst for what
needs to be done here to properly describe this.
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-15 14:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13 23:34 [PATCH] staging: rtl8723bs: use kfree_sensitive() for key material Ivy Lopez
2026-07-13 23:37 ` Ivy Lopez
2026-07-15 14:09 ` Greg KH
2026-07-14 7:20 ` Dan Carpenter
2026-07-14 21:20 ` Ivy Lopez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox