Infinite loop in the subgraph.cc
Hi @SiriusHsh 

As this [comment](https://github.com/tensorflow/tensorflow/issues/60620#issuecomment-1553442519) suggests, please consult https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md#vulnerabilities-in-tensorflow and follow rules for responsible disclosure.

Thanks. I was able to replicate locally on nightly branch:

```
./benchmark_model --graph=subgraph_infinite_loop.tflite
INFO: STARTING!
WARN: Duplicate flags: num_threads
INFO: Log parameter values verbosely: [0]
INFO: Graph: [subgraph_infinite_loop.tflite]
INFO: Loaded model subgraph_infinite_loop.tflite
INFO: Initialized TensorFlow Lite runtime.
INFO: Applying 1 TensorFlow Lite delegate(s) lazily.
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
INFO: Successfully applied the default TensorFlow Lite delegate indexed at 0.
 *NOTE*: because a delegate has been applied, the precision of computations should be unchanged, but the exact output tensor values may have changed. If such output values are checked in your code, like in your tests etc., please consider increasing error tolerance for the check.
INFO: The input model file size (MB): 0.000488
INFO: Initialized session in 1.213ms.
INFO: Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
Segmentation fault
```

Top of Callstack (repeats last 4):
```
...
#87231 0x0000555555a802c2 in tflite::Subgraph::Invoke (this=0x55555635acd0) at tensorflow/lite/core/subgraph.cc:1498
#87232 0x00005555559dc4d5 in tflite::ops::builtin::call_once_kernel::Eval (context=0x55555635acf8, node=0x55555635e800) at tensorflow/lite/kernels/call_once.cc:98
#87233 0x0000555555a7f7e5 in tflite::Subgraph::OpInvoke (this=0x55555635acd0, op_reg=..., node=0x55555635e800) at tensorflow/lite/core/subgraph.cc:1292
#87234 0x0000555555a80840 in tflite::Subgraph::InvokeImpl (this=0x55555635acd0) at tensorflow/lite/core/subgraph.cc:1605
#87235 0x0000555555a802c2 in tflite::Subgraph::Invoke (this=0x55555635acd0) at tensorflow/lite/core/subgraph.cc:1498
#87236 0x00005555559dc4d5 in tflite::ops::builtin::call_once_kernel::Eval (context=0x55555635acf8, node=0x55555635e800) at tensorflow/lite/kernels/call_once.cc:98
#87237 0x0000555555a7f7e5 in tflite::Subgraph::OpInvoke (this=0x55555635acd0, op_reg=..., node=0x55555635e800) at tensorflow/lite/core/subgraph.cc:1292
#87238 0x0000555555a80840 in tflite::Subgraph::InvokeImpl (this=0x55555635acd0) at tensorflow/lite/core/subgraph.cc:1605
#87239 0x0000555555a802c2 in tflite::Subgraph::Invoke (this=0x55555635acd0) at tensorflow/lite/core/subgraph.cc:1498
#87240 0x0000555555a50898 in tflite::impl::Interpreter::Invoke (this=0x55555634b910) at tensorflow/lite/core/interpreter.cc:237
#87241 0x000055555557bacc in tflite::benchmark::BenchmarkTfLiteModel::RunImpl (this=0x7fffffffc370) at tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc:961
#87242 0x000055555559ae70 in tflite::benchmark::BenchmarkModel::Run (this=0x7fffffffc370, min_num_times=1, min_secs=0.5, max_secs=150, run_type=tflite::benchmark::WARMUP, invoke_status=0x7fffffffbe8c) at tensorflow/lite/tools/benchmark/benchmark_model.cc:230
#87243 0x000055555559ba3c in tflite::benchmark::BenchmarkModel::Run (this=0x7fffffffc370) at tensorflow/lite/tools/benchmark/benchmark_model.cc:318
#87244 0x000055555559b313 in tflite::benchmark::BenchmarkModel::Run (this=0x7fffffffc370, argc=2, argv=0x7fffffffdac8) at tensorflow/lite/tools/benchmark/benchmark_model.cc:276
#87245 0x000055555557230e in tflite::benchmark::Main (argc=2, argv=0x7fffffffdac8) at tensorflow/lite/tools/benchmark/benchmark_main.cc:27
#87246 0x00005555555723b6 in main (argc=2, argv=0x7fffffffdac8) at tensorflow/lite/tools/benchmark/benchmark_main.cc:36
``` Hi @miaout17, can you take a look at this?
<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

No

### Source

source

### Tensorflow Version

tf 2.14.0

### Custom Code

No

### OS Platform and Distribution

Ubuntu 18.04.6

### Mobile device

_No response_

### Python version

Python 3.8.3

### Bazel version

bazel 5.3.0

### GCC/Compiler version

gcc 7.5.0

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

When the `GetRegistrationFromOpCode` function parses a maliciously crafted model structure, if the `builtin_code` is `tflite::BuiltinOperator_CALL_ONCE`, it will enter an infinite loop in the subsequent inference process:`tflite::Subgraph::Invoke -> tflite::Subgraph::InvokeImpl -> tflite::Subgraph::OpInvoke -> tflite::ops::builtin::call_once_kernel::Eval`.

```c
// op_resolver.cc
TfLiteStatus GetRegistrationFromOpCode(
    const OperatorCode* opcode, const OpResolver& op_resolver,
    ErrorReporter* error_reporter, const TfLiteRegistration** registration) {
  TfLiteStatus status = kTfLiteOk;
  *registration = nullptr;
  auto builtin_code = GetBuiltinCode(opcode);
  int version = opcode->version();

  if (builtin_code > BuiltinOperator_MAX) {
    TF_LITE_REPORT_ERROR(
        error_reporter,
        "Op builtin_code out of range: %d. Are you using old TFLite binary "
        "with newer model?",
        builtin_code);
    status = kTfLiteError;
  } else if (builtin_code != BuiltinOperator_CUSTOM) {
    *registration = op_resolver.FindOp(builtin_code, version); // here
```

At the time of the crash, the call stack would look like this:

```
#67807 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67808 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67809 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67810 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67811 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67812 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67813 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67814 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67815 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67816 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67817 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67818 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67819 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67820 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67821 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67822 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67823 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67824 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67825 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67826 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67827 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67828 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67829 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67830 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67831 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67832 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67833 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67834 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67835 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67836 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67837 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67838 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67839 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67840 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67841 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67842 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67843 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67844 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67845 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67846 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67847 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67848 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67849 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67850 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67851 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67852 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
#67853 0x00005555555ee3fe in tflite::Subgraph::Invoke() ()
#67854 0x000055555566cc30 in tflite::ops::builtin::call_once_kernel::Eval(TfLiteContext*, TfLiteNode*) ()
#67855 0x00005555555ee106 in tflite::Subgraph::InvokeImpl() ()
```

[subgraph_infinite_loop.zip](https://github.com/tensorflow/tensorflow/files/11503605/subgraph_infinite_loop.zip)


### Standalone code to reproduce the issue

```shell
When I use the benchmark tool for PoC validation, it causes the TensorFlow Lite inference process to be subjected to a DOS（coredump).


❯ ./benchmark_model --graph=./subgraph_infinite_loop.tflite
INFO: STARTING!
INFO: Log parameter values verbosely: [0]
INFO: Graph: [./subgraph_infinite_loop.tflite]
INFO: Loaded model ./subgraph_infinite_loop.tflite
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
INFO: The input model file size (MB): 0.000488
INFO: Initialized session in 0.731ms.
INFO: Running benchmark for at least 1 iterations and at least 0.5 seconds but terminate if exceeding 150 seconds.
[1]    6892 segmentation fault (core dumped)  ./benchmark_model --graph=./subgraph_infinite_loop.tflite
```
```


### Relevant log output

_No response_</details>