Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jul 2019 19:40:01 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349746 - head/sys/compat/linux
Message-ID:  <201907041940.x64Je1Uv029298@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Thu Jul  4 19:40:01 2019
New Revision: 349746
URL: https://svnweb.freebsd.org/changeset/base/349746

Log:
  Fix linuxulator prlimit64(2) with pid == 0.  This makes 'ulimit -a'
  return something reasonable, and helps linux binaries which attempt
  to close all the files, eg apt(8).
  
  Reviewed by:	emaste
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20692

Modified:
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_misc.c
==============================================================================
--- head/sys/compat/linux/linux_misc.c	Thu Jul  4 19:25:30 2019	(r349745)
+++ head/sys/compat/linux/linux_misc.c	Thu Jul  4 19:40:01 2019	(r349746)
@@ -2001,10 +2001,14 @@ linux_prlimit64(struct thread *td, struct linux_prlimi
 		flags |= PGET_CANDEBUG;
 	else
 		flags |= PGET_CANSEE;
-	error = pget(args->pid, flags, &p);
-	if (error != 0)
-		return (error);
-
+	if (args->pid == 0) {
+		p = td->td_proc;
+		PHOLD(p);
+	} else {
+		error = pget(args->pid, flags, &p);
+		if (error != 0)
+			return (error);
+	}
 	if (args->old != NULL) {
 		PROC_LOCK(p);
 		lim_rlimit_proc(p, which, &rlim);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907041940.x64Je1Uv029298>