Fix #107420: crash getting PTCacheID when baking scene rigid body world #107536

Merged
Philipp Oeser merged 1 commits from lichtwerk/blender:107420_a into main 2023-05-02 17:56:23 +02:00
Member

ptcache_baker_create falsely assumed the PointCache owner id is always
an object, but when baking rigid body world it is a scene. Code
would cast the ID to an object and passed that to BKE_ptcache_id_find /
BKE_ptcache_ids_from_object (which can get terribly wrong -- reading
something on the scene as something from the assumed object).

Prior to f61ff22967 this was less likely to be a problem, but that
commit introduced a DrawDataList into the struct Scene. In the file from the report, this would lead to foreach_object_particle_ptcachenow recognizing garbage memory as a particle system, accessing itsParticleSettings phystype` would then crash (buffer-overflow).

Now pass a NULL object to BKE_ptcache_id_find in case we are having a
scene, following code still handles rigid bodies just fine (the scene is
actually passed separately as well).

`ptcache_baker_create` falsely assumed the PointCache owner id is always an **object**, but when baking rigid body world it is a **scene**. Code would cast the ID to an object and passed that to `BKE_ptcache_id_find` / `BKE_ptcache_ids_from_object` (which can get terribly wrong -- reading _something_ on the scene as something from the assumed object). Prior to f61ff22967c5 this was less likely to be a problem, but that commit introduced a `DrawDataList` into the `struct Scene. In the file from the report, this would lead to `foreach_object_particle_ptcache` now recognizing garbage memory as a particle system, accessing its `ParticleSettings` `phystype` would then crash (buffer-overflow). Now pass a NULL object to `BKE_ptcache_id_find` in case we are having a scene, following code still handles rigid bodies just fine (the scene is actually passed separately as well).
Philipp Oeser added 1 commit 2023-05-02 13:04:49 +02:00
5157303dba Fix #107420: crash getting PTCacheID when baking scene rigid body world
`ptcache_baker_create` falsely assumed the PointCache owner id is always
an **object**, but when baking rigid body world it is a **scene**. Code
would cast the ID to an object and passed that to `BKE_ptcache_id_find` /
`BKE_ptcache_ids_from_object` (which can get terribly wrong -- reading
_something_ on the scene as something from the assumed object).

Prior to f61ff22967 this was less likely to be a problem, but that
commit introduced a `DrawDataList` into the `struct Scene. In the file
from the report, this would lead to `foreach_object_particle_ptcache`
now recognizing garbage memory as a particle system, accessing its
`ParticleSettings` `phystype` would then crash (buffer-overflow).

Now pass a NULL object to `BKE_ptcache_id_find` in case we are having a
scene, following code still handles rigid bodies just fine (the scene is
actually passed separately as well).
Philipp Oeser requested review from Sebastian Parborg 2023-05-02 13:04:58 +02:00
Philipp Oeser requested review from Lukas Tönne 2023-05-02 13:05:11 +02:00
Philipp Oeser added this to the Nodes & Physics project 2023-05-02 13:05:18 +02:00
Sebastian Parborg approved these changes 2023-05-02 15:58:31 +02:00
Sebastian Parborg left a comment
Member

LGTM

LGTM
Lukas Tönne approved these changes 2023-05-02 17:27:12 +02:00
Philipp Oeser merged commit d0c6117196 into main 2023-05-02 17:56:23 +02:00
Philipp Oeser deleted branch 107420_a 2023-05-02 17:56:24 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:43 +02:00
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 Assignees
3 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#107536
No description provided.