* [PATCH] w1: Use kfree_sensitive to clear sensitive information
@ 2022-12-22 22:39 Deepak R Varma
2023-01-07 20:11 ` Deepak R Varma
0 siblings, 1 reply; 3+ messages in thread
From: Deepak R Varma @ 2022-12-22 22:39 UTC (permalink / raw)
To: Evgeniy Polyakov, linux-kernel; +Cc: Saurabh Singh Sengar, Praveen Kumar, drv
Replace combination of 'memset(0) + kfree()' by kfree_sensitive() as it
prevents compiler from optimizing away from zeroing out memory at the
end of a scope. kfree_sensitive() is also safe in case the memory
pointer turns out to be null, which simply gets ignored.
Issue identified using kfree_sensitive.cocci coccinelle semantic patch.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
Note: proposed change is compile tested only.
drivers/w1/w1.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index f2ae2e563dc5..e08467e08b73 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -73,8 +73,7 @@ static void w1_master_release(struct device *dev)
struct w1_master *md = dev_to_w1_master(dev);
dev_dbg(dev, "%s: Releasing %s.\n", __func__, md->name);
- memset(md, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
- kfree(md);
+ kfree_sensitive(md);
}
static void w1_slave_release(struct device *dev)
@@ -805,9 +804,10 @@ int w1_unref_slave(struct w1_slave *sl)
w1_family_notify(BUS_NOTIFY_DEL_DEVICE, sl);
device_unregister(&sl->dev);
#ifdef DEBUG
- memset(sl, 0, sizeof(*sl));
- #endif
+ kfree_sensitive(sl);
+ #else
kfree(sl);
+ #endif
}
atomic_dec(&dev->refcnt);
mutex_unlock(&dev->list_mutex);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] w1: Use kfree_sensitive to clear sensitive information
2022-12-22 22:39 [PATCH] w1: Use kfree_sensitive to clear sensitive information Deepak R Varma
@ 2023-01-07 20:11 ` Deepak R Varma
2023-01-22 19:50 ` Deepak R Varma
0 siblings, 1 reply; 3+ messages in thread
From: Deepak R Varma @ 2023-01-07 20:11 UTC (permalink / raw)
To: Evgeniy Polyakov, linux-kernel
Cc: Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma
On Fri, Dec 23, 2022 at 04:09:22AM +0530, Deepak R Varma wrote:
> Replace combination of 'memset(0) + kfree()' by kfree_sensitive() as it
> prevents compiler from optimizing away from zeroing out memory at the
> end of a scope. kfree_sensitive() is also safe in case the memory
> pointer turns out to be null, which simply gets ignored.
>
> Issue identified using kfree_sensitive.cocci coccinelle semantic patch.
>
> Signed-off-by: Deepak R Varma <drv@mailo.com>
> ---
Hello,
Requesting a review and feedback on this patch proposal.
Thank you,
./drv
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] w1: Use kfree_sensitive to clear sensitive information
2023-01-07 20:11 ` Deepak R Varma
@ 2023-01-22 19:50 ` Deepak R Varma
0 siblings, 0 replies; 3+ messages in thread
From: Deepak R Varma @ 2023-01-22 19:50 UTC (permalink / raw)
To: Evgeniy Polyakov, linux-kernel; +Cc: Saurabh Singh Sengar, Praveen Kumar
On Sun, Jan 08, 2023 at 01:41:18AM +0530, Deepak R Varma wrote:
> On Fri, Dec 23, 2022 at 04:09:22AM +0530, Deepak R Varma wrote:
> > Replace combination of 'memset(0) + kfree()' by kfree_sensitive() as it
> > prevents compiler from optimizing away from zeroing out memory at the
> > end of a scope. kfree_sensitive() is also safe in case the memory
> > pointer turns out to be null, which simply gets ignored.
> >
> > Issue identified using kfree_sensitive.cocci coccinelle semantic patch.
> >
> > Signed-off-by: Deepak R Varma <drv@mailo.com>
> > ---
>
> Hello,
> Requesting a review and feedback on this patch proposal.
Hello,
Requesting a review and feedback on this patch proposal please.
Thank you,
./drv
>
> Thank you,
> ./drv
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-22 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-22 22:39 [PATCH] w1: Use kfree_sensitive to clear sensitive information Deepak R Varma
2023-01-07 20:11 ` Deepak R Varma
2023-01-22 19:50 ` Deepak R Varma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).