Skip to content

Instantly share code, notes, and snippets.

@shkhln
Created July 3, 2020 02:52
Show Gist options
  • Save shkhln/12e11fb2980196a42d88ad032051c29b to your computer and use it in GitHub Desktop.
Save shkhln/12e11fb2980196a42d88ad032051c29b to your computer and use it in GitHub Desktop.
webcamd, compat32, evdev
diff --git a/kernel/linux_file.c b/kernel/linux_file.c
index a68291a..98cef0a 100644
--- kernel/linux_file.c
+++ kernel/linux_file.c
@@ -194,7 +194,14 @@ linux_read(struct cdev_handle *handle, int fflags, char *ptr, size_t len)
linux_fix_f_flags(&handle->fixed_file, fflags);
- error = handle->fixed_file.f_op->read(&handle->fixed_file, ptr, len, &off);
+ if (fflags & CUSE_FFLAG_COMPAT32) {
+ in_compat32_call = 1;
+ error = handle->fixed_file.f_op->read(&handle->fixed_file, ptr, len, &off);
+ in_compat32_call = 0;
+ // compat_free_all_user_space()?
+ } else {
+ error = handle->fixed_file.f_op->read(&handle->fixed_file, ptr, len, &off);
+ }
return (error);
}
diff --git a/webcamd.c b/webcamd.c
index cf3c43a..8431a85 100644
--- webcamd.c
+++ webcamd.c
@@ -247,7 +247,7 @@ v4b_read(struct cuse_dev *cdev, int fflags,
handle = cuse_dev_get_per_file_handle(cdev);
/* read from device */
- error = linux_read(handle, fflags & CUSE_FFLAG_NONBLOCK, peer_ptr, len);
+ error = linux_read(handle, fflags & (CUSE_FFLAG_NONBLOCK | CUSE_FFLAG_COMPAT32), peer_ptr, len);
return (v4b_convert_error(error));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment