Skip to content

bounds checks for texture-buffer copies happen too late #2951

@jimblandy

Description

@jimblandy

Methods like command_encoder_copy_texture_to_buffer do check that ImageCopyTexture::mip_level field of their source and/or destination parameters is valid for the relevant texture, by calling validate_texture_copy_range. However, those checks occur after those functions have called TextureTracker::set_single, which assumes that the mip_level is in range.

The specific call chain is:

  • Global::command_encoder_copy_texture_to_buffer, or related
  • TextureTracker::set_single
  • wgpu_core::track::texture::insert_or_barrier_single
  • wgpu_core::track::texture::insert
  • ComplexTextureState::from_selector_state_iter

This last uses get_unchecked_mut on selector.mips.start.

cc @cwfitzgerald

Metadata

Metadata

Assignees

Labels

area: validationIssues related to validation, diagnostics, and error handlingtype: bugSomething isn't working

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions