Commit ae8831e
drm: Do not allow userspace to trigger kernel warnings in drm_gem_change_handle_ioctl()
commit 12f15d5 upstream.
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.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent dd222df commit ae8831e
1 file changed
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
970 | 970 | | |
971 | 971 | | |
972 | 972 | | |
973 | | - | |
| 973 | + | |
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
978 | 983 | | |
979 | 984 | | |
980 | 985 | | |
981 | 986 | | |
982 | | - | |
| 987 | + | |
983 | 988 | | |
984 | 989 | | |
985 | 990 | | |
986 | 991 | | |
987 | 992 | | |
988 | 993 | | |
989 | 994 | | |
990 | | - | |
991 | | - | |
| 995 | + | |
| 996 | + | |
992 | 997 | | |
993 | 998 | | |
994 | 999 | | |
995 | 1000 | | |
996 | 1001 | | |
997 | 1002 | | |
998 | | - | |
| 1003 | + | |
| 1004 | + | |
999 | 1005 | | |
1000 | 1006 | | |
1001 | | - | |
| 1007 | + | |
1002 | 1008 | | |
1003 | 1009 | | |
1004 | 1010 | | |
| |||
0 commit comments