@@ -378,6 +378,7 @@ impl Thread {
378378 index_offset : usize ,
379379 alloc : & Allocation ,
380380 view : & AllocationView ,
381+ allow_fds : bool ,
381382 ) -> BinderResult {
382383 let offset = alloc. read ( index_offset) ?;
383384 let header = view. read :: < bindings:: binder_object_header > ( offset) ?;
@@ -403,15 +404,26 @@ impl Thread {
403404 self . process . get_node_from_handle ( handle, strong)
404405 } ) ?;
405406 }
407+ BINDER_TYPE_FD => {
408+ if !allow_fds {
409+ return Err ( BinderError :: new_failed ( ) ) ;
410+ }
411+ }
406412 _ => pr_warn ! ( "Unsupported binder object type: {:x}\n " , header. type_) ,
407413 }
408414 Ok ( ( ) )
409415 }
410416
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 {
412424 let view = AllocationView :: new ( & alloc, start) ;
413425 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 ) {
415427 alloc. set_info ( AllocationInfo { offsets : start..i } ) ;
416428 return Err ( err) ;
417429 }
@@ -426,6 +438,7 @@ impl Thread {
426438 & self ,
427439 to_process : & ' a Process ,
428440 tr : & BinderTransactionData ,
441+ allow_fds : bool ,
429442 ) -> BinderResult < Allocation < ' a > > {
430443 let data_size = tr. data_size as _ ;
431444 let adata_size = ptr_align ( data_size) ;
@@ -450,7 +463,12 @@ impl Thread {
450463 alloc. copy_into ( & mut reader, adata_size, offsets_size) ?;
451464
452465 // 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+ ) ?;
454472 }
455473
456474 Ok ( alloc)
@@ -540,7 +558,8 @@ impl Thread {
540558 ( || -> BinderResult < _ > {
541559 let completion = Arc :: try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE ) ) ?;
542560 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) ?) ?;
544563 self . inner . lock ( ) . push_work ( completion) ;
545564 orig. from . deliver_reply ( Either :: Left ( reply) , & orig) ;
546565 Ok ( ( ) )
0 commit comments