2 * SPDX-License-Identifier: MIT
4 * Copyright © 2018 Intel Corporation
7 #include <linux/nospec.h>
8 #include <linux/sched/signal.h>
9 #include <linux/uaccess.h>
11 #include <uapi/drm/i915_drm.h>
13 #include "i915_user_extensions.h"
14 #include "i915_utils.h"
16 int i915_user_extensions(struct i915_user_extension __user
*ext
,
17 const i915_user_extension_fn
*tbl
,
21 unsigned int stackdepth
= 512;
28 if (!stackdepth
--) /* recursion vs useful flexibility */
31 err
= check_user_mbz(&ext
->flags
);
35 for (i
= 0; i
< ARRAY_SIZE(ext
->rsvd
); i
++) {
36 err
= check_user_mbz(&ext
->rsvd
[i
]);
41 if (get_user(name
, &ext
->name
))
46 name
= array_index_nospec(name
, count
);
48 err
= tbl
[name
](ext
, data
);
53 if (get_user(next
, &ext
->next_extension
) ||
54 overflows_type(next
, ext
))
57 ext
= u64_to_user_ptr(next
);