Message ID | 20180205151745.29292-1-msrb@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Quoting Michal Srb (2018-02-05 15:17:45) > The command MEDIA_VFE_STATE checks bits at offset +2 dwords. However, it is > possible to have MEDIA_VFE_STATE command with length = 0 + LENGTH_BIAS = 2. > In that case check_cmd will read bits from the following command, or even past > the end of the buffer. > > If the offset ends up outside of the command length, reject the command. > > Signed-off-by: Michal Srb <msrb@suse.com> Looks good, both Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> I'll resend them to intel-gfx@ so CI picks them up for the checklist. -Chris
Quoting Chris Wilson (2018-02-05 16:04:25) > Quoting Michal Srb (2018-02-05 15:17:45) > > The command MEDIA_VFE_STATE checks bits at offset +2 dwords. However, it is > > possible to have MEDIA_VFE_STATE command with length = 0 + LENGTH_BIAS = 2. > > In that case check_cmd will read bits from the following command, or even past > > the end of the buffer. > > > > If the offset ends up outside of the command length, reject the command. > > > > Signed-off-by: Michal Srb <msrb@suse.com> > > Looks good, both > Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> > > I'll resend them to intel-gfx@ so CI picks them up for the checklist. Added Fixes: 76ff480ec963 ("drm/i915/cmdparser: Use binary search for faster register lookup" and Fixes: 351e3db2b363 ("drm/i915: Implement command buffer parsing logic") respectively and pushed. Thanks for the patches, -Chris
diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c index de7ec59433d1..ef7ad016d67c 100644 --- a/drivers/gpu/drm/i915/i915_cmd_parser.c +++ b/drivers/gpu/drm/i915/i915_cmd_parser.c @@ -1218,6 +1218,12 @@ static bool check_cmd(const struct intel_engine_cs *engine, continue; } + if (desc->bits[i].offset >= length) { + DRM_DEBUG_DRIVER("CMD: Rejected command 0x%08X, too short to check bitmask (%s)\n", + *cmd, engine->name); + return false; + } + dword = cmd[desc->bits[i].offset] & desc->bits[i].mask;
The command MEDIA_VFE_STATE checks bits at offset +2 dwords. However, it is possible to have MEDIA_VFE_STATE command with length = 0 + LENGTH_BIAS = 2. In that case check_cmd will read bits from the following command, or even past the end of the buffer. If the offset ends up outside of the command length, reject the command. Signed-off-by: Michal Srb <msrb@suse.com> --- v2: Return false instead of continuing - reject the command instead of ignoring. drivers/gpu/drm/i915/i915_cmd_parser.c | 6 ++++++ 1 file changed, 6 insertions(+)