Skip to contentSkip to conversation

argo: don't leak stack contents when returning ring info

PATCH In review Jan Beulich 2 participants 3 messages Jan 14, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 argo: don't leak stack contents when returning ring info

The max_message_size field of the output gets filled only when the flags field is non-zero. Don't copy back uninitialized data to guest context.

xen/common/argo.c +2 -1
@@ -1405,7 +1405,8 @@ fill_ring_data(const struct domain *curr
         rcu_unlock_domain(dst_d);
 
     if ( !ret && (__copy_field_to_guest(data_ent_hnd, &ent, flags) ||
-                  __copy_field_to_guest(data_ent_hnd, &ent, max_message_size)) )
+                  (ent.flags &&
+                   __copy_field_to_guest(data_ent_hnd, &ent, max_message_size))) )
         return -EFAULT;
 
     return ret;
#1 lore raw
Quoted 2 lines · Jan Beulich

The max_message_size field of the output gets filled only when the flags field is non-zero. Don't copy back uninitialized data to guest context.

I'm afraid I'm missing something. AFAICT ent gets filled from the user-space contents of data_ent_hnd that's copied from user-space at the top of the function, so there's no leak from hypervisor stack in the return path?

Thanks, Roger.

#2 lore raw
Quoted 7 lines · Roger Pau Monné
Quoted 2 lines · Jan Beulich

The max_message_size field of the output gets filled only when the flags field is non-zero. Don't copy back uninitialized data to guest context.

I'm afraid I'm missing something. AFAICT ent gets filled from the user-space contents of data_ent_hnd that's copied from user-space at the top of the function,

Oh, I managed to overlook this multiple time, so ...

Quoted 2 lines

so there's no leak from hypervisor stack in
the return path?

... yes indeed. Withdrawing the patch.

Thanks for noticing,
Jan