Skip to content

Commit

Permalink
drm/asahi: Check command structure sizes
Browse files Browse the repository at this point in the history
Eventually this can be used to extend the structure at the end
backwards-compatibly, for cases where we missed core fields in the UAPI.
More discrete features should be implemented via extensions.

Signed-off-by: Asahi Lina <[email protected]>
  • Loading branch information
asahilina committed Jan 17, 2024
1 parent db612a8 commit 5ccaf76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/gpu/drm/asahi/queue/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ impl super::Queue::ver {

mod_dev_dbg!(self.dev, "[Submission {}] Compute!\n", id);

if cmd.cmd_buffer_size as usize != core::mem::size_of::<uapi::drm_asahi_cmd_compute>() {
cls_pr_debug!(
Errors,
"Invalid compute command size ({:#x})\n",
cmd.cmd_buffer_size
);
return Err(EINVAL);
}

let mut cmdbuf_reader = unsafe {
UserSlicePtr::new(
cmd.cmd_buffer as usize as *mut _,
Expand Down
9 changes: 9 additions & 0 deletions drivers/gpu/drm/asahi/queue/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ impl super::Queue::ver {

mod_dev_dbg!(self.dev, "[Submission {}] Render!\n", id);

if cmd.cmd_buffer_size as usize != core::mem::size_of::<uapi::drm_asahi_cmd_render>() {
cls_pr_debug!(
Errors,
"Invalid render command size ({:#x})\n",
cmd.cmd_buffer_size
);
return Err(EINVAL);
}

let mut cmdbuf_reader = unsafe {
UserSlicePtr::new(
cmd.cmd_buffer as usize as *mut _,
Expand Down

0 comments on commit 5ccaf76

Please sign in to comment.