On Mon, Nov 04, 2024 at 04:36:09PM +0100, Steffen Eiden wrote: > Enable the list IOCTL to provide lists longer than one page (85 entries). > The list IOCTL now accepts any argument length in page granularity. > It fills the argument up to this length with entries until the list > ends. User space unaware of this enhancement will still receive one page > of data and an uv_rc 0x0100. > > Signed-off-by: Steffen Eiden <seiden@xxxxxxxxxxxxx> > --- > v3: remove upper boundary (8 pages) for arg len ... > +static int uvio_get_list(void *zpage, struct uvio_ioctl_cb *uv_ioctl) > +{ > + const size_t data_off = offsetof(struct uv_secret_list, secrets); > + u8 __user *user_buf = (u8 __user *)uv_ioctl->argument_addr; > + struct uv_secret_list *list = zpage; > + u16 num_secrets_stored = 0; > + size_t user_off = data_off; > + size_t copy_len; > + > + do { > + uv_list_secrets(list, list->next_secret_idx, &uv_ioctl->uv_rc, > + &uv_ioctl->uv_rrc); > + if (uv_ioctl->uv_rc != UVC_RC_EXECUTED && > + uv_ioctl->uv_rc != UVC_RC_MORE_DATA) > + break; > + > + copy_len = sizeof(list->secrets[0]) * list->num_secr_stored; > + WARN_ON(copy_len > sizeof(list->secrets)); Is this really possible? Without checking the documentation I guess this is not possible and therefore the WARN_ON() should be removed. If however this can be possible then this should be turned into a WARN_ON_ONCE(). > + if (copy_to_user(user_buf + user_off, list->secrets, copy_len)) > + return -EFAULT; ...and in addition, if the above would be possible this _could_ copy random kernel data to user space. Not good.