Skip to content

Commit 19eb3e9

Browse files
ldv-altsolardiz
authored andcommitted
pam_tcb: do not use deprecated _pam_overwrite macro
As Linux-PAM v1.5.3 deprecated this macro, follow the Linux-PAM example by introducing an internal pam_tcb_overwrite_string macro and using it instead of _pam_overwrite. This fixes -Werror build with Linux-PAM >= 1.5.3.
1 parent 15d378c commit 19eb3e9

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
2024-10-17 Dmitry V. Levin <ldv at owl.openwall.com>
22

3+
pam_tcb: Do not use deprecated _pam_overwrite macro.
4+
* pam_tcb/support.h (pam_tcb_overwrite_string): New macro.
5+
(_pam_delete): Replace _pam_overwrite with pam_tcb_overwrite_string.
6+
* pam_tcb/pam_unix_passwd.c (pam_sm_chauthtok): Likewise.
7+
38
pam_tcb: Use _pam_delete in the compat implementation of pam_prompt.
49
* pam_tcb/compat.c (pam_prompt): Use _pam_delete instead of
510
_pam_overwrite followed by _pam_drop.

pam_tcb/pam_unix_passwd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,11 @@ PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
547547
retval = unix_approve_pass(pamh, oldpass, newpass);
548548
}
549549

550-
_pam_overwrite((char *)oldpass);
550+
pam_tcb_overwrite_string((char *)oldpass);
551551

552552
if (retval != PAM_SUCCESS) {
553553
pam_syslog(pamh, LOG_NOTICE, "New password not acceptable");
554-
_pam_overwrite((char *)newpass);
554+
pam_tcb_overwrite_string((char *)newpass);
555555
return retval;
556556
}
557557

@@ -562,7 +562,7 @@ PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
562562

563563
/* First we hash the new password and forget the plaintext. */
564564
newhash = do_crypt(pamh, newpass);
565-
_pam_overwrite((char *)newpass);
565+
pam_tcb_overwrite_string((char *)newpass);
566566

567567
D(("password processed"));
568568

pam_tcb/support.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,19 @@ struct unix_verify_password_param {
147147
const char *pass;
148148
};
149149

150+
#define pam_tcb_overwrite_string(xx) \
151+
{ \
152+
void *xx__ = xx; \
153+
if (xx__) { \
154+
xx__ = memset(xx__, '\0', strlen(xx__)); \
155+
__asm__ __volatile__ ("" : : "r"(xx__) : "memory"); \
156+
} \
157+
}
158+
150159
/* use this to free strings, ESPECIALLY password strings */
151160
#define _pam_delete(xx) \
152161
{ \
153-
_pam_overwrite(xx); \
162+
pam_tcb_overwrite_string(xx); \
154163
_pam_drop(xx); \
155164
}
156165

0 commit comments

Comments
 (0)