aboutsummaryrefslogtreecommitdiff
path: root/procfs/rootdir.c
Commit message (Collapse)AuthorAgeFilesLines
* procfs: Fix use-after-freeSergey Bugaev2021-05-241-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix several issues with reference counting in rootdir_make_translated_node (): * Grab an additional reference while still holding the lock. * Give the node an additional reference for being pointed to by the ops. * Reference the existing node if we find it on the second try, not only if we find it on the first try. * Dereference, not just clean, the created node if it turns out to be unneeded. Fixes a crash with the following backtrace: #2 0x010855c8 in __assert_fail_backtrace ( assertion=0x1051148 "! (r.hard == 1 && r.weak == 0) || !\"refcount detected use-after-free!\"", file=0x1050cec "../../libshouldbeinlibc/refcount.h", line=170, function=0x1051220 <__PRETTY_FUNCTION__.3> "refcounts_ref") at ../../libshouldbeinlibc/assert-backtrace.c:64 #3 0x01050358 in refcounts_ref (result=0x0, ref=0x15009a0) at ../../libshouldbeinlibc/refcount.h:170 #4 netfs_nref (np=0x15008f0) at ../../libnetfs/nref.c:26 #5 0x0804c9f4 in rootdir_make_translated_node (dir_hook=0x10001990, entry_hook=0x8055180 <__compound_literal.8>) at ../../procfs/rootdir.c:674 #6 0x0804ace3 in procfs_dir_lookup (hook=0x10001c10, name=0x2857efc "mounts", np=0x2855d68) at ../../procfs/procfs_dir.c:88 #7 0x0804a410 in procfs_lookup (np=0x10001c40, name=0x2857efc "mounts", npp=0x2855d68) at ../../procfs/procfs.c:185 #8 0x0804cae5 in dircat_lookup (hook=0x10001d50, name=0x2857efc "mounts", np=0x2855d68) at ../../procfs/dircat.c:76 #9 0x0804a410 in procfs_lookup (np=0x10001d80, name=0x2857efc "mounts", npp=0x2855d68) at ../../procfs/procfs.c:185 #10 0x0804a96f in netfs_attempt_lookup (user=0x1401c60, dir=0x10001d80, name=0x2857efc "mounts", np=0x2855d68) at ../../procfs/netfs.c:212 #11 0x0103fd5b in netfs_S_dir_lookup (dircred=<optimized out>, filename=<optimized out>, flags=<optimized out>, mode=<optimized out>, do_retry=<optimized out>, retry_name=<optimized out>, retry_port=<optimized out>, retry_port_type=<optimized out>) at ../../libnetfs/dir-lookup.c:175 Message-Id: <20210524154340.264885-2-bugaevc@gmail.com>
* Use our own variant of 'assert' and 'assert_perror'.Justus Winter2017-08-051-2/+2
| | | | | Our variants print stack traces on failures. This will make locating errors much easier.
* procfs: Provide 'hostinfo'.Justus Winter2017-08-051-1/+59
| | | | | * procfs/rootdir.c (rootdir_gc_hostinfo): New function. (rootdir_entries): New entry 'hostinfo'.
* procfs: Remove superfluous calls.Justus Winter2017-06-031-8/+0
| | | | | * procfs/rootdir.c (rootdir_gc_vmstat): Remove superfluous 'host_info' calls.
* procfs: provide magic retry response for /proc/selfJustus Winter2016-12-191-19/+4
| | | | | | | | | * hurd/hurd_types.h: Document the magic retry string `pid'. * hurd/paths.h (_HURD_MAGIC): New macro. * procfs/main.c: Remove all code related to faking /proc/self. * procfs/main.h: Likewise. * procfs/rootdir.c: Likewise. Instead, return the magic retry response `pid' for the `self' node.
* procfs: Gracefully degrade meminfo.Justus Winter2016-10-151-12/+32
| | | | | * procfs/rootdir.c (rootdir_gc_meminfo): Just omit the swap information if the default pager is unreachable.
* Use swapon path as pager partition pathSamuel Thibault2016-03-241-1/+1
| | | | | | | | | | | When /dev/hd* entries are parted-partition storeio, the store name is only the disk name, thus not unique. We should just use the path being used instead. * sutils/swapon.c (swaponoff): Use `file' instead of `store->name' to default_pager_paging_file. (main): Drop hardcoded "/dev/". * procfs/rootdir.c (rootdir_gc_swaps): Drop hardcoded "/dev/".
* Fix swap information numbersSamuel Thibault2016-03-241-1/+1
| | | | | | * procfs/rootdir.c (rootdir_gc_swaps): Fix default_pager_storage_info call parameter order. * sutils/swapon.c (main): Likewise.
* Add getting swap information from swapon and procfsSamuel Thibault2016-03-161-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | * hurd/default_pager.defs (default_pager_storage_info): New RPC. * hurd/default_pager_reply.defs: Skip default_pager_storage_info RPC. * hurd/default_pager_types.h: Include <mach/machine/vm_types.h>. (vm_size_array_t): New type. * mach-defpager/priv.h (part): Add `name' field. * mach-defpager/default_pager.c (new_partition): Allocate and fill `part->name' field. Free it on error. (destroy_paging_partition): Free `part->name' field. (S_default_pager_storage_info): New function. * procfs/Makefile (SRCS): Add default_pagerUser.c. * procfs/rootdir.c: Include "default_pager_U.h". (rootdir_gc_swaps): New function. (rootdir_entries): Add "swaps" entry. * sutils/swapon.c: Include <argz.h> (show): New variable. (options): Add --show/-S option. (def_pager, dev_master): New variables (swaponoff): Move getting `def_pager' to... (get_def_pager): ... new function. (main): Support 'S' option. * trans/proxy-defpager.c (S_default_pager_storage_info): New function.
* procfs: adapt to kernel interface changeJustus Winter2016-02-231-5/+4
| | | | | | | procfs makes use of the debug interface which is subject to change. * procfs/rootdir.c (rootdir_gc_slabinfo): The flag CACHE_FLAGS_NO_RECLAIM is no longer used.
* fix compiler warnings in hurd/procfsFlavio Cruz2015-12-291-5/+5
| | | | | | | | procfs: Fix compiler warnings. * include/sys/procfs.h: Change uintptr_t to vm_address_t. * procfs/process.c: Fix format strings. * procfs/rootdir.c: Add missing casts.
* procfs: reorganize rootdir.cJustus Winter2014-09-291-76/+77
| | | | | * procfs/rootdir.c: Move the translator linkage code to the appropriate location.
* procfs: generalize the translator linkage codeJustus Winter2014-09-291-20/+42
| | | | | | | | | | | | | | | | | Generalize the translator linkage code previously introduced for the `mounts' node. * procfs/rootdir.c (struct procfs_translated_node_ops): New specialized node operations structure for translated nodes. (rootdir_mounts_make_node): Generalize and rename to rootdir_make_translated_node. Also, pass the entry_hook to procfs_make_node so that... (rootdir_mounts_get_translator): ... can be generalized to rootdir_translated_node_get_translator and read the argz vector from the hooked structure. (ROOTDIR_DEFINE_TRANSLATED_NODE): New convenience macro to define translated nodes. (rootdir_entries): Use the new code for the `mounts' node.
* procfs: do not test whether /hurd/mtab existsJustus Winter2014-09-291-10/+0
| | | | | | | | Now that procfs is merged into the Hurd repository we can just assume that the mtab translator exists. * procfs/rootdir.c (rootdir_mounts_exists): Drop function. (rootdir_entries): Adjust accordingly.
* procfs: implement /proc/filesystemsJustus Winter2014-09-291-1/+60
| | | | | * procfs/rootdir.c (rootdir_gc_filesystems): New function. (rootdir_entries): Use the new function to implement /proc/filesystems.
* hurd: add symbolic name for the mtab translatorJustus Winter2014-09-221-5/+2
| | | | | | * hurd/paths.h (_HURD_MTAB): New macro. * procfs/rootdir.c (rootdir_mounts_get_translator): Use the new macro. (rootdir_mounts_exists): Likewise.
* Prepare the procfs translator to be merged into the Hurd sourcesJustus Winter2014-06-151-0/+661
Move the procfs translator to its own subdirectory 'procfs'. This is the last commit to this repository. Development of the procfs translator will continue in the main Hurd repository. * procfs/Makefile: Replace the standalone Makefile with the one from the Debian packaging repository.