Bug 207386

Summary: [PATCH] implementation of the /proc/<pid>/limits file for linprocfs
Product: Base System Reporter: Szymon <knight.erraunt>
Component: kernAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me CC: dchagin, des, knight.erraunt
Priority: --- Keywords: patch
Version: CURRENTFlags: des: mfc-stable10?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
The diff of the linprocfs file.
none
more complete implementation
none
proc lock fix patch
none
Fixed the improper access to the process limits none

Description Szymon 2016-02-21 01:54:28 UTC
Created attachment 167233 [details]
The diff of the linprocfs file.

There are "(very) minor style issues" in this patch but was told they can be fixed by the committer.
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2016-02-21 11:52:05 UTC
Sorry, Dmitry, this one is mine.
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-02-21 14:56:51 UTC
A commit references this bug:

Author: des
Date: Sun Feb 21 14:56:05 UTC 2016
New revision: 295856
URL: https://svnweb.freebsd.org/changeset/base/295856

Log:
  Implement /proc/$$/limits.

  PR:		207386
  Submitted by:	Szymon ?liwa <knight.erraunt@gmail.com>
  MFC after:	3 weeks

Changes:
  head/sys/compat/linprocfs/linprocfs.c
Comment 3 Dmitry Chagin freebsd_committer freebsd_triage 2016-02-21 15:24:47 UTC
Created attachment 167260 [details]
more complete implementation

i have adapted my own limits implementation over your
Comment 4 Szymon 2016-02-21 23:20:51 UTC
(In reply to Dmitry Chagin from comment #3)
Well, I got a message from one of the committers that there are some issues - plimit does not need to be allocated dynamically. And actually we should not copy the limits but get a private reference, I also got this link http://fxr.watson.org/fxr/source/fs/procfs/procfs_rlimit.c#L112
so I think that the implementation should conform to what is under the link.
Comment 5 Dmitry Chagin freebsd_committer freebsd_triage 2016-02-23 05:54:39 UTC
Created attachment 167315 [details]
proc lock fix patch

yes, mjg@ pointed proc locking problem. pn_fill methods only prele proc
Comment 6 Szymon 2016-03-07 14:23:35 UTC
Created attachment 167814 [details]
Fixed the improper access to the process limits

Changed the way the code accesses the limits structure. Took inspiration from here: http://fxr.watson.org/fxr/source/fs/procfs/procfs_rlimit.c#L112 .
Also changed the name cur_proc_lim to process_lim as I was told the prior may be misleading.
Comment 7 Szymon 2016-03-07 14:29:36 UTC
(In reply to Dmitry Chagin from comment #5)
I also fixed mine code and posted here a patch to comply with the istructions given from the rest. What should we do to commit any of the fixes, I don't mind which one, I would just like if the dangerous code was replaced with something fast.
Comment 8 commit-hook freebsd_committer freebsd_triage 2016-04-10 07:12:08 UTC
A commit references this bug:

Author: dchagin
Date: Sun Apr 10 07:11:30 UTC 2016
New revision: 297781
URL: https://svnweb.freebsd.org/changeset/base/297781

Log:
  More complete implementation of /proc/self/limits.
  Fix the way the code accesses process limits struct - pointed out by mjg@.

  PR:		207386
  Reviewed by:	no objection form des@
  MFC after:	3 weeks

Changes:
  head/sys/compat/linprocfs/linprocfs.c
  head/sys/compat/linux/linux_misc.h
Comment 9 commit-hook freebsd_committer freebsd_triage 2016-05-07 19:06:26 UTC
A commit references this bug:

Author: dchagin
Date: Sat May  7 19:05:39 UTC 2016
New revision: 299221
URL: https://svnweb.freebsd.org/changeset/base/299221

Log:
  MFC r295856 (by des@):
  Implement /proc/$$/limits.

  MFC r297781 (by dchagin@):
  More complete implementation of /proc/self/limits.
  Fix the way the code accesses process limits struct - pointed out by mjg@.

  MFC r298318, 298319 (by cem@):
  Don't print uninitialized values and initialize error return before use.

  PR:		207386

Changes:
_U  stable/10/
  stable/10/sys/compat/linprocfs/linprocfs.c
  stable/10/sys/compat/linux/linux_misc.h