mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tee: optee: allocate a bitmap for all valid notification keys
@ 2026-10-10  3:19 Amirreza Zarrabi
  2026-10-19 11:48 ` Sumit Garg
  0 siblings, 1 reply; 2+ messages in thread
From: Amirreza Zarrabi @ 2026-10-10  3:19 UTC (permalink / raw)
  To: Jens Wiklander, Sumit Garg
  Cc: linux-arm-msm, op-tee, linux-kernel, Amirreza Zarrabi

Notification keys are checked against an inclusive maximum, but
optee_notif_init() passes that maximum to bitmap_zalloc() as the number of
bits. The bitmap is therefore one bit short. When the maximum key is a
multiple of BITS_PER_LONG, accessing that key reads or writes beyond the
allocated bitmap. Word rounding masks the problem.

Allocate max_key + 1 bits so that the highest valid key has storage.

Fixes: 787c80cc7b22 ("optee: separate notification functions")
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
---
 drivers/tee/optee/notif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c
index 68014222d7be..2bf5ce397233 100644
--- a/drivers/tee/optee/notif.c
+++ b/drivers/tee/optee/notif.c
@@ -114,7 +114,7 @@ int optee_notif_init(struct optee *optee, u_int max_key)
 {
 	spin_lock_init(&optee->notif.lock);
 	INIT_LIST_HEAD(&optee->notif.db);
-	optee->notif.bitmap = bitmap_zalloc(max_key, GFP_KERNEL);
+	optee->notif.bitmap = bitmap_zalloc(max_key + 1, GFP_KERNEL);
 	if (!optee->notif.bitmap)
 		return -ENOMEM;
 

---
base-commit: becb95e45ef0dda9ffb35156d909d3da7a2789c3
change-id: 20261009-fix-tee-max-keys-50f2db87b4e5

Best regards,
-- 
Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>


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

* Re: [PATCH] tee: optee: allocate a bitmap for all valid notification keys
  2026-10-10  3:19 [PATCH] tee: optee: allocate a bitmap for all valid notification keys Amirreza Zarrabi
@ 2026-10-19 11:48 ` Sumit Garg
  0 siblings, 0 replies; 2+ messages in thread
From: Sumit Garg @ 2026-10-19 11:48 UTC (permalink / raw)
  To: Amirreza Zarrabi
  Cc: Jens Wiklander, Sumit Garg, linux-arm-msm, op-tee, linux-kernel

On Fri, 09 Oct 2026 at 20:19:48 -0700, Amirreza Zarrabi wrote:
>Notification keys are checked against an inclusive maximum, but
>optee_notif_init() passes that maximum to bitmap_zalloc() as the number of
>bits. The bitmap is therefore one bit short. When the maximum key is a
>multiple of BITS_PER_LONG, accessing that key reads or writes beyond the
>allocated bitmap. Word rounding masks the problem.
>
>Allocate max_key + 1 bits so that the highest valid key has storage.
>
>Fixes: 787c80cc7b22 ("optee: separate notification functions")
>Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
>---
> drivers/tee/optee/notif.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>

-Sumit

>
>diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c
>index 68014222d7be..2bf5ce397233 100644
>--- a/drivers/tee/optee/notif.c
>+++ b/drivers/tee/optee/notif.c
>@@ -114,7 +114,7 @@ int optee_notif_init(struct optee *optee, u_int max_key)
> {
> 	spin_lock_init(&optee->notif.lock);
> 	INIT_LIST_HEAD(&optee->notif.db);
>-	optee->notif.bitmap = bitmap_zalloc(max_key, GFP_KERNEL);
>+	optee->notif.bitmap = bitmap_zalloc(max_key + 1, GFP_KERNEL);
> 	if (!optee->notif.bitmap)
> 		return -ENOMEM;
>
>
>---
>base-commit: becb95e45ef0dda9ffb35156d909d3da7a2789c3
>change-id: 20261009-fix-tee-max-keys-50f2db87b4e5
>
>Best regards,
>-- 
>Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
>

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

end of thread, other threads:[~2026-10-19 11:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10  3:19 [PATCH] tee: optee: allocate a bitmap for all valid notification keys Amirreza Zarrabi
2026-10-19 11:48 ` Sumit Garg

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

all inboxes | Powered by JetHome®