From c677338f67d2e96dfe399d2a3303854abb74ae38 Mon Sep 17 00:00:00 2001 From: bket Date: Sun, 12 Jan 2020 17:25:37 +0000 Subject: [PATCH] Do not allow scrypt to ignore RLIMIT_DATA scrypt estimates the amount of available RAM, and ignores RLIMIT_DATA on systems which have mmap. From tedu@ (http://mail.tarsnap.com/scrypt/msg00263.html): "...this is the wrong thing to do for OpenBSD. On OpenBSD, rlimit_data is applied to anonymous mmap (since that's now the heap) for consistency. RLIMIT_RSS is a vestigal do nothing define." Issue is fixed by reverting https://github.com/Tarsnap/scrypt/commit/2b478e7ce590a6564d89417ddad4f3dd4bbdcaf6 While here set COMPILER and COMPILER_LANGS to fix building on sparc64 and powerpc (from kmos@, and tested by kmos@ and cwen@). OK cwen@, "patch looks good to me" tedu@ --- security/scrypt/Makefile | 6 ++++- .../scrypt/patches/patch-lib_util_memlimit_c | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 security/scrypt/patches/patch-lib_util_memlimit_c diff --git a/security/scrypt/Makefile b/security/scrypt/Makefile index 31dc84c3443..b52500f9de9 100644 --- a/security/scrypt/Makefile +++ b/security/scrypt/Makefile @@ -1,8 +1,9 @@ -# $OpenBSD: Makefile,v 1.10 2019/12/31 07:26:59 bket Exp $ +# $OpenBSD: Makefile,v 1.11 2020/01/12 17:25:37 bket Exp $ COMMENT = command-line encryption using scrypt key derivation function DISTNAME = scrypt-1.3.0 +REVISION = 0 SHARED_LIBS += scrypt-kdf 0.0 # 1.0 @@ -18,6 +19,9 @@ WANTLIB = c crypto MASTER_SITES = ${HOMEPAGE} EXTRACT_SUFX = .tgz +COMPILER = base-clang ports-gcc +COMPILER_LANGS = c + CONFIGURE_STYLE = gnu CONFIGURE_ARGS = --enable-libscrypt-kdf diff --git a/security/scrypt/patches/patch-lib_util_memlimit_c b/security/scrypt/patches/patch-lib_util_memlimit_c new file mode 100644 index 00000000000..6e4cd8de869 --- /dev/null +++ b/security/scrypt/patches/patch-lib_util_memlimit_c @@ -0,0 +1,24 @@ +$OpenBSD: patch-lib_util_memlimit_c,v 1.1 2020/01/12 17:25:37 bket Exp $ + +Do not ignore RLIMIT_DATA on OpenBSD. Revert +https://github.com/Tarsnap/scrypt/commit/2b478e7ce590a6564d89417ddad4f3dd4bbdcaf6 + +Index: lib/util/memlimit.c +--- lib/util/memlimit.c.orig ++++ lib/util/memlimit.c +@@ -167,14 +167,12 @@ memlimit_rlimit(size_t * memlimit) + memrlimit = (uint64_t)rl.rlim_cur; + #endif + +-#ifndef HAVE_MMAP +- /* ... RLIMIT_DATA (if we're not using mmap)... */ ++ /* ... RLIMIT_DATA... */ + if (getrlimit(RLIMIT_DATA, &rl)) + return (1); + if ((rl.rlim_cur != RLIM_INFINITY) && + ((uint64_t)rl.rlim_cur < memrlimit)) + memrlimit = (uint64_t)rl.rlim_cur; +-#endif + + /* ... and RLIMIT_RSS. */ + #ifdef RLIMIT_RSS