From nobody Sun May 22 16:37:42 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DB58E1B4ACFF; Sun, 22 May 2022 16:37:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L5mN65jjYz4prv; Sun, 22 May 2022 16:37:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653237462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F/KCFLr6f4dOAmY+GedmMujZYqxXdPeMnf2GLaPCS0w=; b=PQfc9FQiASKUa1zU92V1RANAgTFwxJsJRpBguBkFaHWKUaCx8U/go4+osOwb2gPNnLccJv itgpR6dZoirSKJogOmr5irpVdHkgoNCeabybk6DGC0pl0Xqt4gpxPqEeTQBOrCcg52QxMl C8v8V7AlBOiWRLALiCPWkonhYr4FMFzOK2cSTsy6jud+pMuPMlJAkUcW3BCzSMuXKMbuxj ++FrEoAW6nALmtUOUVIJn7nqPCx9yuCmDoIH0NHema/qEMCFDczk7/D69Go8ELk5MB0AgH R1ZMlTUIHibVwkIZD88gGxtX5TZ15hRRe89aZDbXhwJFW16EJ9hCBDI+RuisJA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 93DA11EBD3; Sun, 22 May 2022 16:37:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24MGbg07094011; Sun, 22 May 2022 16:37:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24MGbgk3094010; Sun, 22 May 2022 16:37:42 GMT (envelope-from git) Date: Sun, 22 May 2022 16:37:42 GMT Message-Id: <202205221637.24MGbgk3094010@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: b75e0eed345d - main - pam_exec: fix segfault when authtok is null List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b75e0eed345d2ab047a6b1b00a9a7c3bf92e992c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653237462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F/KCFLr6f4dOAmY+GedmMujZYqxXdPeMnf2GLaPCS0w=; b=Sy9JyN62ovW0XxtG7Kx/t7pQDduClS/17pOthpuRDxIsIJ3OxQpZ7RmSvMEUnGQRLfIArT P/auIfVpZWpMvMJ6DwNgEQ1ztqn/5yb/S4ko8tSFmd29pWkXndMAkKPTzyaBBi1sjS+4ge E9sgqP9TpabWzUfNv/WsOm1esEoLeZiOb8d3/SLbBJcrSxUW8jk6yWZ/T2mQ+RKDF+z172 8qCK8MP9kRB1ZKaCDO4wPdfIGSInBEjI7jmTvFQXisUsS0KZQdW3e2ux4u6nR4u4wCPGyL LLrH28cJ6XU7bf1p8yizr2T1m+4z88dXDNK2vz7qGW84mECRipFnTVCroN1Z8A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653237462; a=rsa-sha256; cv=none; b=We04nA++RAi3F6Qt3l+CuO7AXswHmfDIx6T2IijhKV+WPQ2al1CbI0Knj4G1cNwd+ROV9v AxmIiHN20aUBFxB5lcBwtkV4lY7aq6WifAiYb9hkB+Q8PI+d8fnoWsgaw91O+V9IMwE7iS lSUC18yTYfskG/wtH1Gv3+J7NEluhjWz+FSzEgosWTkM3/Ef5boHry4bqEFVY8/qlLqN11 4q3K1kdz/B9HOYuJQxUMA7biyte6SPylk9RdZw3Y2TdPj9d5atSCrHG2YjZZN1SBLM+whT lY0XJS5Glo8VWFJ8F5056PnNBvZgRS0DL9ebXdnUf8CcWZz37FojhAVlUgv6jg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=b75e0eed345d2ab047a6b1b00a9a7c3bf92e992c commit b75e0eed345d2ab047a6b1b00a9a7c3bf92e992c Author: Yan Ka Chiu AuthorDate: 2022-05-22 16:33:02 +0000 Commit: Ka Ho Ng CommitDate: 2022-05-22 16:36:48 +0000 pam_exec: fix segfault when authtok is null According to pam_exec(8), the `expose_authtok` option should be ignored when the service function is `pam_sm_setcred`. Currently `pam_exec` only prevent prompt for anth token when `expose_authtok` is set on `pam_sm_setcred`. This subsequently led to segfault when there isn't an existing auth token available. Bug reported on this: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263893 After reading https://reviews.freebsd.org/rS349556 I am not sure if the default behaviour supposed to be simply not prompt for authentication token, or is it to ignore the option entirely as stated in the man page. This patch is therefore only adding an additional NULL check on the item `pam_get_item` provide, and exit with `PAM_SYSTEM_ERR` when such item is NULL. MFC after: 1 week Reviewed by: des, khng Differential Revision: https://reviews.freebsd.org/D35169 --- lib/libpam/modules/pam_exec/pam_exec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/libpam/modules/pam_exec/pam_exec.c b/lib/libpam/modules/pam_exec/pam_exec.c index b8f2e1d8fdfc..ef2680d80525 100644 --- a/lib/libpam/modules/pam_exec/pam_exec.c +++ b/lib/libpam/modules/pam_exec/pam_exec.c @@ -261,6 +261,13 @@ _pam_exec(pam_handle_t *pamh, /* don't prompt, only expose existing token */ rc = pam_get_item(pamh, PAM_AUTHTOK, &item); authtok = item; + if (authtok == NULL && rc == PAM_SUCCESS) { + openpam_log(PAM_LOG_ERROR, + "%s: pam_get_authtok(): %s", + func, "authentication token not available"); + OUT(PAM_SYSTEM_ERR); + } + } else { rc = pam_get_authtok(pamh, PAM_AUTHTOK, &authtok, NULL); }