aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_unix/unix_update.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-01-30 17:56:58 +0100
committerChristian Göttsche <cgzones@googlemail.com>2023-02-28 15:13:15 +0100
commitbcba17939e1b1a568cd4a764534cde74d37078cc (patch)
tree4f3630f53cd52c2afa59435f5d36db260c1bf4a1 /modules/pam_unix/unix_update.c
parent87ff7a12a55c38873905636eb8d29b4542d828f5 (diff)
downloadpam-bcba17939e1b1a568cd4a764534cde74d37078cc.tar.gz
pam-bcba17939e1b1a568cd4a764534cde74d37078cc.tar.bz2
pam-bcba17939e1b1a568cd4a764534cde74d37078cc.zip
modules: make use of secure memory erasure
Use empty initialization of structs to minimize the memset() usage, to reduce the amount of calls which are not sensitive. Non trivial changes: - pam_env: * erase environment variables where possible - pam_exec: * erase responce on error * erase auth token - pam_pwhistory: * erase buffers containing old passwords - pam_selinux: skip overwriting data structure consisting of only pointers to insensitive data, which also gets free'd afterwards (so it currently does not protect against double-free or use-after-free on the member pointers) - pam_unix: erase cipher data in more places - pam_userdb: erase password hashes
Diffstat (limited to 'modules/pam_unix/unix_update.c')
-rw-r--r--modules/pam_unix/unix_update.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/modules/pam_unix/unix_update.c b/modules/pam_unix/unix_update.c
index 3559972b..49a70ff3 100644
--- a/modules/pam_unix/unix_update.c
+++ b/modules/pam_unix/unix_update.c
@@ -55,15 +55,18 @@ set_password(const char *forwho, const char *shadow, const char *remember)
if (npass != 2) { /* is it a valid password? */
if (npass == 1) {
helper_log_err(LOG_DEBUG, "no new password supplied");
- memset(pass, '\0', PAM_MAX_RESP_SIZE);
+ pam_overwrite_array(pass);
} else {
helper_log_err(LOG_DEBUG, "no valid passwords supplied");
}
return PAM_AUTHTOK_ERR;
}
- if (lock_pwdf() != PAM_SUCCESS)
+ if (lock_pwdf() != PAM_SUCCESS) {
+ pam_overwrite_array(pass);
+ pam_overwrite_array(towhat);
return PAM_AUTHTOK_LOCK_BUSY;
+ }
pwd = getpwnam(forwho);
@@ -98,8 +101,8 @@ set_password(const char *forwho, const char *shadow, const char *remember)
}
done:
- memset(pass, '\0', PAM_MAX_RESP_SIZE);
- memset(towhat, '\0', PAM_MAX_RESP_SIZE);
+ pam_overwrite_array(pass);
+ pam_overwrite_array(towhat);
unlock_pwdf();