Lines Matching refs:o

78 						     struct tee_obj *o)  in tee_svc_storage_remove_corrupt_obj()  argument
80 o->pobj->fops->remove(o->pobj); in tee_svc_storage_remove_corrupt_obj()
81 tee_obj_close(to_user_ta_ctx(sess->ctx), o); in tee_svc_storage_remove_corrupt_obj()
86 static TEE_Result tee_svc_storage_read_head(struct tee_obj *o) in tee_svc_storage_read_head() argument
91 const struct tee_file_operations *fops = o->pobj->fops; in tee_svc_storage_read_head()
96 assert(!o->fh); in tee_svc_storage_read_head()
97 res = fops->open(o->pobj, &size, &o->fh); in tee_svc_storage_read_head()
103 res = fops->read(o->fh, 0, &head, &bytes); in tee_svc_storage_read_head()
124 res = tee_obj_set_type(o, head.objectType, head.maxObjectSize); in tee_svc_storage_read_head()
128 o->ds_pos = tmp; in tee_svc_storage_read_head()
139 res = fops->read(o->fh, sizeof(struct tee_svc_storage_head), in tee_svc_storage_read_head()
149 res = tee_obj_attr_from_binary(o, attr, head.attr_size); in tee_svc_storage_read_head()
153 o->info.dataSize = size - sizeof(head) - head.attr_size; in tee_svc_storage_read_head()
154 o->info.objectSize = head.objectSize; in tee_svc_storage_read_head()
155 o->info.objectUsage = head.objectUsage; in tee_svc_storage_read_head()
156 o->info.objectType = head.objectType; in tee_svc_storage_read_head()
157 o->have_attrs = head.have_attrs; in tee_svc_storage_read_head()
180 struct tee_obj *o = NULL; in syscall_storage_obj_open() local
209 o = tee_obj_alloc(); in syscall_storage_obj_open()
210 if (o == NULL) { in syscall_storage_obj_open()
216 o->info.handleFlags = TEE_HANDLE_FLAG_PERSISTENT | in syscall_storage_obj_open()
218 o->pobj = po; in syscall_storage_obj_open()
219 tee_obj_add(utc, o); in syscall_storage_obj_open()
221 res = tee_svc_storage_read_head(o); in syscall_storage_obj_open()
230 res = copy_kaddr_to_uref(obj, o); in syscall_storage_obj_open()
237 tee_obj_close(utc, o); in syscall_storage_obj_open()
238 o = NULL; in syscall_storage_obj_open()
243 if (res == TEE_ERROR_CORRUPT_OBJECT && o) in syscall_storage_obj_open()
244 tee_svc_storage_remove_corrupt_obj(sess, o); in syscall_storage_obj_open()
250 static TEE_Result tee_svc_storage_init_file(struct tee_obj *o, bool overwrite, in tee_svc_storage_init_file() argument
256 const struct tee_file_operations *fops = o->pobj->fops; in tee_svc_storage_init_file()
261 res = tee_obj_set_type(o, attr_o->info.objectType, in tee_svc_storage_init_file()
265 res = tee_obj_attr_copy_from(o, attr_o); in tee_svc_storage_init_file()
268 o->have_attrs = attr_o->have_attrs; in tee_svc_storage_init_file()
269 o->info.objectUsage = attr_o->info.objectUsage; in tee_svc_storage_init_file()
270 o->info.objectSize = attr_o->info.objectSize; in tee_svc_storage_init_file()
271 res = tee_obj_attr_to_binary(o, NULL, &attr_size); in tee_svc_storage_init_file()
278 res = tee_obj_attr_to_binary(o, attr, &attr_size); in tee_svc_storage_init_file()
283 res = tee_obj_set_type(o, TEE_TYPE_DATA, 0); in tee_svc_storage_init_file()
288 o->ds_pos = sizeof(struct tee_svc_storage_head) + attr_size; in tee_svc_storage_init_file()
292 head.objectSize = o->info.objectSize; in tee_svc_storage_init_file()
293 head.maxObjectSize = o->info.maxObjectSize; in tee_svc_storage_init_file()
294 head.objectUsage = o->info.objectUsage; in tee_svc_storage_init_file()
295 head.objectType = o->info.objectType; in tee_svc_storage_init_file()
296 head.have_attrs = o->have_attrs; in tee_svc_storage_init_file()
298 res = fops->create(o->pobj, overwrite, &head, sizeof(head), attr, in tee_svc_storage_init_file()
299 attr_size, data, len, &o->fh); in tee_svc_storage_init_file()
302 o->info.dataSize = len; in tee_svc_storage_init_file()
326 struct tee_obj *o = NULL; in syscall_storage_obj_create() local
370 o = tee_obj_alloc(); in syscall_storage_obj_create()
371 if (o == NULL) { in syscall_storage_obj_create()
376 o->info.handleFlags = TEE_HANDLE_FLAG_PERSISTENT | in syscall_storage_obj_create()
378 o->pobj = po; in syscall_storage_obj_create()
391 res = tee_svc_storage_init_file(o, flags & TEE_DATA_FLAG_OVERWRITE, in syscall_storage_obj_create()
397 tee_obj_add(utc, o); in syscall_storage_obj_create()
399 res = copy_kaddr_to_uref(obj, o); in syscall_storage_obj_create()
403 tee_pobj_create_final(o->pobj); in syscall_storage_obj_create()
407 tee_obj_close(utc, o); in syscall_storage_obj_create()
415 if (o) { in syscall_storage_obj_create()
416 fops->close(&o->fh); in syscall_storage_obj_create()
417 tee_obj_free(o); in syscall_storage_obj_create()
430 struct tee_obj *o = NULL; in syscall_storage_obj_del() local
432 res = tee_obj_get(utc, uref_to_vaddr(obj), &o); in syscall_storage_obj_del()
436 if (!(o->info.handleFlags & TEE_DATA_FLAG_ACCESS_WRITE_META)) in syscall_storage_obj_del()
439 if (o->pobj == NULL || o->pobj->obj_id == NULL) in syscall_storage_obj_del()
444 res = crypto_storage_obj_del(o); in syscall_storage_obj_del()
449 res = o->pobj->fops->remove(o->pobj); in syscall_storage_obj_del()
450 tee_obj_close(utc, o); in syscall_storage_obj_del()
463 struct tee_obj *o = NULL; in syscall_storage_obj_rename() local
470 res = tee_obj_get(utc, uref_to_vaddr(obj), &o); in syscall_storage_obj_rename()
474 if (!(o->info.handleFlags & TEE_HANDLE_FLAG_PERSISTENT)) { in syscall_storage_obj_rename()
479 if (!(o->info.handleFlags & TEE_DATA_FLAG_ACCESS_WRITE_META)) { in syscall_storage_obj_rename()
484 if (o->pobj == NULL || o->pobj->obj_id == NULL) { in syscall_storage_obj_rename()
498 fops = o->pobj->fops; in syscall_storage_obj_rename()
506 res = fops->rename(o->pobj, po, false /* no overwrite */); in syscall_storage_obj_rename()
510 res = tee_pobj_rename(o->pobj, object_id, object_id_len); in syscall_storage_obj_rename()
613 struct tee_obj *o = NULL; in syscall_storage_next_enum() local
643 o = tee_obj_alloc(); in syscall_storage_next_enum()
644 if (o == NULL) { in syscall_storage_next_enum()
650 TEE_POBJ_USAGE_ENUM, e->fops, &o->pobj); in syscall_storage_next_enum()
654 o->info.handleFlags = o->pobj->flags | TEE_HANDLE_FLAG_PERSISTENT | in syscall_storage_next_enum()
657 res = tee_svc_storage_read_head(o); in syscall_storage_next_enum()
662 .obj_type = o->info.objectType, in syscall_storage_next_enum()
663 .obj_size = o->info.objectSize, in syscall_storage_next_enum()
664 .max_obj_size = o->info.maxObjectSize, in syscall_storage_next_enum()
665 .obj_usage = o->info.objectUsage, in syscall_storage_next_enum()
666 .data_size = o->info.dataSize, in syscall_storage_next_enum()
667 .data_pos = o->info.dataPosition, in syscall_storage_next_enum()
668 .handle_flags = o->info.handleFlags, in syscall_storage_next_enum()
670 memcpy(obj_id, o->pobj->obj_id, o->pobj->obj_id_len); in syscall_storage_next_enum()
672 l = o->pobj->obj_id_len; in syscall_storage_next_enum()
676 if (o) { in syscall_storage_next_enum()
677 if (o->pobj) { in syscall_storage_next_enum()
678 o->pobj->fops->close(&o->fh); in syscall_storage_next_enum()
679 tee_pobj_release(o->pobj); in syscall_storage_next_enum()
681 tee_obj_free(o); in syscall_storage_next_enum()
693 struct tee_obj *o = NULL; in syscall_storage_obj_read() local
698 res = tee_obj_get(utc, uref_to_vaddr(obj), &o); in syscall_storage_obj_read()
702 if (!(o->info.handleFlags & TEE_HANDLE_FLAG_PERSISTENT)) { in syscall_storage_obj_read()
707 if (!(o->info.handleFlags & TEE_DATA_FLAG_ACCESS_READ)) { in syscall_storage_obj_read()
713 if (ADD_OVERFLOW(o->info.dataPosition, len, &pos_tmp)) { in syscall_storage_obj_read()
726 if (ADD_OVERFLOW(o->ds_pos, o->info.dataPosition, &pos_tmp)) { in syscall_storage_obj_read()
730 res = o->pobj->fops->read(o->fh, pos_tmp, data, &bytes); in syscall_storage_obj_read()
734 tee_svc_storage_remove_corrupt_obj(sess, o); in syscall_storage_obj_read()
739 o->info.dataPosition += bytes; in syscall_storage_obj_read()
752 struct tee_obj *o = NULL; in syscall_storage_obj_write() local
755 res = tee_obj_get(utc, uref_to_vaddr(obj), &o); in syscall_storage_obj_write()
759 if (!(o->info.handleFlags & TEE_HANDLE_FLAG_PERSISTENT)) { in syscall_storage_obj_write()
764 if (!(o->info.handleFlags & TEE_DATA_FLAG_ACCESS_WRITE)) { in syscall_storage_obj_write()
770 if (ADD_OVERFLOW(o->info.dataPosition, len, &pos_tmp)) { in syscall_storage_obj_write()
782 if (ADD_OVERFLOW(o->ds_pos, o->info.dataPosition, &pos_tmp)) { in syscall_storage_obj_write()
786 res = o->pobj->fops->write(o->fh, pos_tmp, data, len); in syscall_storage_obj_write()
790 tee_svc_storage_remove_corrupt_obj(sess, o); in syscall_storage_obj_write()
795 o->info.dataPosition += len; in syscall_storage_obj_write()
796 if (o->info.dataPosition > o->info.dataSize) in syscall_storage_obj_write()
797 o->info.dataSize = o->info.dataPosition; in syscall_storage_obj_write()
807 struct tee_obj *o = NULL; in syscall_storage_obj_trunc() local
811 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_storage_obj_trunc()
815 if (!(o->info.handleFlags & TEE_HANDLE_FLAG_PERSISTENT)) { in syscall_storage_obj_trunc()
820 if (!(o->info.handleFlags & TEE_DATA_FLAG_ACCESS_WRITE)) { in syscall_storage_obj_trunc()
825 res = tee_obj_attr_to_binary(o, NULL, &attr_size); in syscall_storage_obj_trunc()
838 res = o->pobj->fops->truncate(o->fh, off); in syscall_storage_obj_trunc()
841 o->info.dataSize = len; in syscall_storage_obj_trunc()
845 (void)tee_svc_storage_remove_corrupt_obj(sess, o); in syscall_storage_obj_trunc()
861 struct tee_obj *o = NULL; in syscall_storage_obj_seek() local
864 res = tee_obj_get(to_user_ta_ctx(sess->ctx), uref_to_vaddr(obj), &o); in syscall_storage_obj_seek()
868 if (!(o->info.handleFlags & TEE_HANDLE_FLAG_PERSISTENT)) in syscall_storage_obj_seek()
876 if (ADD_OVERFLOW(o->info.dataPosition, offset, &new_pos)) in syscall_storage_obj_seek()
880 if (ADD_OVERFLOW(o->info.dataSize, offset, &new_pos)) in syscall_storage_obj_seek()
895 o->info.dataPosition = new_pos; in syscall_storage_obj_seek()