mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix bugs found by static analysis (#85705)
These PR fixes a number of bugs found by Svace static analyzer: 1. DEREF_AFTER_FREE at qnnpack_utils.h: Pointer '&convolution->zero_buffer' is dereferenced at qnnpack_utils.h:258 after the referenced memory was deallocated at operator-delete.c:25 by passing as 1st parameter to function 'pytorch_qnnp_delete_operator' at qnnpack_utils.h:251. 2. DEREF_AFTER_NULL at impl.cpp: After having been compared to NULL value at impl.cpp:1892, pointer 'schema' is passed as 2nd parameter in call to function 'c10::operator<<' at impl.cpp:1921, where it is dereferenced at function_schema_inl.h:13. 3. DEREF_OF_NULL at stmt.h: After having been compared to NULL value at stmt.h:744, pointer 'body->_M_ptr' is passed in call to function 'torch::jit::tensorexpr::malformed_input::malformed_input' at stmt.h:745, where it is dereferenced at exceptions.h:67. 4. DEREF_OF_NULL at loopnest.h: Pointer 'f->ptr' that can have only NULL value (checked at loopnest.cpp:1482), is passed in call to function 'torch::jit::tensorexpr::malformed_input::malformed_input' at loopnest.cpp:1483, where it is dereferenced at exceptions.h:67. This is the same error as 3: forwarding a nullptr to malformed_input(). 4. TAINTED_INT.LOOP in python_arg_parser: Integer value 'this->size' obtained from untrusted source at python_arg_parser.cpp:118 without checking its bounds is used as a loop bound at python_arg_parser.cpp:698 by calling function 'torch::FunctionParameter::set_default_str' at python_arg_parser.cpp:133. Pull Request resolved: https://github.com/pytorch/pytorch/pull/85705 Approved by: https://github.com/kit1980
This commit is contained in:
committed by
PyTorch MergeBot
parent
376acf7625
commit
1eba3f220e
@ -2062,7 +2062,7 @@ bool ProcessedNode::verify_inputs_dont_overlap_outputs(bool force_check) const {
|
||||
bool skip_check = !schema ||
|
||||
((schema->is_mutable() || !fn_->checkMemoryOverlap()) &&
|
||||
num_outputs() == 1);
|
||||
if (!force_check && skip_check) {
|
||||
if (!schema || (!force_check && skip_check)) {
|
||||
if (!schema) {
|
||||
VLOG(2) << "Detected that op schema is null";
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user