Date: Sun, 30 Dec 2012 13:39:16 GMT From: Fabian Keil <fk@fabiankeil.de> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/174831: [PATCH] geli segfaults with the new locked memory limit default Message-ID: <201212301339.qBUDdGTb038253@red.freebsd.org> Resent-Message-ID: <201212301340.qBUDe0Ys099832@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 174831 >Category: bin >Synopsis: [PATCH] geli segfaults with the new locked memory limit default >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Dec 30 13:40:00 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Fabian Keil >Release: HEAD >Organization: >Environment: FreeBSD r500.local 10.0-CURRENT FreeBSD 10.0-CURRENT #536 r+d9956e5: Wed Dec 26 16:42:41 CET 2012 fk@r500.local:/usr/obj/usr/src/sys/ZOEY amd64 >Description: Since the last login.conf update geli segfaults when called as ordinary user or with sudo. fk@r500 ~ $sudo /sbin/geli attach /dev/label/test || tail -n 2 /var/log/messages Dec 30 13:37:30 r500 kernel: [5043] pid 3521 (geli), uid 0: exited on signal 11 Dec 30 13:37:42 r500 sudo: fk : TTY=pts/6 ; PWD=/home/fk ; USER=root ; COMMAND=/sbin/geli attach /dev/label/test The problem seems to be the new locked memory limit default of 64K. Executing geli from a root shell works as expected and setting vm.old_mlock=0 works around the problem. >How-To-Repeat: See description. >Fix: The attached patch lets geli try to set the limit to 1024K which seems to be sufficient to prevent the segmentation fault and results in a proper error message if the user lacks the required privileges. Patch attached with submission follows: >From 4aa5fe7e0b70a0c437fbcbebec4e7cc89c7afa2c Mon Sep 17 00:00:00 2001 From: Fabian Keil <fk@fabiankeil.de> Date: Sun, 30 Dec 2012 13:48:15 +0100 Subject: [PATCH] Let eli_protect() make sure the locked memory limit is high enough Prevents segmentation faults with the new locked memory limit default for ordinary users (64K). --- sbin/geom/class/eli/geom_eli.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sbin/geom/class/eli/geom_eli.c b/sbin/geom/class/eli/geom_eli.c index cfd8897..06dadac 100644 --- a/sbin/geom/class/eli/geom_eli.c +++ b/sbin/geom/class/eli/geom_eli.c @@ -272,6 +272,14 @@ eli_protect(struct gctl_req *req) strerror(errno)); return (-1); } + /* Make sure the locked memory limit is high enough. */ + rl.rlim_cur = 1024 * 1024; + rl.rlim_max = 1024 * 1024; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) { + gctl_error(req, "Cannot set locked memory limit: %s.", + strerror(errno)); + return (-1); + } /* Disable swapping. */ if (mlockall(MCL_FUTURE) == -1) { gctl_error(req, "Cannot lock memory: %s.", strerror(errno)); -- 1.8.0.2 >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212301339.qBUDdGTb038253>