@@ -378,6 +378,7 @@ impl Thread {
378
378
index_offset : usize ,
379
379
alloc : & Allocation ,
380
380
view : & AllocationView ,
381
+ allow_fds : bool ,
381
382
) -> BinderResult {
382
383
let offset = alloc. read ( index_offset) ?;
383
384
let header = view. read :: < bindings:: binder_object_header > ( offset) ?;
@@ -403,15 +404,26 @@ impl Thread {
403
404
self . process . get_node_from_handle ( handle, strong)
404
405
} ) ?;
405
406
}
407
+ BINDER_TYPE_FD => {
408
+ if !allow_fds {
409
+ return Err ( BinderError :: new_failed ( ) ) ;
410
+ }
411
+ }
406
412
_ => pr_warn ! ( "Unsupported binder object type: {:x}\n " , header. type_) ,
407
413
}
408
414
Ok ( ( ) )
409
415
}
410
416
411
- fn translate_objects ( & self , alloc : & mut Allocation , start : usize , end : usize ) -> BinderResult {
417
+ fn translate_objects (
418
+ & self ,
419
+ alloc : & mut Allocation ,
420
+ start : usize ,
421
+ end : usize ,
422
+ allow_fds : bool ,
423
+ ) -> BinderResult {
412
424
let view = AllocationView :: new ( & alloc, start) ;
413
425
for i in ( start..end) . step_by ( size_of :: < usize > ( ) ) {
414
- if let Err ( err) = self . translate_object ( i, alloc, & view) {
426
+ if let Err ( err) = self . translate_object ( i, alloc, & view, allow_fds ) {
415
427
alloc. set_info ( AllocationInfo { offsets : start..i } ) ;
416
428
return Err ( err) ;
417
429
}
@@ -426,6 +438,7 @@ impl Thread {
426
438
& self ,
427
439
to_process : & ' a Process ,
428
440
tr : & BinderTransactionData ,
441
+ allow_fds : bool ,
429
442
) -> BinderResult < Allocation < ' a > > {
430
443
let data_size = tr. data_size as _ ;
431
444
let adata_size = ptr_align ( data_size) ;
@@ -450,7 +463,12 @@ impl Thread {
450
463
alloc. copy_into ( & mut reader, adata_size, offsets_size) ?;
451
464
452
465
// Traverse the objects specified.
453
- self . translate_objects ( & mut alloc, adata_size, adata_size + aoffsets_size) ?;
466
+ self . translate_objects (
467
+ & mut alloc,
468
+ adata_size,
469
+ adata_size + aoffsets_size,
470
+ allow_fds,
471
+ ) ?;
454
472
}
455
473
456
474
Ok ( alloc)
@@ -540,7 +558,8 @@ impl Thread {
540
558
( || -> BinderResult < _ > {
541
559
let completion = Arc :: try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE ) ) ?;
542
560
let process = orig. from . process . clone ( ) ;
543
- let reply = Arc :: try_new ( Transaction :: new_reply ( self , process, tr) ?) ?;
561
+ let allow_fds = orig. flags & TF_ACCEPT_FDS != 0 ;
562
+ let reply = Arc :: try_new ( Transaction :: new_reply ( self , process, tr, allow_fds) ?) ?;
544
563
self . inner . lock ( ) . push_work ( completion) ;
545
564
orig. from . deliver_reply ( Either :: Left ( reply) , & orig) ;
546
565
Ok ( ( ) )
0 commit comments