Skip to content

Commit a27bb4b

Browse files
marekolsakairlied
authored andcommitted
drm/radeon/kms: do bounds checking for 3D_LOAD_VBPNTR and bump array limit
To my knowledge, the limit is 16 on r300. (the docs don't say what the limit is) The lack of bounds checking can be abused to do all sorts of things (from bypassing parts of the CS checker to crashing the kernel). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=36745 Cc: stable@kernel.org Signed-off-by: Marek Olšák <maraeo@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent ab21e60 commit a27bb4b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎drivers/gpu/drm/radeon/r100_track.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct r100_cs_track {
6363
unsigned num_arrays;
6464
unsigned max_indx;
6565
unsigned color_channel_mask;
66-
struct r100_cs_track_array arrays[11];
66+
struct r100_cs_track_array arrays[16];
6767
struct r100_cs_track_cb cb[R300_MAX_CB];
6868
struct r100_cs_track_cb zb;
6969
struct r100_cs_track_cb aa;
@@ -146,6 +146,12 @@ static inline int r100_packet3_load_vbpntr(struct radeon_cs_parser *p,
146146
ib = p->ib->ptr;
147147
track = (struct r100_cs_track *)p->track;
148148
c = radeon_get_ib_value(p, idx++) & 0x1F;
149+
if (c > 16) {
150+
DRM_ERROR("Only 16 vertex buffers are allowed %d\n",
151+
pkt->opcode);
152+
r100_cs_dump_packet(p, pkt);
153+
return -EINVAL;
154+
}
149155
track->num_arrays = c;
150156
for (i = 0; i < (c - 1); i+=2, idx+=3) {
151157
r = r100_cs_packet_next_reloc(p, &reloc);

0 commit comments

Comments
 (0)