Skip to contentSkip to conversation

ta: avb: fix object leakage at lock state write

PATCH In review Ivan Khoronzhuk 2 participants 2 messages Jan 21, 2023 – Jan 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ta: avb: fix object leakage at lock state write

From: Ivan Khoronzhuk <[email protected]>

Should close object created for reading, so better use seek and then close the object.

Fixes b29b41950 ("ta: add AVB TA")
---
 ta/avb/entry.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
ta/avb/entry.c +5 -1
index 4e57003e..a6e01035 100644
@@ -239,7 +239,11 @@ static TEE_Result write_lock_state(uint32_t pt,
 	if (count == sizeof(lock_state) && lock_state == wlock_state)
 		goto out;
 
-	res = create_rb_state(wlock_state, &h);
+	res = TEE_SeekObjectData(h, 0, TEE_DATA_SEEK_SET);
+	if (res)
+		goto out;
+
+	res = TEE_WriteObjectData(h, &wlock_state, sizeof(wlock_state));
 out:
 	TEE_CloseObject(h);
 	return res;
Signature · 1 line
2.34.1
#1 lore raw

Hi Ivan,

Quoted 30 lines · Ivan Khoronzhuk

From: Ivan Khoronzhuk <[email protected]>

Should close object created for reading, so better use seek and then close the object.

Fixes b29b41950 ("ta: add AVB TA")
---
 ta/avb/entry.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
ta/avb/entry.c +5 -2
index 4e57003e..a6e01035 100644
@@ -239,7 +239,11 @@ static TEE_Result write_lock_state(uint32_t pt,
        if (count == sizeof(lock_state) && lock_state == wlock_state)
                goto out;
 
-       res = create_rb_state(wlock_state, &h);
+       res = TEE_SeekObjectData(h, 0, TEE_DATA_SEEK_SET);
+       if (res)
+               goto out;
+
+       res = TEE_WriteObjectData(h, &wlock_state, sizeof(wlock_state));
 out:
        TEE_CloseObject(h);
        return res;
--
Quoted 2 lines

2.34.1

The patch looks good. Would you mind opening a pull request at
https://github.com/OP-TEE/optee_os?

Cheers,
Jens