summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jls
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2005-08-15 12:15:21 +0000
committerpjd <pjd@FreeBSD.org>2005-08-15 12:15:21 +0000
commitd5f324cb09368c2d209854d95fa99d3670ec760b (patch)
tree7b6531c0ee73162dfb13a97d0ac30c8069d4cfc7 /usr.sbin/jls
parent50f5e50a7bf1405b73d63b5d0aa18d701726e857 (diff)
downloadFreeBSD-src-d5f324cb09368c2d209854d95fa99d3670ec760b.zip
FreeBSD-src-d5f324cb09368c2d209854d95fa99d3670ec760b.tar.gz
Not sure why, but SYSCTL_OUT() can sometimes keep returning ENOMEM
in sysctl_jail_list(). Because of this, jls(8) could enter into an endless loop. The strange thing is, that we can call jls(8) while the other one is in loop and it will succeed - SYSCTL_OUT() will not return ENOMEM there. Maybe SYSCTL_OUT() returns first ENOMEM, because there is no memory, but is marking some memory range as wired even on failure and another SYSCTL_OUT() calls are not going to succeed, because process exceeds limit of wired memory? ENOVMCLUE. Anyway. Fix jls(8) to ignore ENOMEM and retry only 4 times. Submitted by: Niklas Saers PR: kern/79245 MFC after: 3 days
Diffstat (limited to 'usr.sbin/jls')
-rw-r--r--usr.sbin/jls/jls.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c
index 0ad36d1..e8446bb 100644
--- a/usr.sbin/jls/jls.c
+++ b/usr.sbin/jls/jls.c
@@ -47,20 +47,26 @@ main(void)
if (sysctlbyname("security.jail.list", NULL, &len, NULL, 0) == -1)
err(1, "sysctlbyname(): security.jail.list");
-retry:
- if (len <= 0)
- exit(0);
- sxp = xp = calloc(len, 1);
- if (sxp == NULL)
- err(1, "malloc()");
- if (sysctlbyname("security.jail.list", xp, &len, NULL, 0) == -1) {
- if (errno == ENOMEM) {
- free(sxp);
- goto retry;
+ for (i = 0; i < 4; i++) {
+ if (len <= 0)
+ exit(0);
+ sxp = xp = calloc(len, 1);
+ if (sxp == NULL)
+ err(1, "malloc()");
+
+ if (sysctlbyname("security.jail.list", xp, &len, NULL, 0) == -1) {
+ if (errno == ENOMEM) {
+ free(sxp);
+ sxp = NULL;
+ continue;
+ }
+ err(1, "sysctlbyname(): security.jail.list");
}
- err(1, "sysctlbyname(): security.jail.list");
+ break;
}
+ if (sxp == NULL)
+ err(1, "sysctlbyname(): security.jail.list");
if (len < sizeof(*xp) || len % sizeof(*xp) ||
xp->pr_version != XPRISON_VERSION)
errx(1, "Kernel and userland out of sync");
OpenPOWER on IntegriCloud