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 2b478e7ce5

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@
This commit is contained in:
bket 2020-01-12 17:25:37 +00:00
parent 2c5bb1a439
commit c677338f67
2 changed files with 29 additions and 1 deletions

View File

@ -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

View File

@ -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