Skip to content

Commit 2c8cad7

Browse files
committed
drm/asahi: Check command structure sizes
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]>
1 parent abc9a00 commit 2c8cad7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/gpu/drm/asahi/queue/compute.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ impl super::Queue::ver {
5555

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

58+
if cmd.cmd_buffer_size as usize != core::mem::size_of::<uapi::drm_asahi_cmd_compute>() {
59+
cls_pr_debug!(
60+
Errors,
61+
"Invalid compute command size ({:#x})\n",
62+
cmd.cmd_buffer_size
63+
);
64+
return Err(EINVAL);
65+
}
66+
5867
let mut cmdbuf_reader = unsafe {
5968
UserSlicePtr::new(
6069
cmd.cmd_buffer as usize as *mut _,

drivers/gpu/drm/asahi/queue/render.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ impl super::Queue::ver {
222222

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

225+
if cmd.cmd_buffer_size as usize != core::mem::size_of::<uapi::drm_asahi_cmd_render>() {
226+
cls_pr_debug!(
227+
Errors,
228+
"Invalid render command size ({:#x})\n",
229+
cmd.cmd_buffer_size
230+
);
231+
return Err(EINVAL);
232+
}
233+
225234
let mut cmdbuf_reader = unsafe {
226235
UserSlicePtr::new(
227236
cmd.cmd_buffer as usize as *mut _,

0 commit comments

Comments
 (0)