]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: improve reinit_after_fork error handling
authorDavid Disseldorp <ddiss@samba.org>
Wed, 4 Sep 2024 02:54:09 +0000 (02:54 +0000)
committerDavid Disseldorp <ddiss@samba.org>
Wed, 4 Sep 2024 09:53:01 +0000 (09:53 +0000)
reinit_after_fork() may panic or return an error on failure. When smbd
is started in interactive mode, it ignores the reinit_after_fork()
return status and unconditionally proceeds to smbd_process().

Similarly, if messaging_reinit() fails within reinit_after_fork() then
it will subsequently call ctdb_async_ctx_reinit() if clustering is
enabled.

There's no reason why these errors shouldn't be handled immediately, so
add appropriate error handling.

Found by code inspection; not seen in the wild.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Wed Sep  4 09:53:01 UTC 2024 on atb-devel-224

source3/lib/util.c
source3/smbd/server.c

index 5561aa815ceb10dd55602abebb04bb429806c690..2e7cf649ebe9ca983ca818ccbdd984c053749893 100644 (file)
@@ -482,6 +482,7 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("messaging_reinit() failed: %s\n",
                                 nt_errstr(status)));
+                       goto done;
                }
 
                if (lp_clustering()) {
index e9ba7be9166051a8081d79b2ef2c52fcc8e7fadc..b43d654d6a5d2d7a05fb5c8dfaf293102ad8c6fc 100644 (file)
@@ -976,7 +976,13 @@ static void smbd_accept_connection(struct tevent_context *ev,
        smb_set_close_on_exec(fd);
 
        if (s->parent->interactive) {
-               reinit_after_fork(msg_ctx, ev, true);
+               NTSTATUS status;
+
+               status = reinit_after_fork(msg_ctx, ev, true);
+               if (!NT_STATUS_IS_OK(status)) {
+                       exit_server("reinit_after_fork() failed");
+                       return;
+               }
                smbd_process(ev, msg_ctx, fd, true);
                exit_server_cleanly("end of interactive mode");
                return;