Skip to content

Commit

Permalink
Fix empty resource handle vulnerability.
Browse files Browse the repository at this point in the history
Some ops that attempt to extract a resource handle from user input
can lead to nullptr dereferences.  This returns an error in such
a case.

PiperOrigin-RevId: 445571938
  • Loading branch information
cantonios authored and tensorflow-jenkins committed May 4, 2022
1 parent c112f65 commit 295ffc9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tensorflow/core/common_runtime/eager/execute.cc
Expand Up @@ -303,6 +303,9 @@ Status GetDeviceForInput(const EagerContext& ctx, TensorHandle* tensor_handle,
const Tensor* tensor;
// TODO(fishx): Avoid blocking here.
TF_RETURN_IF_ERROR(tensor_handle->Tensor(&tensor));
if (tensor->NumElements() == 0) {
return errors::InvalidArgument("Empty resource handle");
}
const ResourceHandle& handle = tensor->flat<ResourceHandle>()(0);
device_name = handle.device();

Expand Down

0 comments on commit 295ffc9

Please sign in to comment.