From: Jeremy Allison Date: Tue, 19 Sep 2023 00:37:44 +0000 (-0700) Subject: s3: smbd: named pipe writes are async. Use the same logic as for named pipe transacts... X-Git-Tag: tevent-0.16.0~536 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea062c3b0d4dbb1f0682f808ac893bf36a6fb194;p=thirdparty%2Fsamba.git s3: smbd: named pipe writes are async. Use the same logic as for named pipe transacts to avoid crashes on shutdown. Noticed by Metze. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15423 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/smb2_write.c b/source3/smbd/smb2_write.c index 269c489642e..a7af20173a1 100644 --- a/source3/smbd/smb2_write.c +++ b/source3/smbd/smb2_write.c @@ -307,6 +307,7 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx, if (IS_IPC(smbreq->conn)) { struct tevent_req *subreq = NULL; + bool ok; if (!fsp_is_np(fsp)) { tevent_req_nterror(req, NT_STATUS_FILE_CLOSED); @@ -323,6 +324,18 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx, tevent_req_set_callback(subreq, smbd_smb2_write_pipe_done, req); + + /* + * Make sure we mark the fsp as having outstanding async + * activity so we don't crash on shutdown close. + */ + + ok = aio_add_req_to_fsp(fsp, req); + if (!ok) { + tevent_req_nterror(req, NT_STATUS_NO_MEMORY); + return tevent_req_post(req, ev); + } + return req; }