zfs/contrib
Attila Fülöp 7cc5cb8083 pam_zfs_key: malloc and mlock/munlock won't match
mlock(2) and munlock(2) operate on memory pages whereas malloc(3)
does not. So if you munlock(2) a malloced memory region, the whole
page containing it is freed. Since this page may contain another
malloced and mlocked memory region, used as a password buffer by a
concurrent running instance of pam_zfs_key, there is a slight chance
of leaking passwords. By using mmap(2) we avoid such problems since
it will return whole pages on page aligned addresses.

Although the above concern may be mostly academical, it is still
better to use mmap(2) for allocating memory since the FreeBSD
documentation suggests to call mlock(2) and munlock(2) on page
aligned addresses, and other implementations even require it.

While here, remove duplicate code in alloc_pw_string() by calling
alloc_pw_size().

Reviewed-by: Felix Dörre <felix@dogcraft.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #12665
2021-10-22 11:42:34 -07:00
..
bash_completion.d Turn shellcheck into a normal make target. Fix new files it caught 2021-06-01 11:38:49 -07:00
bpftrace Turn shellcheck into a normal make target. Fix new files it caught 2021-06-01 11:38:49 -07:00
dracut Fix plymouth passphrase prompt with dracut 2021-06-25 22:43:25 -07:00
initramfs initramfs: use correct dataset for rootfs on rollback=1 2021-10-08 11:16:31 -07:00
intel_qat Add intel_QAT patches 2020-09-30 13:17:30 -07:00
pam_zfs_key pam_zfs_key: malloc and mlock/munlock won't match 2021-10-22 11:42:34 -07:00
pyzfs Replace ZoL with OpenZFS where applicable 2021-05-07 17:20:37 -07:00
zcp Fix contrib/zcp/Makefile.am 2019-10-30 12:37:49 -07:00
Makefile.am Turn shellcheck into a normal make target. Fix new files it caught 2021-06-01 11:38:49 -07:00