Skip to content

Commit

Permalink
[fuzzing] Fix fuzzer found bugs in client promise call (grpc#34724)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller authored Oct 19, 2023
1 parent eccbc97 commit 3f7d651
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/lib/surface/call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2837,6 +2837,7 @@ class ClientPromiseBasedCall final : public PromiseBasedCall {
Pipe<MessageHandle> server_to_client_messages_{arena()};
bool is_trailers_only_ = false;
bool scheduled_receive_status_ = false;
bool scheduled_send_close_ = false;
// True once the promise for the call is started.
// This corresponds to sending initial metadata, or cancelling before doing
// so.
Expand Down Expand Up @@ -2906,7 +2907,10 @@ grpc_call_error ClientPromiseBasedCall::ValidateBatch(const grpc_op* ops,
break;
case GRPC_OP_RECV_INITIAL_METADATA:
case GRPC_OP_RECV_MESSAGE:
if (op.flags != 0) return GRPC_CALL_ERROR_INVALID_FLAGS;
break;
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
if (scheduled_send_close_) return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
if (op.flags != 0) return GRPC_CALL_ERROR_INVALID_FLAGS;
break;
case GRPC_OP_RECV_STATUS_ON_CLIENT:
Expand Down Expand Up @@ -2973,6 +2977,7 @@ void ClientPromiseBasedCall::CommitBatch(const grpc_op* ops, size_t nops,
&server_to_client_messages_.receiver, false, spawner);
break;
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
scheduled_send_close_ = true;
spawner.Spawn(
"send_close_from_client",
[this]() {
Expand Down
41 changes: 41 additions & 0 deletions test/core/end2end/fuzzers/client_fuzzer_corpus/5694930614812672
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
api_actions {
create_call {
propagation_mask: 51456
method {
value: "\023"
}
timeout: 1560281087
}
}
api_actions {
queue_batch {
operations {
receive_status_on_client {
}
}
operations {
send_message {
}
}
}
}
api_actions {
queue_batch {
operations {
}
operations {
flags: 172184661
}
}
}
api_actions {
queue_batch {
operations {
receive_status_on_client {
}
}
}
}
config_vars {
experiments: 18374694180430544895
}
27 changes: 27 additions & 0 deletions test/core/end2end/fuzzers/client_fuzzer_corpus/6195677899063296
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
api_actions {
create_call {
method {
value: "="
}
timeout: -2045050880
}
}
api_actions {
queue_batch {
operations {
send_close_from_client {
}
}
}
}
api_actions {
queue_batch {
operations {
send_close_from_client {
}
}
}
}
config_vars {
experiments: 72057594037927935
}

0 comments on commit 3f7d651

Please sign in to comment.