summaryrefslogtreecommitdiff
path: root/src/secmem.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2016-12-09 12:10:54 +0100
committerWerner Koch <wk@gnupg.org>2016-12-09 12:10:54 +0100
commit618b8978f46f4011c11512fd5f30c15e01652e2e (patch)
treea1e669656746e3d22273b3b69b96267b29a47fb1 /src/secmem.c
parent656395ba4cf34f42dda3a120bda3ed1220755a3d (diff)
downloadlibgcrypt-618b8978f46f4011c11512fd5f30c15e01652e2e.tar.gz
Improve handling of mlock error codes.
* acinclude.m4 (GNUPG_CHECK_MLOCK): Check also for EAGAIN which is a legitimate return code and does not indicate a broken mlock(). * src/secmem.c (lock_pool_pages): Test ERR instead of ERRNO which could have been overwritten by cap_from+text et al. -- On FreeBSD, if there are not enough free pages, mlock() can return EAGAIN, as documented in mlock(2). That doesn't mean that mlock is broken. I suspect this same issue also exists on the other BSD's. Suggested-by: Ruben Kerkhof <ruben@rubenkerkhof.com> This is (now) also true for Linux. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'src/secmem.c')
-rw-r--r--src/secmem.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/secmem.c b/src/secmem.c
index 4fa267b6..55424f21 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -282,15 +282,15 @@ lock_pool_pages (void *p, size_t n)
if (err)
{
- if (errno != EPERM
-#ifdef EAGAIN /* OpenBSD returns this */
- && errno != EAGAIN
+ if (err != EPERM
+#ifdef EAGAIN /* BSD and also Linux may return EAGAIN */
+ && err != EAGAIN
#endif
#ifdef ENOSYS /* Some SCOs return this (function not implemented) */
- && errno != ENOSYS
+ && err != ENOSYS
#endif
#ifdef ENOMEM /* Linux might return this. */
- && errno != ENOMEM
+ && err != ENOMEM
#endif
)
log_error ("can't lock memory: %s\n", strerror (err));
@@ -341,15 +341,15 @@ lock_pool_pages (void *p, size_t n)
if (err)
{
- if (errno != EPERM
-#ifdef EAGAIN /* OpenBSD returns this. */
- && errno != EAGAIN
+ if (err != EPERM
+#ifdef EAGAIN /* BSD and also Linux may return this. */
+ && err != EAGAIN
#endif
#ifdef ENOSYS /* Some SCOs return this (function not implemented). */
- && errno != ENOSYS
+ && err != ENOSYS
#endif
#ifdef ENOMEM /* Linux might return this. */
- && errno != ENOMEM
+ && err != ENOMEM
#endif
)
log_error ("can't lock memory: %s\n", strerror (err));