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);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to