Commit 12f15d5
drm: Do not allow userspace to trigger kernel warnings in drm_gem_change_handle_ioctl()
Since GEM bo handles are u32 in the uapi and the internal implementation
uses idr_alloc() which uses int ranges, passing a new handle larger than
INT_MAX trivially triggers a kernel warning:
idr_alloc():
...
if (WARN_ON_ONCE(start < 0))
return -EINVAL;
...
Fix it by rejecting new handles above INT_MAX and at the same time make
the end limit calculation more obvious by moving into int domain.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Reported-by: Zhi Wang <wangzhi@stu.xidian.edu.cn>
Fixes: 5309672 ("drm: Add DRM prime interface to reassign GEM handle")
Cc: David Francis <David.Francis@amd.com>
Cc: Felix Kuehling <felix.kuehling@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: <stable@vger.kernel.org> # v6.18+
Tested-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net>
Link: https://lore.kernel.org/r/20260123141540.76540-1-tvrtko.ursulin@igalia.com1 parent 0a095b6 commit 12f15d5
1 file changed
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
960 | 960 | | |
961 | 961 | | |
962 | 962 | | |
963 | | - | |
| 963 | + | |
964 | 964 | | |
965 | 965 | | |
966 | 966 | | |
967 | 967 | | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
968 | 973 | | |
969 | 974 | | |
970 | 975 | | |
971 | 976 | | |
972 | | - | |
| 977 | + | |
973 | 978 | | |
974 | 979 | | |
975 | 980 | | |
976 | 981 | | |
977 | 982 | | |
978 | 983 | | |
979 | 984 | | |
980 | | - | |
981 | | - | |
| 985 | + | |
| 986 | + | |
982 | 987 | | |
983 | 988 | | |
984 | 989 | | |
985 | 990 | | |
986 | 991 | | |
987 | 992 | | |
988 | | - | |
| 993 | + | |
| 994 | + | |
989 | 995 | | |
990 | 996 | | |
991 | | - | |
| 997 | + | |
992 | 998 | | |
993 | 999 | | |
994 | 1000 | | |
| |||
0 commit comments