Running select_linked_pick with a negative index crashes Blender with an access violation #89367

Closed
opened 2021-06-22 17:35:35 +02:00 by Fen · 6 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 446.14

Blender Version
Broken: version: 2.93.0, branch: master, commit date: 2021-06-02 11:21, hash: 84da05a8b8
Worked: 2.80 accepts an index argument but doesn't crash

Broken by: 211d7ff3cf
Worked: 65965a892f

Short description of error
bpy.ops.mesh.select_linked_pick accepts object_index and index arguments. They are set to -1 by default (probably indicating that they're not meant to be used). If object_index corresponds to an object in the scene and index is a negative number, Blender crashes.

Exact steps for others to reproduce the error

  1. Select the default cube and go into edit mode
  2. Open a Python console
  3. Run bpy.ops.mesh.select_linked_pick(object_index=0)
  4. Crash

Alternatively, you can provide any negative index value; it should always crash (although it might run into valid memory if you're lucky)

A debug build reports an access violation:

SUMMARY: AddressSanitizer: access-violation D:\blender-git\blender\source\blender\editors\mesh\editmesh_select.c:3451 in edbm_select_linked_pick_ex

Debug stack trace: P2202

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 446.14 **Blender Version** Broken: version: 2.93.0, branch: master, commit date: 2021-06-02 11:21, hash: `84da05a8b8` Worked: 2.80 accepts an `index` argument but doesn't crash Broken by: 211d7ff3cf Worked: 65965a892f **Short description of error** `bpy.ops.mesh.select_linked_pick` accepts `object_index` and `index` arguments. They are set to `-1` by default (probably indicating that they're not meant to be used). If `object_index` corresponds to an object in the scene and `index` is a negative number, Blender crashes. **Exact steps for others to reproduce the error** 1. Select the default cube and go into edit mode 2. Open a Python console 3. Run `bpy.ops.mesh.select_linked_pick(object_index=0)` 4. Crash Alternatively, you can provide any negative index value; it should always crash (although it might run into valid memory if you're lucky) A debug build reports an access violation: `SUMMARY: AddressSanitizer: access-violation D:\blender-git\blender\source\blender\editors\mesh\editmesh_select.c:3451 in edbm_select_linked_pick_ex` Debug stack trace: [P2202](https://archive.blender.org/developer/P2202.txt)
Author

Added subscriber: @chemicalcrux

Added subscriber: @chemicalcrux
Fen self-assigned this 2021-06-22 17:59:45 +02:00
Author

Looks like 211d7ff3cf lost this sanity check:

if (index < 0 || index >= (bm->totvert + bm->totedge + bm->totface)) {
    return OPERATOR_CANCELLED;
  }

EDBM_elem_from_index_any_multi correctly handles invalid object indices (as negative indices become a very large uint), but EDBM_elem_from_index_any uses signed integers, so its index < bm->totvert test succeeds. Updating it to reject negative indices should resolve this problem, if it's deemed to be a bug worth fixing.

Looks like 211d7ff3cf lost this sanity check: ``` if (index < 0 || index >= (bm->totvert + bm->totedge + bm->totface)) { return OPERATOR_CANCELLED; } ``` `EDBM_elem_from_index_any_multi` correctly handles invalid object indices (as negative indices become a very large uint), but `EDBM_elem_from_index_any` uses signed integers, so its `index < bm->totvert` test succeeds. Updating it to reject negative indices should resolve this problem, if it's deemed to be a bug worth fixing.
Author

Proposed a fix in D11672

Proposed a fix in [D11672](https://archive.blender.org/developer/D11672)

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

This issue was referenced by 635b4db162

This issue was referenced by 635b4db162731a100c255faa11ca9e2bd40d7d93

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#89367
No description provided.