]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
propagate PAM crashes to PerSourcePenalties
authorDamien Miller <djm@mindrot.org>
Mon, 17 Jun 2024 07:02:18 +0000 (17:02 +1000)
committerDamien Miller <djm@mindrot.org>
Mon, 17 Jun 2024 07:02:18 +0000 (17:02 +1000)
If the PAM subprocess crashes, exit with a crash status that will be
picked up by the sshd(8) listener process where it can be used by
PerSourcePenalties to block the client. This is similar handling to
the privsep preauth process.

auth-pam.c

index 2c1a8d3df8dd6c8a4c8258af04da6c6d94731d08..13c0a792e99e63246b9b82fc1ba325812039edb5 100644 (file)
 #include "ssh-gss.h"
 #endif
 #include "monitor_wrap.h"
+#include "srclimit.h"
 
 extern ServerOptions options;
 extern struct sshbuf *loginmsg;
@@ -166,13 +167,13 @@ sshpam_sigchld_handler(int sig)
                        return;
                }
        }
-       if (WIFSIGNALED(sshpam_thread_status) &&
-           WTERMSIG(sshpam_thread_status) == SIGTERM)
-               return; /* terminated by pthread_cancel */
-       if (!WIFEXITED(sshpam_thread_status))
-               sigdie("PAM: authentication thread exited unexpectedly");
-       if (WEXITSTATUS(sshpam_thread_status) != 0)
-               sigdie("PAM: authentication thread exited uncleanly");
+       if (sshpam_thread_status == -1)
+               return;
+       if (WIFSIGNALED(sshpam_thread_status)) {
+               if (signal_is_crash(WTERMSIG(sshpam_thread_status)))
+                       _exit(EXIT_CHILD_CRASH);
+       } else if (!WIFEXITED(sshpam_thread_status))
+               _exit(EXIT_CHILD_CRASH);
 }
 
 /* ARGSUSED */