sysctl.c 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674
  1. /*
  2. * sysctl.c: General linux system control interface
  3. *
  4. * Begun 24 March 1995, Stephen Tweedie
  5. * Added /proc support, Dec 1995
  6. * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
  7. * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
  8. * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
  9. * Dynamic registration fixes, Stephen Tweedie.
  10. * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
  11. * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
  12. * Horn.
  13. * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
  14. * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
  15. * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
  16. * Wendling.
  17. * The list_for_each() macro wasn't appropriate for the sysctl loop.
  18. * Removed it and replaced it with older style, 03/23/00, Bill Wendling
  19. */
  20. #include <linux/module.h>
  21. #include <linux/mm.h>
  22. #include <linux/swap.h>
  23. #include <linux/slab.h>
  24. #include <linux/sysctl.h>
  25. #include <linux/proc_fs.h>
  26. #include <linux/security.h>
  27. #include <linux/ctype.h>
  28. #include <linux/kmemcheck.h>
  29. #include <linux/fs.h>
  30. #include <linux/init.h>
  31. #include <linux/kernel.h>
  32. #include <linux/kobject.h>
  33. #include <linux/net.h>
  34. #include <linux/sysrq.h>
  35. #include <linux/highuid.h>
  36. #include <linux/writeback.h>
  37. #include <linux/ratelimit.h>
  38. #include <linux/hugetlb.h>
  39. #include <linux/initrd.h>
  40. #include <linux/key.h>
  41. #include <linux/times.h>
  42. #include <linux/limits.h>
  43. #include <linux/dcache.h>
  44. #include <linux/syscalls.h>
  45. #include <linux/vmstat.h>
  46. #include <linux/nfs_fs.h>
  47. #include <linux/acpi.h>
  48. #include <linux/reboot.h>
  49. #include <linux/ftrace.h>
  50. #include <linux/slow-work.h>
  51. #include <linux/perf_event.h>
  52. #include <asm/uaccess.h>
  53. #include <asm/processor.h>
  54. #ifdef CONFIG_X86
  55. #include <asm/nmi.h>
  56. #include <asm/stacktrace.h>
  57. #include <asm/io.h>
  58. #endif
  59. #if defined(CONFIG_SYSCTL)
  60. /* External variables not in a header file. */
  61. extern int C_A_D;
  62. extern int print_fatal_signals;
  63. extern int sysctl_overcommit_memory;
  64. extern int sysctl_overcommit_ratio;
  65. extern int sysctl_panic_on_oom;
  66. extern int sysctl_oom_kill_allocating_task;
  67. extern int sysctl_oom_dump_tasks;
  68. extern int max_threads;
  69. extern int core_uses_pid;
  70. extern int suid_dumpable;
  71. extern char core_pattern[];
  72. extern unsigned int core_pipe_limit;
  73. extern int pid_max;
  74. extern int min_free_kbytes;
  75. extern int pid_max_min, pid_max_max;
  76. extern int sysctl_drop_caches;
  77. extern int percpu_pagelist_fraction;
  78. extern int compat_log;
  79. extern int latencytop_enabled;
  80. extern int sysctl_nr_open_min, sysctl_nr_open_max;
  81. #ifndef CONFIG_MMU
  82. extern int sysctl_nr_trim_pages;
  83. #endif
  84. #ifdef CONFIG_RCU_TORTURE_TEST
  85. extern int rcutorture_runnable;
  86. #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
  87. #ifdef CONFIG_BLOCK
  88. extern int blk_iopoll_enabled;
  89. #endif
  90. /* Constants used for minimum and maximum */
  91. #ifdef CONFIG_DETECT_SOFTLOCKUP
  92. static int sixty = 60;
  93. static int neg_one = -1;
  94. #endif
  95. static int zero;
  96. static int __maybe_unused one = 1;
  97. static int __maybe_unused two = 2;
  98. static unsigned long one_ul = 1;
  99. static int one_hundred = 100;
  100. #ifdef CONFIG_PRINTK
  101. static int ten_thousand = 10000;
  102. #endif
  103. /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
  104. static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
  105. /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
  106. static int maxolduid = 65535;
  107. static int minolduid;
  108. static int min_percpu_pagelist_fract = 8;
  109. static int ngroups_max = NGROUPS_MAX;
  110. #ifdef CONFIG_MODULES
  111. extern char modprobe_path[];
  112. extern int modules_disabled;
  113. #endif
  114. #ifdef CONFIG_CHR_DEV_SG
  115. extern int sg_big_buff;
  116. #endif
  117. #ifdef CONFIG_SPARC
  118. #include <asm/system.h>
  119. #endif
  120. #ifdef CONFIG_SPARC64
  121. extern int sysctl_tsb_ratio;
  122. #endif
  123. #ifdef __hppa__
  124. extern int pwrsw_enabled;
  125. extern int unaligned_enabled;
  126. #endif
  127. #ifdef CONFIG_S390
  128. #ifdef CONFIG_MATHEMU
  129. extern int sysctl_ieee_emulation_warnings;
  130. #endif
  131. extern int sysctl_userprocess_debug;
  132. extern int spin_retry;
  133. #endif
  134. #ifdef CONFIG_BSD_PROCESS_ACCT
  135. extern int acct_parm[];
  136. #endif
  137. #ifdef CONFIG_IA64
  138. extern int no_unaligned_warning;
  139. extern int unaligned_dump_stack;
  140. #endif
  141. extern struct ratelimit_state printk_ratelimit_state;
  142. #ifdef CONFIG_RT_MUTEXES
  143. extern int max_lock_depth;
  144. #endif
  145. #ifdef CONFIG_PROC_SYSCTL
  146. static int proc_do_cad_pid(struct ctl_table *table, int write,
  147. void __user *buffer, size_t *lenp, loff_t *ppos);
  148. static int proc_taint(struct ctl_table *table, int write,
  149. void __user *buffer, size_t *lenp, loff_t *ppos);
  150. #endif
  151. static struct ctl_table root_table[];
  152. static struct ctl_table_root sysctl_table_root;
  153. static struct ctl_table_header root_table_header = {
  154. .count = 1,
  155. .ctl_table = root_table,
  156. .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
  157. .root = &sysctl_table_root,
  158. .set = &sysctl_table_root.default_set,
  159. };
  160. static struct ctl_table_root sysctl_table_root = {
  161. .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
  162. .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
  163. };
  164. static struct ctl_table kern_table[];
  165. static struct ctl_table vm_table[];
  166. static struct ctl_table fs_table[];
  167. static struct ctl_table debug_table[];
  168. static struct ctl_table dev_table[];
  169. extern struct ctl_table random_table[];
  170. #ifdef CONFIG_INOTIFY_USER
  171. extern struct ctl_table inotify_table[];
  172. #endif
  173. #ifdef CONFIG_EPOLL
  174. extern struct ctl_table epoll_table[];
  175. #endif
  176. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  177. int sysctl_legacy_va_layout;
  178. #endif
  179. extern int prove_locking;
  180. extern int lock_stat;
  181. /* The default sysctl tables: */
  182. static struct ctl_table root_table[] = {
  183. {
  184. .procname = "kernel",
  185. .mode = 0555,
  186. .child = kern_table,
  187. },
  188. {
  189. .procname = "vm",
  190. .mode = 0555,
  191. .child = vm_table,
  192. },
  193. {
  194. .procname = "fs",
  195. .mode = 0555,
  196. .child = fs_table,
  197. },
  198. {
  199. .procname = "debug",
  200. .mode = 0555,
  201. .child = debug_table,
  202. },
  203. {
  204. .procname = "dev",
  205. .mode = 0555,
  206. .child = dev_table,
  207. },
  208. /*
  209. * NOTE: do not add new entries to this table unless you have read
  210. * Documentation/sysctl/ctl_unnumbered.txt
  211. */
  212. { }
  213. };
  214. #ifdef CONFIG_SCHED_DEBUG
  215. static int min_sched_granularity_ns = 100000; /* 100 usecs */
  216. static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
  217. static int min_wakeup_granularity_ns; /* 0 usecs */
  218. static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
  219. static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
  220. static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
  221. static int min_sched_shares_ratelimit = 100000; /* 100 usec */
  222. static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
  223. #endif
  224. static struct ctl_table kern_table[] = {
  225. {
  226. .procname = "sched_child_runs_first",
  227. .data = &sysctl_sched_child_runs_first,
  228. .maxlen = sizeof(unsigned int),
  229. .mode = 0644,
  230. .proc_handler = proc_dointvec,
  231. },
  232. #ifdef CONFIG_SCHED_DEBUG
  233. {
  234. .procname = "sched_min_granularity_ns",
  235. .data = &sysctl_sched_min_granularity,
  236. .maxlen = sizeof(unsigned int),
  237. .mode = 0644,
  238. .proc_handler = sched_proc_update_handler,
  239. .extra1 = &min_sched_granularity_ns,
  240. .extra2 = &max_sched_granularity_ns,
  241. },
  242. {
  243. .procname = "sched_latency_ns",
  244. .data = &sysctl_sched_latency,
  245. .maxlen = sizeof(unsigned int),
  246. .mode = 0644,
  247. .proc_handler = sched_proc_update_handler,
  248. .extra1 = &min_sched_granularity_ns,
  249. .extra2 = &max_sched_granularity_ns,
  250. },
  251. {
  252. .procname = "sched_wakeup_granularity_ns",
  253. .data = &sysctl_sched_wakeup_granularity,
  254. .maxlen = sizeof(unsigned int),
  255. .mode = 0644,
  256. .proc_handler = sched_proc_update_handler,
  257. .extra1 = &min_wakeup_granularity_ns,
  258. .extra2 = &max_wakeup_granularity_ns,
  259. },
  260. {
  261. .procname = "sched_shares_ratelimit",
  262. .data = &sysctl_sched_shares_ratelimit,
  263. .maxlen = sizeof(unsigned int),
  264. .mode = 0644,
  265. .proc_handler = sched_proc_update_handler,
  266. .extra1 = &min_sched_shares_ratelimit,
  267. .extra2 = &max_sched_shares_ratelimit,
  268. },
  269. {
  270. .procname = "sched_tunable_scaling",
  271. .data = &sysctl_sched_tunable_scaling,
  272. .maxlen = sizeof(enum sched_tunable_scaling),
  273. .mode = 0644,
  274. .proc_handler = sched_proc_update_handler,
  275. .extra1 = &min_sched_tunable_scaling,
  276. .extra2 = &max_sched_tunable_scaling,
  277. },
  278. {
  279. .procname = "sched_shares_thresh",
  280. .data = &sysctl_sched_shares_thresh,
  281. .maxlen = sizeof(unsigned int),
  282. .mode = 0644,
  283. .proc_handler = proc_dointvec_minmax,
  284. .extra1 = &zero,
  285. },
  286. {
  287. .procname = "sched_migration_cost",
  288. .data = &sysctl_sched_migration_cost,
  289. .maxlen = sizeof(unsigned int),
  290. .mode = 0644,
  291. .proc_handler = proc_dointvec,
  292. },
  293. {
  294. .procname = "sched_nr_migrate",
  295. .data = &sysctl_sched_nr_migrate,
  296. .maxlen = sizeof(unsigned int),
  297. .mode = 0644,
  298. .proc_handler = proc_dointvec,
  299. },
  300. {
  301. .procname = "sched_time_avg",
  302. .data = &sysctl_sched_time_avg,
  303. .maxlen = sizeof(unsigned int),
  304. .mode = 0644,
  305. .proc_handler = proc_dointvec,
  306. },
  307. {
  308. .procname = "timer_migration",
  309. .data = &sysctl_timer_migration,
  310. .maxlen = sizeof(unsigned int),
  311. .mode = 0644,
  312. .proc_handler = proc_dointvec_minmax,
  313. .extra1 = &zero,
  314. .extra2 = &one,
  315. },
  316. #endif
  317. {
  318. .procname = "sched_rt_period_us",
  319. .data = &sysctl_sched_rt_period,
  320. .maxlen = sizeof(unsigned int),
  321. .mode = 0644,
  322. .proc_handler = sched_rt_handler,
  323. },
  324. {
  325. .procname = "sched_rt_runtime_us",
  326. .data = &sysctl_sched_rt_runtime,
  327. .maxlen = sizeof(int),
  328. .mode = 0644,
  329. .proc_handler = sched_rt_handler,
  330. },
  331. {
  332. .procname = "sched_compat_yield",
  333. .data = &sysctl_sched_compat_yield,
  334. .maxlen = sizeof(unsigned int),
  335. .mode = 0644,
  336. .proc_handler = proc_dointvec,
  337. },
  338. #ifdef CONFIG_PROVE_LOCKING
  339. {
  340. .procname = "prove_locking",
  341. .data = &prove_locking,
  342. .maxlen = sizeof(int),
  343. .mode = 0644,
  344. .proc_handler = proc_dointvec,
  345. },
  346. #endif
  347. #ifdef CONFIG_LOCK_STAT
  348. {
  349. .procname = "lock_stat",
  350. .data = &lock_stat,
  351. .maxlen = sizeof(int),
  352. .mode = 0644,
  353. .proc_handler = proc_dointvec,
  354. },
  355. #endif
  356. {
  357. .procname = "panic",
  358. .data = &panic_timeout,
  359. .maxlen = sizeof(int),
  360. .mode = 0644,
  361. .proc_handler = proc_dointvec,
  362. },
  363. {
  364. .procname = "core_uses_pid",
  365. .data = &core_uses_pid,
  366. .maxlen = sizeof(int),
  367. .mode = 0644,
  368. .proc_handler = proc_dointvec,
  369. },
  370. {
  371. .procname = "core_pattern",
  372. .data = core_pattern,
  373. .maxlen = CORENAME_MAX_SIZE,
  374. .mode = 0644,
  375. .proc_handler = proc_dostring,
  376. },
  377. {
  378. .procname = "core_pipe_limit",
  379. .data = &core_pipe_limit,
  380. .maxlen = sizeof(unsigned int),
  381. .mode = 0644,
  382. .proc_handler = proc_dointvec,
  383. },
  384. #ifdef CONFIG_PROC_SYSCTL
  385. {
  386. .procname = "tainted",
  387. .maxlen = sizeof(long),
  388. .mode = 0644,
  389. .proc_handler = proc_taint,
  390. },
  391. #endif
  392. #ifdef CONFIG_LATENCYTOP
  393. {
  394. .procname = "latencytop",
  395. .data = &latencytop_enabled,
  396. .maxlen = sizeof(int),
  397. .mode = 0644,
  398. .proc_handler = proc_dointvec,
  399. },
  400. #endif
  401. #ifdef CONFIG_BLK_DEV_INITRD
  402. {
  403. .procname = "real-root-dev",
  404. .data = &real_root_dev,
  405. .maxlen = sizeof(int),
  406. .mode = 0644,
  407. .proc_handler = proc_dointvec,
  408. },
  409. #endif
  410. {
  411. .procname = "print-fatal-signals",
  412. .data = &print_fatal_signals,
  413. .maxlen = sizeof(int),
  414. .mode = 0644,
  415. .proc_handler = proc_dointvec,
  416. },
  417. #ifdef CONFIG_SPARC
  418. {
  419. .procname = "reboot-cmd",
  420. .data = reboot_command,
  421. .maxlen = 256,
  422. .mode = 0644,
  423. .proc_handler = proc_dostring,
  424. },
  425. {
  426. .procname = "stop-a",
  427. .data = &stop_a_enabled,
  428. .maxlen = sizeof (int),
  429. .mode = 0644,
  430. .proc_handler = proc_dointvec,
  431. },
  432. {
  433. .procname = "scons-poweroff",
  434. .data = &scons_pwroff,
  435. .maxlen = sizeof (int),
  436. .mode = 0644,
  437. .proc_handler = proc_dointvec,
  438. },
  439. #endif
  440. #ifdef CONFIG_SPARC64
  441. {
  442. .procname = "tsb-ratio",
  443. .data = &sysctl_tsb_ratio,
  444. .maxlen = sizeof (int),
  445. .mode = 0644,
  446. .proc_handler = proc_dointvec,
  447. },
  448. #endif
  449. #ifdef __hppa__
  450. {
  451. .procname = "soft-power",
  452. .data = &pwrsw_enabled,
  453. .maxlen = sizeof (int),
  454. .mode = 0644,
  455. .proc_handler = proc_dointvec,
  456. },
  457. {
  458. .procname = "unaligned-trap",
  459. .data = &unaligned_enabled,
  460. .maxlen = sizeof (int),
  461. .mode = 0644,
  462. .proc_handler = proc_dointvec,
  463. },
  464. #endif
  465. {
  466. .procname = "ctrl-alt-del",
  467. .data = &C_A_D,
  468. .maxlen = sizeof(int),
  469. .mode = 0644,
  470. .proc_handler = proc_dointvec,
  471. },
  472. #ifdef CONFIG_FUNCTION_TRACER
  473. {
  474. .procname = "ftrace_enabled",
  475. .data = &ftrace_enabled,
  476. .maxlen = sizeof(int),
  477. .mode = 0644,
  478. .proc_handler = ftrace_enable_sysctl,
  479. },
  480. #endif
  481. #ifdef CONFIG_STACK_TRACER
  482. {
  483. .procname = "stack_tracer_enabled",
  484. .data = &stack_tracer_enabled,
  485. .maxlen = sizeof(int),
  486. .mode = 0644,
  487. .proc_handler = stack_trace_sysctl,
  488. },
  489. #endif
  490. #ifdef CONFIG_TRACING
  491. {
  492. .procname = "ftrace_dump_on_oops",
  493. .data = &ftrace_dump_on_oops,
  494. .maxlen = sizeof(int),
  495. .mode = 0644,
  496. .proc_handler = proc_dointvec,
  497. },
  498. #endif
  499. #ifdef CONFIG_MODULES
  500. {
  501. .procname = "modprobe",
  502. .data = &modprobe_path,
  503. .maxlen = KMOD_PATH_LEN,
  504. .mode = 0644,
  505. .proc_handler = proc_dostring,
  506. },
  507. {
  508. .procname = "modules_disabled",
  509. .data = &modules_disabled,
  510. .maxlen = sizeof(int),
  511. .mode = 0644,
  512. /* only handle a transition from default "0" to "1" */
  513. .proc_handler = proc_dointvec_minmax,
  514. .extra1 = &one,
  515. .extra2 = &one,
  516. },
  517. #endif
  518. #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
  519. {
  520. .procname = "hotplug",
  521. .data = &uevent_helper,
  522. .maxlen = UEVENT_HELPER_PATH_LEN,
  523. .mode = 0644,
  524. .proc_handler = proc_dostring,
  525. },
  526. #endif
  527. #ifdef CONFIG_CHR_DEV_SG
  528. {
  529. .procname = "sg-big-buff",
  530. .data = &sg_big_buff,
  531. .maxlen = sizeof (int),
  532. .mode = 0444,
  533. .proc_handler = proc_dointvec,
  534. },
  535. #endif
  536. #ifdef CONFIG_BSD_PROCESS_ACCT
  537. {
  538. .procname = "acct",
  539. .data = &acct_parm,
  540. .maxlen = 3*sizeof(int),
  541. .mode = 0644,
  542. .proc_handler = proc_dointvec,
  543. },
  544. #endif
  545. #ifdef CONFIG_MAGIC_SYSRQ
  546. {
  547. .procname = "sysrq",
  548. .data = &__sysrq_enabled,
  549. .maxlen = sizeof (int),
  550. .mode = 0644,
  551. .proc_handler = proc_dointvec,
  552. },
  553. #endif
  554. #ifdef CONFIG_PROC_SYSCTL
  555. {
  556. .procname = "cad_pid",
  557. .data = NULL,
  558. .maxlen = sizeof (int),
  559. .mode = 0600,
  560. .proc_handler = proc_do_cad_pid,
  561. },
  562. #endif
  563. {
  564. .procname = "threads-max",
  565. .data = &max_threads,
  566. .maxlen = sizeof(int),
  567. .mode = 0644,
  568. .proc_handler = proc_dointvec,
  569. },
  570. {
  571. .procname = "random",
  572. .mode = 0555,
  573. .child = random_table,
  574. },
  575. {
  576. .procname = "overflowuid",
  577. .data = &overflowuid,
  578. .maxlen = sizeof(int),
  579. .mode = 0644,
  580. .proc_handler = proc_dointvec_minmax,
  581. .extra1 = &minolduid,
  582. .extra2 = &maxolduid,
  583. },
  584. {
  585. .procname = "overflowgid",
  586. .data = &overflowgid,
  587. .maxlen = sizeof(int),
  588. .mode = 0644,
  589. .proc_handler = proc_dointvec_minmax,
  590. .extra1 = &minolduid,
  591. .extra2 = &maxolduid,
  592. },
  593. #ifdef CONFIG_S390
  594. #ifdef CONFIG_MATHEMU
  595. {
  596. .procname = "ieee_emulation_warnings",
  597. .data = &sysctl_ieee_emulation_warnings,
  598. .maxlen = sizeof(int),
  599. .mode = 0644,
  600. .proc_handler = proc_dointvec,
  601. },
  602. #endif
  603. {
  604. .procname = "userprocess_debug",
  605. .data = &sysctl_userprocess_debug,
  606. .maxlen = sizeof(int),
  607. .mode = 0644,
  608. .proc_handler = proc_dointvec,
  609. },
  610. #endif
  611. {
  612. .procname = "pid_max",
  613. .data = &pid_max,
  614. .maxlen = sizeof (int),
  615. .mode = 0644,
  616. .proc_handler = proc_dointvec_minmax,
  617. .extra1 = &pid_max_min,
  618. .extra2 = &pid_max_max,
  619. },
  620. {
  621. .procname = "panic_on_oops",
  622. .data = &panic_on_oops,
  623. .maxlen = sizeof(int),
  624. .mode = 0644,
  625. .proc_handler = proc_dointvec,
  626. },
  627. #if defined CONFIG_PRINTK
  628. {
  629. .procname = "printk",
  630. .data = &console_loglevel,
  631. .maxlen = 4*sizeof(int),
  632. .mode = 0644,
  633. .proc_handler = proc_dointvec,
  634. },
  635. {
  636. .procname = "printk_ratelimit",
  637. .data = &printk_ratelimit_state.interval,
  638. .maxlen = sizeof(int),
  639. .mode = 0644,
  640. .proc_handler = proc_dointvec_jiffies,
  641. },
  642. {
  643. .procname = "printk_ratelimit_burst",
  644. .data = &printk_ratelimit_state.burst,
  645. .maxlen = sizeof(int),
  646. .mode = 0644,
  647. .proc_handler = proc_dointvec,
  648. },
  649. {
  650. .procname = "printk_delay",
  651. .data = &printk_delay_msec,
  652. .maxlen = sizeof(int),
  653. .mode = 0644,
  654. .proc_handler = proc_dointvec_minmax,
  655. .extra1 = &zero,
  656. .extra2 = &ten_thousand,
  657. },
  658. #endif
  659. {
  660. .procname = "ngroups_max",
  661. .data = &ngroups_max,
  662. .maxlen = sizeof (int),
  663. .mode = 0444,
  664. .proc_handler = proc_dointvec,
  665. },
  666. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
  667. {
  668. .procname = "unknown_nmi_panic",
  669. .data = &unknown_nmi_panic,
  670. .maxlen = sizeof (int),
  671. .mode = 0644,
  672. .proc_handler = proc_dointvec,
  673. },
  674. {
  675. .procname = "nmi_watchdog",
  676. .data = &nmi_watchdog_enabled,
  677. .maxlen = sizeof (int),
  678. .mode = 0644,
  679. .proc_handler = proc_nmi_enabled,
  680. },
  681. #endif
  682. #if defined(CONFIG_X86)
  683. {
  684. .procname = "panic_on_unrecovered_nmi",
  685. .data = &panic_on_unrecovered_nmi,
  686. .maxlen = sizeof(int),
  687. .mode = 0644,
  688. .proc_handler = proc_dointvec,
  689. },
  690. {
  691. .procname = "panic_on_io_nmi",
  692. .data = &panic_on_io_nmi,
  693. .maxlen = sizeof(int),
  694. .mode = 0644,
  695. .proc_handler = proc_dointvec,
  696. },
  697. {
  698. .procname = "bootloader_type",
  699. .data = &bootloader_type,
  700. .maxlen = sizeof (int),
  701. .mode = 0444,
  702. .proc_handler = proc_dointvec,
  703. },
  704. {
  705. .procname = "bootloader_version",
  706. .data = &bootloader_version,
  707. .maxlen = sizeof (int),
  708. .mode = 0444,
  709. .proc_handler = proc_dointvec,
  710. },
  711. {
  712. .procname = "kstack_depth_to_print",
  713. .data = &kstack_depth_to_print,
  714. .maxlen = sizeof(int),
  715. .mode = 0644,
  716. .proc_handler = proc_dointvec,
  717. },
  718. {
  719. .procname = "io_delay_type",
  720. .data = &io_delay_type,
  721. .maxlen = sizeof(int),
  722. .mode = 0644,
  723. .proc_handler = proc_dointvec,
  724. },
  725. #endif
  726. #if defined(CONFIG_MMU)
  727. {
  728. .procname = "randomize_va_space",
  729. .data = &randomize_va_space,
  730. .maxlen = sizeof(int),
  731. .mode = 0644,
  732. .proc_handler = proc_dointvec,
  733. },
  734. #endif
  735. #if defined(CONFIG_S390) && defined(CONFIG_SMP)
  736. {
  737. .procname = "spin_retry",
  738. .data = &spin_retry,
  739. .maxlen = sizeof (int),
  740. .mode = 0644,
  741. .proc_handler = proc_dointvec,
  742. },
  743. #endif
  744. #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
  745. {
  746. .procname = "acpi_video_flags",
  747. .data = &acpi_realmode_flags,
  748. .maxlen = sizeof (unsigned long),
  749. .mode = 0644,
  750. .proc_handler = proc_doulongvec_minmax,
  751. },
  752. #endif
  753. #ifdef CONFIG_IA64
  754. {
  755. .procname = "ignore-unaligned-usertrap",
  756. .data = &no_unaligned_warning,
  757. .maxlen = sizeof (int),
  758. .mode = 0644,
  759. .proc_handler = proc_dointvec,
  760. },
  761. {
  762. .procname = "unaligned-dump-stack",
  763. .data = &unaligned_dump_stack,
  764. .maxlen = sizeof (int),
  765. .mode = 0644,
  766. .proc_handler = proc_dointvec,
  767. },
  768. #endif
  769. #ifdef CONFIG_DETECT_SOFTLOCKUP
  770. {
  771. .procname = "softlockup_panic",
  772. .data = &softlockup_panic,
  773. .maxlen = sizeof(int),
  774. .mode = 0644,
  775. .proc_handler = proc_dointvec_minmax,
  776. .extra1 = &zero,
  777. .extra2 = &one,
  778. },
  779. {
  780. .procname = "softlockup_thresh",
  781. .data = &softlockup_thresh,
  782. .maxlen = sizeof(int),
  783. .mode = 0644,
  784. .proc_handler = proc_dosoftlockup_thresh,
  785. .extra1 = &neg_one,
  786. .extra2 = &sixty,
  787. },
  788. #endif
  789. #ifdef CONFIG_DETECT_HUNG_TASK
  790. {
  791. .procname = "hung_task_panic",
  792. .data = &sysctl_hung_task_panic,
  793. .maxlen = sizeof(int),
  794. .mode = 0644,
  795. .proc_handler = proc_dointvec_minmax,
  796. .extra1 = &zero,
  797. .extra2 = &one,
  798. },
  799. {
  800. .procname = "hung_task_check_count",
  801. .data = &sysctl_hung_task_check_count,
  802. .maxlen = sizeof(unsigned long),
  803. .mode = 0644,
  804. .proc_handler = proc_doulongvec_minmax,
  805. },
  806. {
  807. .procname = "hung_task_timeout_secs",
  808. .data = &sysctl_hung_task_timeout_secs,
  809. .maxlen = sizeof(unsigned long),
  810. .mode = 0644,
  811. .proc_handler = proc_dohung_task_timeout_secs,
  812. },
  813. {
  814. .procname = "hung_task_warnings",
  815. .data = &sysctl_hung_task_warnings,
  816. .maxlen = sizeof(unsigned long),
  817. .mode = 0644,
  818. .proc_handler = proc_doulongvec_minmax,
  819. },
  820. #endif
  821. #ifdef CONFIG_COMPAT
  822. {
  823. .procname = "compat-log",
  824. .data = &compat_log,
  825. .maxlen = sizeof (int),
  826. .mode = 0644,
  827. .proc_handler = proc_dointvec,
  828. },
  829. #endif
  830. #ifdef CONFIG_RT_MUTEXES
  831. {
  832. .procname = "max_lock_depth",
  833. .data = &max_lock_depth,
  834. .maxlen = sizeof(int),
  835. .mode = 0644,
  836. .proc_handler = proc_dointvec,
  837. },
  838. #endif
  839. {
  840. .procname = "poweroff_cmd",
  841. .data = &poweroff_cmd,
  842. .maxlen = POWEROFF_CMD_PATH_LEN,
  843. .mode = 0644,
  844. .proc_handler = proc_dostring,
  845. },
  846. #ifdef CONFIG_KEYS
  847. {
  848. .procname = "keys",
  849. .mode = 0555,
  850. .child = key_sysctls,
  851. },
  852. #endif
  853. #ifdef CONFIG_RCU_TORTURE_TEST
  854. {
  855. .procname = "rcutorture_runnable",
  856. .data = &rcutorture_runnable,
  857. .maxlen = sizeof(int),
  858. .mode = 0644,
  859. .proc_handler = proc_dointvec,
  860. },
  861. #endif
  862. #ifdef CONFIG_SLOW_WORK
  863. {
  864. .procname = "slow-work",
  865. .mode = 0555,
  866. .child = slow_work_sysctls,
  867. },
  868. #endif
  869. #ifdef CONFIG_PERF_EVENTS
  870. {
  871. .procname = "perf_event_paranoid",
  872. .data = &sysctl_perf_event_paranoid,
  873. .maxlen = sizeof(sysctl_perf_event_paranoid),
  874. .mode = 0644,
  875. .proc_handler = proc_dointvec,
  876. },
  877. {
  878. .procname = "perf_event_mlock_kb",
  879. .data = &sysctl_perf_event_mlock,
  880. .maxlen = sizeof(sysctl_perf_event_mlock),
  881. .mode = 0644,
  882. .proc_handler = proc_dointvec,
  883. },
  884. {
  885. .procname = "perf_event_max_sample_rate",
  886. .data = &sysctl_perf_event_sample_rate,
  887. .maxlen = sizeof(sysctl_perf_event_sample_rate),
  888. .mode = 0644,
  889. .proc_handler = proc_dointvec,
  890. },
  891. #endif
  892. #ifdef CONFIG_KMEMCHECK
  893. {
  894. .procname = "kmemcheck",
  895. .data = &kmemcheck_enabled,
  896. .maxlen = sizeof(int),
  897. .mode = 0644,
  898. .proc_handler = proc_dointvec,
  899. },
  900. #endif
  901. #ifdef CONFIG_BLOCK
  902. {
  903. .procname = "blk_iopoll",
  904. .data = &blk_iopoll_enabled,
  905. .maxlen = sizeof(int),
  906. .mode = 0644,
  907. .proc_handler = proc_dointvec,
  908. },
  909. #endif
  910. /*
  911. * NOTE: do not add new entries to this table unless you have read
  912. * Documentation/sysctl/ctl_unnumbered.txt
  913. */
  914. { }
  915. };
  916. static struct ctl_table vm_table[] = {
  917. {
  918. .procname = "overcommit_memory",
  919. .data = &sysctl_overcommit_memory,
  920. .maxlen = sizeof(sysctl_overcommit_memory),
  921. .mode = 0644,
  922. .proc_handler = proc_dointvec,
  923. },
  924. {
  925. .procname = "panic_on_oom",
  926. .data = &sysctl_panic_on_oom,
  927. .maxlen = sizeof(sysctl_panic_on_oom),
  928. .mode = 0644,
  929. .proc_handler = proc_dointvec,
  930. },
  931. {
  932. .procname = "oom_kill_allocating_task",
  933. .data = &sysctl_oom_kill_allocating_task,
  934. .maxlen = sizeof(sysctl_oom_kill_allocating_task),
  935. .mode = 0644,
  936. .proc_handler = proc_dointvec,
  937. },
  938. {
  939. .procname = "oom_dump_tasks",
  940. .data = &sysctl_oom_dump_tasks,
  941. .maxlen = sizeof(sysctl_oom_dump_tasks),
  942. .mode = 0644,
  943. .proc_handler = proc_dointvec,
  944. },
  945. {
  946. .procname = "overcommit_ratio",
  947. .data = &sysctl_overcommit_ratio,
  948. .maxlen = sizeof(sysctl_overcommit_ratio),
  949. .mode = 0644,
  950. .proc_handler = proc_dointvec,
  951. },
  952. {
  953. .procname = "page-cluster",
  954. .data = &page_cluster,
  955. .maxlen = sizeof(int),
  956. .mode = 0644,
  957. .proc_handler = proc_dointvec,
  958. },
  959. {
  960. .procname = "dirty_background_ratio",
  961. .data = &dirty_background_ratio,
  962. .maxlen = sizeof(dirty_background_ratio),
  963. .mode = 0644,
  964. .proc_handler = dirty_background_ratio_handler,
  965. .extra1 = &zero,
  966. .extra2 = &one_hundred,
  967. },
  968. {
  969. .procname = "dirty_background_bytes",
  970. .data = &dirty_background_bytes,
  971. .maxlen = sizeof(dirty_background_bytes),
  972. .mode = 0644,
  973. .proc_handler = dirty_background_bytes_handler,
  974. .extra1 = &one_ul,
  975. },
  976. {
  977. .procname = "dirty_ratio",
  978. .data = &vm_dirty_ratio,
  979. .maxlen = sizeof(vm_dirty_ratio),
  980. .mode = 0644,
  981. .proc_handler = dirty_ratio_handler,
  982. .extra1 = &zero,
  983. .extra2 = &one_hundred,
  984. },
  985. {
  986. .procname = "dirty_bytes",
  987. .data = &vm_dirty_bytes,
  988. .maxlen = sizeof(vm_dirty_bytes),
  989. .mode = 0644,
  990. .proc_handler = dirty_bytes_handler,
  991. .extra1 = &dirty_bytes_min,
  992. },
  993. {
  994. .procname = "dirty_writeback_centisecs",
  995. .data = &dirty_writeback_interval,
  996. .maxlen = sizeof(dirty_writeback_interval),
  997. .mode = 0644,
  998. .proc_handler = dirty_writeback_centisecs_handler,
  999. },
  1000. {
  1001. .procname = "dirty_expire_centisecs",
  1002. .data = &dirty_expire_interval,
  1003. .maxlen = sizeof(dirty_expire_interval),
  1004. .mode = 0644,
  1005. .proc_handler = proc_dointvec,
  1006. },
  1007. {
  1008. .procname = "nr_pdflush_threads",
  1009. .data = &nr_pdflush_threads,
  1010. .maxlen = sizeof nr_pdflush_threads,
  1011. .mode = 0444 /* read-only*/,
  1012. .proc_handler = proc_dointvec,
  1013. },
  1014. {
  1015. .procname = "swappiness",
  1016. .data = &vm_swappiness,
  1017. .maxlen = sizeof(vm_swappiness),
  1018. .mode = 0644,
  1019. .proc_handler = proc_dointvec_minmax,
  1020. .extra1 = &zero,
  1021. .extra2 = &one_hundred,
  1022. },
  1023. #ifdef CONFIG_HUGETLB_PAGE
  1024. {
  1025. .procname = "nr_hugepages",
  1026. .data = NULL,
  1027. .maxlen = sizeof(unsigned long),
  1028. .mode = 0644,
  1029. .proc_handler = hugetlb_sysctl_handler,
  1030. .extra1 = (void *)&hugetlb_zero,
  1031. .extra2 = (void *)&hugetlb_infinity,
  1032. },
  1033. #ifdef CONFIG_NUMA
  1034. {
  1035. .procname = "nr_hugepages_mempolicy",
  1036. .data = NULL,
  1037. .maxlen = sizeof(unsigned long),
  1038. .mode = 0644,
  1039. .proc_handler = &hugetlb_mempolicy_sysctl_handler,
  1040. .extra1 = (void *)&hugetlb_zero,
  1041. .extra2 = (void *)&hugetlb_infinity,
  1042. },
  1043. #endif
  1044. {
  1045. .procname = "hugetlb_shm_group",
  1046. .data = &sysctl_hugetlb_shm_group,
  1047. .maxlen = sizeof(gid_t),
  1048. .mode = 0644,
  1049. .proc_handler = proc_dointvec,
  1050. },
  1051. {
  1052. .procname = "hugepages_treat_as_movable",
  1053. .data = &hugepages_treat_as_movable,
  1054. .maxlen = sizeof(int),
  1055. .mode = 0644,
  1056. .proc_handler = hugetlb_treat_movable_handler,
  1057. },
  1058. {
  1059. .procname = "nr_overcommit_hugepages",
  1060. .data = NULL,
  1061. .maxlen = sizeof(unsigned long),
  1062. .mode = 0644,
  1063. .proc_handler = hugetlb_overcommit_handler,
  1064. .extra1 = (void *)&hugetlb_zero,
  1065. .extra2 = (void *)&hugetlb_infinity,
  1066. },
  1067. #endif
  1068. {
  1069. .procname = "lowmem_reserve_ratio",
  1070. .data = &sysctl_lowmem_reserve_ratio,
  1071. .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
  1072. .mode = 0644,
  1073. .proc_handler = lowmem_reserve_ratio_sysctl_handler,
  1074. },
  1075. {
  1076. .procname = "drop_caches",
  1077. .data = &sysctl_drop_caches,
  1078. .maxlen = sizeof(int),
  1079. .mode = 0644,
  1080. .proc_handler = drop_caches_sysctl_handler,
  1081. },
  1082. {
  1083. .procname = "min_free_kbytes",
  1084. .data = &min_free_kbytes,
  1085. .maxlen = sizeof(min_free_kbytes),
  1086. .mode = 0644,
  1087. .proc_handler = min_free_kbytes_sysctl_handler,
  1088. .extra1 = &zero,
  1089. },
  1090. {
  1091. .procname = "percpu_pagelist_fraction",
  1092. .data = &percpu_pagelist_fraction,
  1093. .maxlen = sizeof(percpu_pagelist_fraction),
  1094. .mode = 0644,
  1095. .proc_handler = percpu_pagelist_fraction_sysctl_handler,
  1096. .extra1 = &min_percpu_pagelist_fract,
  1097. },
  1098. #ifdef CONFIG_MMU
  1099. {
  1100. .procname = "max_map_count",
  1101. .data = &sysctl_max_map_count,
  1102. .maxlen = sizeof(sysctl_max_map_count),
  1103. .mode = 0644,
  1104. .proc_handler = proc_dointvec
  1105. },
  1106. #else
  1107. {
  1108. .procname = "nr_trim_pages",
  1109. .data = &sysctl_nr_trim_pages,
  1110. .maxlen = sizeof(sysctl_nr_trim_pages),
  1111. .mode = 0644,
  1112. .proc_handler = proc_dointvec_minmax,
  1113. .extra1 = &zero,
  1114. },
  1115. #endif
  1116. {
  1117. .procname = "laptop_mode",
  1118. .data = &laptop_mode,
  1119. .maxlen = sizeof(laptop_mode),
  1120. .mode = 0644,
  1121. .proc_handler = proc_dointvec_jiffies,
  1122. },
  1123. {
  1124. .procname = "block_dump",
  1125. .data = &block_dump,
  1126. .maxlen = sizeof(block_dump),
  1127. .mode = 0644,
  1128. .proc_handler = proc_dointvec,
  1129. .extra1 = &zero,
  1130. },
  1131. {
  1132. .procname = "vfs_cache_pressure",
  1133. .data = &sysctl_vfs_cache_pressure,
  1134. .maxlen = sizeof(sysctl_vfs_cache_pressure),
  1135. .mode = 0644,
  1136. .proc_handler = proc_dointvec,
  1137. .extra1 = &zero,
  1138. },
  1139. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  1140. {
  1141. .procname = "legacy_va_layout",
  1142. .data = &sysctl_legacy_va_layout,
  1143. .maxlen = sizeof(sysctl_legacy_va_layout),
  1144. .mode = 0644,
  1145. .proc_handler = proc_dointvec,
  1146. .extra1 = &zero,
  1147. },
  1148. #endif
  1149. #ifdef CONFIG_NUMA
  1150. {
  1151. .procname = "zone_reclaim_mode",
  1152. .data = &zone_reclaim_mode,
  1153. .maxlen = sizeof(zone_reclaim_mode),
  1154. .mode = 0644,
  1155. .proc_handler = proc_dointvec,
  1156. .extra1 = &zero,
  1157. },
  1158. {
  1159. .procname = "min_unmapped_ratio",
  1160. .data = &sysctl_min_unmapped_ratio,
  1161. .maxlen = sizeof(sysctl_min_unmapped_ratio),
  1162. .mode = 0644,
  1163. .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
  1164. .extra1 = &zero,
  1165. .extra2 = &one_hundred,
  1166. },
  1167. {
  1168. .procname = "min_slab_ratio",
  1169. .data = &sysctl_min_slab_ratio,
  1170. .maxlen = sizeof(sysctl_min_slab_ratio),
  1171. .mode = 0644,
  1172. .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
  1173. .extra1 = &zero,
  1174. .extra2 = &one_hundred,
  1175. },
  1176. #endif
  1177. #ifdef CONFIG_SMP
  1178. {
  1179. .procname = "stat_interval",
  1180. .data = &sysctl_stat_interval,
  1181. .maxlen = sizeof(sysctl_stat_interval),
  1182. .mode = 0644,
  1183. .proc_handler = proc_dointvec_jiffies,
  1184. },
  1185. #endif
  1186. {
  1187. .procname = "mmap_min_addr",
  1188. .data = &dac_mmap_min_addr,
  1189. .maxlen = sizeof(unsigned long),
  1190. .mode = 0644,
  1191. .proc_handler = mmap_min_addr_handler,
  1192. },
  1193. #ifdef CONFIG_NUMA
  1194. {
  1195. .procname = "numa_zonelist_order",
  1196. .data = &numa_zonelist_order,
  1197. .maxlen = NUMA_ZONELIST_ORDER_LEN,
  1198. .mode = 0644,
  1199. .proc_handler = numa_zonelist_order_handler,
  1200. },
  1201. #endif
  1202. #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
  1203. (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
  1204. {
  1205. .procname = "vdso_enabled",
  1206. .data = &vdso_enabled,
  1207. .maxlen = sizeof(vdso_enabled),
  1208. .mode = 0644,
  1209. .proc_handler = proc_dointvec,
  1210. .extra1 = &zero,
  1211. },
  1212. #endif
  1213. #ifdef CONFIG_HIGHMEM
  1214. {
  1215. .procname = "highmem_is_dirtyable",
  1216. .data = &vm_highmem_is_dirtyable,
  1217. .maxlen = sizeof(vm_highmem_is_dirtyable),
  1218. .mode = 0644,
  1219. .proc_handler = proc_dointvec_minmax,
  1220. .extra1 = &zero,
  1221. .extra2 = &one,
  1222. },
  1223. #endif
  1224. {
  1225. .procname = "scan_unevictable_pages",
  1226. .data = &scan_unevictable_pages,
  1227. .maxlen = sizeof(scan_unevictable_pages),
  1228. .mode = 0644,
  1229. .proc_handler = scan_unevictable_handler,
  1230. },
  1231. #ifdef CONFIG_MEMORY_FAILURE
  1232. {
  1233. .procname = "memory_failure_early_kill",
  1234. .data = &sysctl_memory_failure_early_kill,
  1235. .maxlen = sizeof(sysctl_memory_failure_early_kill),
  1236. .mode = 0644,
  1237. .proc_handler = proc_dointvec_minmax,
  1238. .extra1 = &zero,
  1239. .extra2 = &one,
  1240. },
  1241. {
  1242. .procname = "memory_failure_recovery",
  1243. .data = &sysctl_memory_failure_recovery,
  1244. .maxlen = sizeof(sysctl_memory_failure_recovery),
  1245. .mode = 0644,
  1246. .proc_handler = proc_dointvec_minmax,
  1247. .extra1 = &zero,
  1248. .extra2 = &one,
  1249. },
  1250. #endif
  1251. /*
  1252. * NOTE: do not add new entries to this table unless you have read
  1253. * Documentation/sysctl/ctl_unnumbered.txt
  1254. */
  1255. { }
  1256. };
  1257. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1258. static struct ctl_table binfmt_misc_table[] = {
  1259. { }
  1260. };
  1261. #endif
  1262. static struct ctl_table fs_table[] = {
  1263. {
  1264. .procname = "inode-nr",
  1265. .data = &inodes_stat,
  1266. .maxlen = 2*sizeof(int),
  1267. .mode = 0444,
  1268. .proc_handler = proc_dointvec,
  1269. },
  1270. {
  1271. .procname = "inode-state",
  1272. .data = &inodes_stat,
  1273. .maxlen = 7*sizeof(int),
  1274. .mode = 0444,
  1275. .proc_handler = proc_dointvec,
  1276. },
  1277. {
  1278. .procname = "file-nr",
  1279. .data = &files_stat,
  1280. .maxlen = 3*sizeof(int),
  1281. .mode = 0444,
  1282. .proc_handler = proc_nr_files,
  1283. },
  1284. {
  1285. .procname = "file-max",
  1286. .data = &files_stat.max_files,
  1287. .maxlen = sizeof(int),
  1288. .mode = 0644,
  1289. .proc_handler = proc_dointvec,
  1290. },
  1291. {
  1292. .procname = "nr_open",
  1293. .data = &sysctl_nr_open,
  1294. .maxlen = sizeof(int),
  1295. .mode = 0644,
  1296. .proc_handler = proc_dointvec_minmax,
  1297. .extra1 = &sysctl_nr_open_min,
  1298. .extra2 = &sysctl_nr_open_max,
  1299. },
  1300. {
  1301. .procname = "dentry-state",
  1302. .data = &dentry_stat,
  1303. .maxlen = 6*sizeof(int),
  1304. .mode = 0444,
  1305. .proc_handler = proc_dointvec,
  1306. },
  1307. {
  1308. .procname = "overflowuid",
  1309. .data = &fs_overflowuid,
  1310. .maxlen = sizeof(int),
  1311. .mode = 0644,
  1312. .proc_handler = proc_dointvec_minmax,
  1313. .extra1 = &minolduid,
  1314. .extra2 = &maxolduid,
  1315. },
  1316. {
  1317. .procname = "overflowgid",
  1318. .data = &fs_overflowgid,
  1319. .maxlen = sizeof(int),
  1320. .mode = 0644,
  1321. .proc_handler = proc_dointvec_minmax,
  1322. .extra1 = &minolduid,
  1323. .extra2 = &maxolduid,
  1324. },
  1325. #ifdef CONFIG_FILE_LOCKING
  1326. {
  1327. .procname = "leases-enable",
  1328. .data = &leases_enable,
  1329. .maxlen = sizeof(int),
  1330. .mode = 0644,
  1331. .proc_handler = proc_dointvec,
  1332. },
  1333. #endif
  1334. #ifdef CONFIG_DNOTIFY
  1335. {
  1336. .procname = "dir-notify-enable",
  1337. .data = &dir_notify_enable,
  1338. .maxlen = sizeof(int),
  1339. .mode = 0644,
  1340. .proc_handler = proc_dointvec,
  1341. },
  1342. #endif
  1343. #ifdef CONFIG_MMU
  1344. #ifdef CONFIG_FILE_LOCKING
  1345. {
  1346. .procname = "lease-break-time",
  1347. .data = &lease_break_time,
  1348. .maxlen = sizeof(int),
  1349. .mode = 0644,
  1350. .proc_handler = proc_dointvec,
  1351. },
  1352. #endif
  1353. #ifdef CONFIG_AIO
  1354. {
  1355. .procname = "aio-nr",
  1356. .data = &aio_nr,
  1357. .maxlen = sizeof(aio_nr),
  1358. .mode = 0444,
  1359. .proc_handler = proc_doulongvec_minmax,
  1360. },
  1361. {
  1362. .procname = "aio-max-nr",
  1363. .data = &aio_max_nr,
  1364. .maxlen = sizeof(aio_max_nr),
  1365. .mode = 0644,
  1366. .proc_handler = proc_doulongvec_minmax,
  1367. },
  1368. #endif /* CONFIG_AIO */
  1369. #ifdef CONFIG_INOTIFY_USER
  1370. {
  1371. .procname = "inotify",
  1372. .mode = 0555,
  1373. .child = inotify_table,
  1374. },
  1375. #endif
  1376. #ifdef CONFIG_EPOLL
  1377. {
  1378. .procname = "epoll",
  1379. .mode = 0555,
  1380. .child = epoll_table,
  1381. },
  1382. #endif
  1383. #endif
  1384. {
  1385. .procname = "suid_dumpable",
  1386. .data = &suid_dumpable,
  1387. .maxlen = sizeof(int),
  1388. .mode = 0644,
  1389. .proc_handler = proc_dointvec_minmax,
  1390. .extra1 = &zero,
  1391. .extra2 = &two,
  1392. },
  1393. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1394. {
  1395. .procname = "binfmt_misc",
  1396. .mode = 0555,
  1397. .child = binfmt_misc_table,
  1398. },
  1399. #endif
  1400. /*
  1401. * NOTE: do not add new entries to this table unless you have read
  1402. * Documentation/sysctl/ctl_unnumbered.txt
  1403. */
  1404. { }
  1405. };
  1406. static struct ctl_table debug_table[] = {
  1407. #if defined(CONFIG_X86) || defined(CONFIG_PPC)
  1408. {
  1409. .procname = "exception-trace",
  1410. .data = &show_unhandled_signals,
  1411. .maxlen = sizeof(int),
  1412. .mode = 0644,
  1413. .proc_handler = proc_dointvec
  1414. },
  1415. #endif
  1416. { }
  1417. };
  1418. static struct ctl_table dev_table[] = {
  1419. { }
  1420. };
  1421. static DEFINE_SPINLOCK(sysctl_lock);
  1422. /* called under sysctl_lock */
  1423. static int use_table(struct ctl_table_header *p)
  1424. {
  1425. if (unlikely(p->unregistering))
  1426. return 0;
  1427. p->used++;
  1428. return 1;
  1429. }
  1430. /* called under sysctl_lock */
  1431. static void unuse_table(struct ctl_table_header *p)
  1432. {
  1433. if (!--p->used)
  1434. if (unlikely(p->unregistering))
  1435. complete(p->unregistering);
  1436. }
  1437. /* called under sysctl_lock, will reacquire if has to wait */
  1438. static void start_unregistering(struct ctl_table_header *p)
  1439. {
  1440. /*
  1441. * if p->used is 0, nobody will ever touch that entry again;
  1442. * we'll eliminate all paths to it before dropping sysctl_lock
  1443. */
  1444. if (unlikely(p->used)) {
  1445. struct completion wait;
  1446. init_completion(&wait);
  1447. p->unregistering = &wait;
  1448. spin_unlock(&sysctl_lock);
  1449. wait_for_completion(&wait);
  1450. spin_lock(&sysctl_lock);
  1451. } else {
  1452. /* anything non-NULL; we'll never dereference it */
  1453. p->unregistering = ERR_PTR(-EINVAL);
  1454. }
  1455. /*
  1456. * do not remove from the list until nobody holds it; walking the
  1457. * list in do_sysctl() relies on that.
  1458. */
  1459. list_del_init(&p->ctl_entry);
  1460. }
  1461. void sysctl_head_get(struct ctl_table_header *head)
  1462. {
  1463. spin_lock(&sysctl_lock);
  1464. head->count++;
  1465. spin_unlock(&sysctl_lock);
  1466. }
  1467. void sysctl_head_put(struct ctl_table_header *head)
  1468. {
  1469. spin_lock(&sysctl_lock);
  1470. if (!--head->count)
  1471. kfree(head);
  1472. spin_unlock(&sysctl_lock);
  1473. }
  1474. struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
  1475. {
  1476. if (!head)
  1477. BUG();
  1478. spin_lock(&sysctl_lock);
  1479. if (!use_table(head))
  1480. head = ERR_PTR(-ENOENT);
  1481. spin_unlock(&sysctl_lock);
  1482. return head;
  1483. }
  1484. void sysctl_head_finish(struct ctl_table_header *head)
  1485. {
  1486. if (!head)
  1487. return;
  1488. spin_lock(&sysctl_lock);
  1489. unuse_table(head);
  1490. spin_unlock(&sysctl_lock);
  1491. }
  1492. static struct ctl_table_set *
  1493. lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
  1494. {
  1495. struct ctl_table_set *set = &root->default_set;
  1496. if (root->lookup)
  1497. set = root->lookup(root, namespaces);
  1498. return set;
  1499. }
  1500. static struct list_head *
  1501. lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
  1502. {
  1503. struct ctl_table_set *set = lookup_header_set(root, namespaces);
  1504. return &set->list;
  1505. }
  1506. struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
  1507. struct ctl_table_header *prev)
  1508. {
  1509. struct ctl_table_root *root;
  1510. struct list_head *header_list;
  1511. struct ctl_table_header *head;
  1512. struct list_head *tmp;
  1513. spin_lock(&sysctl_lock);
  1514. if (prev) {
  1515. head = prev;
  1516. tmp = &prev->ctl_entry;
  1517. unuse_table(prev);
  1518. goto next;
  1519. }
  1520. tmp = &root_table_header.ctl_entry;
  1521. for (;;) {
  1522. head = list_entry(tmp, struct ctl_table_header, ctl_entry);
  1523. if (!use_table(head))
  1524. goto next;
  1525. spin_unlock(&sysctl_lock);
  1526. return head;
  1527. next:
  1528. root = head->root;
  1529. tmp = tmp->next;
  1530. header_list = lookup_header_list(root, namespaces);
  1531. if (tmp != header_list)
  1532. continue;
  1533. do {
  1534. root = list_entry(root->root_list.next,
  1535. struct ctl_table_root, root_list);
  1536. if (root == &sysctl_table_root)
  1537. goto out;
  1538. header_list = lookup_header_list(root, namespaces);
  1539. } while (list_empty(header_list));
  1540. tmp = header_list->next;
  1541. }
  1542. out:
  1543. spin_unlock(&sysctl_lock);
  1544. return NULL;
  1545. }
  1546. struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
  1547. {
  1548. return __sysctl_head_next(current->nsproxy, prev);
  1549. }
  1550. void register_sysctl_root(struct ctl_table_root *root)
  1551. {
  1552. spin_lock(&sysctl_lock);
  1553. list_add_tail(&root->root_list, &sysctl_table_root.root_list);
  1554. spin_unlock(&sysctl_lock);
  1555. }
  1556. /*
  1557. * sysctl_perm does NOT grant the superuser all rights automatically, because
  1558. * some sysctl variables are readonly even to root.
  1559. */
  1560. static int test_perm(int mode, int op)
  1561. {
  1562. if (!current_euid())
  1563. mode >>= 6;
  1564. else if (in_egroup_p(0))
  1565. mode >>= 3;
  1566. if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
  1567. return 0;
  1568. return -EACCES;
  1569. }
  1570. int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
  1571. {
  1572. int error;
  1573. int mode;
  1574. error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
  1575. if (error)
  1576. return error;
  1577. if (root->permissions)
  1578. mode = root->permissions(root, current->nsproxy, table);
  1579. else
  1580. mode = table->mode;
  1581. return test_perm(mode, op);
  1582. }
  1583. static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
  1584. {
  1585. for (; table->procname; table++) {
  1586. table->parent = parent;
  1587. if (table->child)
  1588. sysctl_set_parent(table, table->child);
  1589. }
  1590. }
  1591. static __init int sysctl_init(void)
  1592. {
  1593. sysctl_set_parent(NULL, root_table);
  1594. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1595. {
  1596. int err;
  1597. err = sysctl_check_table(current->nsproxy, root_table);
  1598. }
  1599. #endif
  1600. return 0;
  1601. }
  1602. core_initcall(sysctl_init);
  1603. static struct ctl_table *is_branch_in(struct ctl_table *branch,
  1604. struct ctl_table *table)
  1605. {
  1606. struct ctl_table *p;
  1607. const char *s = branch->procname;
  1608. /* branch should have named subdirectory as its first element */
  1609. if (!s || !branch->child)
  1610. return NULL;
  1611. /* ... and nothing else */
  1612. if (branch[1].procname)
  1613. return NULL;
  1614. /* table should contain subdirectory with the same name */
  1615. for (p = table; p->procname; p++) {
  1616. if (!p->child)
  1617. continue;
  1618. if (p->procname && strcmp(p->procname, s) == 0)
  1619. return p;
  1620. }
  1621. return NULL;
  1622. }
  1623. /* see if attaching q to p would be an improvement */
  1624. static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
  1625. {
  1626. struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
  1627. struct ctl_table *next;
  1628. int is_better = 0;
  1629. int not_in_parent = !p->attached_by;
  1630. while ((next = is_branch_in(by, to)) != NULL) {
  1631. if (by == q->attached_by)
  1632. is_better = 1;
  1633. if (to == p->attached_by)
  1634. not_in_parent = 1;
  1635. by = by->child;
  1636. to = next->child;
  1637. }
  1638. if (is_better && not_in_parent) {
  1639. q->attached_by = by;
  1640. q->attached_to = to;
  1641. q->parent = p;
  1642. }
  1643. }
  1644. /**
  1645. * __register_sysctl_paths - register a sysctl hierarchy
  1646. * @root: List of sysctl headers to register on
  1647. * @namespaces: Data to compute which lists of sysctl entries are visible
  1648. * @path: The path to the directory the sysctl table is in.
  1649. * @table: the top-level table structure
  1650. *
  1651. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1652. * array. A completely 0 filled entry terminates the table.
  1653. *
  1654. * The members of the &struct ctl_table structure are used as follows:
  1655. *
  1656. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1657. * enter a sysctl file
  1658. *
  1659. * data - a pointer to data for use by proc_handler
  1660. *
  1661. * maxlen - the maximum size in bytes of the data
  1662. *
  1663. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1664. *
  1665. * child - a pointer to the child sysctl table if this entry is a directory, or
  1666. * %NULL.
  1667. *
  1668. * proc_handler - the text handler routine (described below)
  1669. *
  1670. * de - for internal use by the sysctl routines
  1671. *
  1672. * extra1, extra2 - extra pointers usable by the proc handler routines
  1673. *
  1674. * Leaf nodes in the sysctl tree will be represented by a single file
  1675. * under /proc; non-leaf nodes will be represented by directories.
  1676. *
  1677. * sysctl(2) can automatically manage read and write requests through
  1678. * the sysctl table. The data and maxlen fields of the ctl_table
  1679. * struct enable minimal validation of the values being written to be
  1680. * performed, and the mode field allows minimal authentication.
  1681. *
  1682. * There must be a proc_handler routine for any terminal nodes
  1683. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1684. * directory handler). Several default handlers are available to
  1685. * cover common cases -
  1686. *
  1687. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1688. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1689. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1690. *
  1691. * It is the handler's job to read the input buffer from user memory
  1692. * and process it. The handler should return 0 on success.
  1693. *
  1694. * This routine returns %NULL on a failure to register, and a pointer
  1695. * to the table header on success.
  1696. */
  1697. struct ctl_table_header *__register_sysctl_paths(
  1698. struct ctl_table_root *root,
  1699. struct nsproxy *namespaces,
  1700. const struct ctl_path *path, struct ctl_table *table)
  1701. {
  1702. struct ctl_table_header *header;
  1703. struct ctl_table *new, **prevp;
  1704. unsigned int n, npath;
  1705. struct ctl_table_set *set;
  1706. /* Count the path components */
  1707. for (npath = 0; path[npath].procname; ++npath)
  1708. ;
  1709. /*
  1710. * For each path component, allocate a 2-element ctl_table array.
  1711. * The first array element will be filled with the sysctl entry
  1712. * for this, the second will be the sentinel (procname == 0).
  1713. *
  1714. * We allocate everything in one go so that we don't have to
  1715. * worry about freeing additional memory in unregister_sysctl_table.
  1716. */
  1717. header = kzalloc(sizeof(struct ctl_table_header) +
  1718. (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
  1719. if (!header)
  1720. return NULL;
  1721. new = (struct ctl_table *) (header + 1);
  1722. /* Now connect the dots */
  1723. prevp = &header->ctl_table;
  1724. for (n = 0; n < npath; ++n, ++path) {
  1725. /* Copy the procname */
  1726. new->procname = path->procname;
  1727. new->mode = 0555;
  1728. *prevp = new;
  1729. prevp = &new->child;
  1730. new += 2;
  1731. }
  1732. *prevp = table;
  1733. header->ctl_table_arg = table;
  1734. INIT_LIST_HEAD(&header->ctl_entry);
  1735. header->used = 0;
  1736. header->unregistering = NULL;
  1737. header->root = root;
  1738. sysctl_set_parent(NULL, header->ctl_table);
  1739. header->count = 1;
  1740. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1741. if (sysctl_check_table(namespaces, header->ctl_table)) {
  1742. kfree(header);
  1743. return NULL;
  1744. }
  1745. #endif
  1746. spin_lock(&sysctl_lock);
  1747. header->set = lookup_header_set(root, namespaces);
  1748. header->attached_by = header->ctl_table;
  1749. header->attached_to = root_table;
  1750. header->parent = &root_table_header;
  1751. for (set = header->set; set; set = set->parent) {
  1752. struct ctl_table_header *p;
  1753. list_for_each_entry(p, &set->list, ctl_entry) {
  1754. if (p->unregistering)
  1755. continue;
  1756. try_attach(p, header);
  1757. }
  1758. }
  1759. header->parent->count++;
  1760. list_add_tail(&header->ctl_entry, &header->set->list);
  1761. spin_unlock(&sysctl_lock);
  1762. return header;
  1763. }
  1764. /**
  1765. * register_sysctl_table_path - register a sysctl table hierarchy
  1766. * @path: The path to the directory the sysctl table is in.
  1767. * @table: the top-level table structure
  1768. *
  1769. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1770. * array. A completely 0 filled entry terminates the table.
  1771. *
  1772. * See __register_sysctl_paths for more details.
  1773. */
  1774. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1775. struct ctl_table *table)
  1776. {
  1777. return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
  1778. path, table);
  1779. }
  1780. /**
  1781. * register_sysctl_table - register a sysctl table hierarchy
  1782. * @table: the top-level table structure
  1783. *
  1784. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1785. * array. A completely 0 filled entry terminates the table.
  1786. *
  1787. * See register_sysctl_paths for more details.
  1788. */
  1789. struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
  1790. {
  1791. static const struct ctl_path null_path[] = { {} };
  1792. return register_sysctl_paths(null_path, table);
  1793. }
  1794. /**
  1795. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1796. * @header: the header returned from register_sysctl_table
  1797. *
  1798. * Unregisters the sysctl table and all children. proc entries may not
  1799. * actually be removed until they are no longer used by anyone.
  1800. */
  1801. void unregister_sysctl_table(struct ctl_table_header * header)
  1802. {
  1803. might_sleep();
  1804. if (header == NULL)
  1805. return;
  1806. spin_lock(&sysctl_lock);
  1807. start_unregistering(header);
  1808. if (!--header->parent->count) {
  1809. WARN_ON(1);
  1810. kfree(header->parent);
  1811. }
  1812. if (!--header->count)
  1813. kfree(header);
  1814. spin_unlock(&sysctl_lock);
  1815. }
  1816. int sysctl_is_seen(struct ctl_table_header *p)
  1817. {
  1818. struct ctl_table_set *set = p->set;
  1819. int res;
  1820. spin_lock(&sysctl_lock);
  1821. if (p->unregistering)
  1822. res = 0;
  1823. else if (!set->is_seen)
  1824. res = 1;
  1825. else
  1826. res = set->is_seen(set);
  1827. spin_unlock(&sysctl_lock);
  1828. return res;
  1829. }
  1830. void setup_sysctl_set(struct ctl_table_set *p,
  1831. struct ctl_table_set *parent,
  1832. int (*is_seen)(struct ctl_table_set *))
  1833. {
  1834. INIT_LIST_HEAD(&p->list);
  1835. p->parent = parent ? parent : &sysctl_table_root.default_set;
  1836. p->is_seen = is_seen;
  1837. }
  1838. #else /* !CONFIG_SYSCTL */
  1839. struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
  1840. {
  1841. return NULL;
  1842. }
  1843. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1844. struct ctl_table *table)
  1845. {
  1846. return NULL;
  1847. }
  1848. void unregister_sysctl_table(struct ctl_table_header * table)
  1849. {
  1850. }
  1851. void setup_sysctl_set(struct ctl_table_set *p,
  1852. struct ctl_table_set *parent,
  1853. int (*is_seen)(struct ctl_table_set *))
  1854. {
  1855. }
  1856. void sysctl_head_put(struct ctl_table_header *head)
  1857. {
  1858. }
  1859. #endif /* CONFIG_SYSCTL */
  1860. /*
  1861. * /proc/sys support
  1862. */
  1863. #ifdef CONFIG_PROC_SYSCTL
  1864. static int _proc_do_string(void* data, int maxlen, int write,
  1865. void __user *buffer,
  1866. size_t *lenp, loff_t *ppos)
  1867. {
  1868. size_t len;
  1869. char __user *p;
  1870. char c;
  1871. if (!data || !maxlen || !*lenp) {
  1872. *lenp = 0;
  1873. return 0;
  1874. }
  1875. if (write) {
  1876. len = 0;
  1877. p = buffer;
  1878. while (len < *lenp) {
  1879. if (get_user(c, p++))
  1880. return -EFAULT;
  1881. if (c == 0 || c == '\n')
  1882. break;
  1883. len++;
  1884. }
  1885. if (len >= maxlen)
  1886. len = maxlen-1;
  1887. if(copy_from_user(data, buffer, len))
  1888. return -EFAULT;
  1889. ((char *) data)[len] = 0;
  1890. *ppos += *lenp;
  1891. } else {
  1892. len = strlen(data);
  1893. if (len > maxlen)
  1894. len = maxlen;
  1895. if (*ppos > len) {
  1896. *lenp = 0;
  1897. return 0;
  1898. }
  1899. data += *ppos;
  1900. len -= *ppos;
  1901. if (len > *lenp)
  1902. len = *lenp;
  1903. if (len)
  1904. if(copy_to_user(buffer, data, len))
  1905. return -EFAULT;
  1906. if (len < *lenp) {
  1907. if(put_user('\n', ((char __user *) buffer) + len))
  1908. return -EFAULT;
  1909. len++;
  1910. }
  1911. *lenp = len;
  1912. *ppos += len;
  1913. }
  1914. return 0;
  1915. }
  1916. /**
  1917. * proc_dostring - read a string sysctl
  1918. * @table: the sysctl table
  1919. * @write: %TRUE if this is a write to the sysctl file
  1920. * @buffer: the user buffer
  1921. * @lenp: the size of the user buffer
  1922. * @ppos: file position
  1923. *
  1924. * Reads/writes a string from/to the user buffer. If the kernel
  1925. * buffer provided is not large enough to hold the string, the
  1926. * string is truncated. The copied string is %NULL-terminated.
  1927. * If the string is being read by the user process, it is copied
  1928. * and a newline '\n' is added. It is truncated if the buffer is
  1929. * not large enough.
  1930. *
  1931. * Returns 0 on success.
  1932. */
  1933. int proc_dostring(struct ctl_table *table, int write,
  1934. void __user *buffer, size_t *lenp, loff_t *ppos)
  1935. {
  1936. return _proc_do_string(table->data, table->maxlen, write,
  1937. buffer, lenp, ppos);
  1938. }
  1939. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  1940. int *valp,
  1941. int write, void *data)
  1942. {
  1943. if (write) {
  1944. *valp = *negp ? -*lvalp : *lvalp;
  1945. } else {
  1946. int val = *valp;
  1947. if (val < 0) {
  1948. *negp = -1;
  1949. *lvalp = (unsigned long)-val;
  1950. } else {
  1951. *negp = 0;
  1952. *lvalp = (unsigned long)val;
  1953. }
  1954. }
  1955. return 0;
  1956. }
  1957. static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
  1958. int write, void __user *buffer,
  1959. size_t *lenp, loff_t *ppos,
  1960. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1961. int write, void *data),
  1962. void *data)
  1963. {
  1964. #define TMPBUFLEN 21
  1965. int *i, vleft, first = 1, neg;
  1966. unsigned long lval;
  1967. size_t left, len;
  1968. char buf[TMPBUFLEN], *p;
  1969. char __user *s = buffer;
  1970. if (!tbl_data || !table->maxlen || !*lenp ||
  1971. (*ppos && !write)) {
  1972. *lenp = 0;
  1973. return 0;
  1974. }
  1975. i = (int *) tbl_data;
  1976. vleft = table->maxlen / sizeof(*i);
  1977. left = *lenp;
  1978. if (!conv)
  1979. conv = do_proc_dointvec_conv;
  1980. for (; left && vleft--; i++, first=0) {
  1981. if (write) {
  1982. while (left) {
  1983. char c;
  1984. if (get_user(c, s))
  1985. return -EFAULT;
  1986. if (!isspace(c))
  1987. break;
  1988. left--;
  1989. s++;
  1990. }
  1991. if (!left)
  1992. break;
  1993. neg = 0;
  1994. len = left;
  1995. if (len > sizeof(buf) - 1)
  1996. len = sizeof(buf) - 1;
  1997. if (copy_from_user(buf, s, len))
  1998. return -EFAULT;
  1999. buf[len] = 0;
  2000. p = buf;
  2001. if (*p == '-' && left > 1) {
  2002. neg = 1;
  2003. p++;
  2004. }
  2005. if (*p < '0' || *p > '9')
  2006. break;
  2007. lval = simple_strtoul(p, &p, 0);
  2008. len = p-buf;
  2009. if ((len < left) && *p && !isspace(*p))
  2010. break;
  2011. s += len;
  2012. left -= len;
  2013. if (conv(&neg, &lval, i, 1, data))
  2014. break;
  2015. } else {
  2016. p = buf;
  2017. if (!first)
  2018. *p++ = '\t';
  2019. if (conv(&neg, &lval, i, 0, data))
  2020. break;
  2021. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  2022. len = strlen(buf);
  2023. if (len > left)
  2024. len = left;
  2025. if(copy_to_user(s, buf, len))
  2026. return -EFAULT;
  2027. left -= len;
  2028. s += len;
  2029. }
  2030. }
  2031. if (!write && !first && left) {
  2032. if(put_user('\n', s))
  2033. return -EFAULT;
  2034. left--, s++;
  2035. }
  2036. if (write) {
  2037. while (left) {
  2038. char c;
  2039. if (get_user(c, s++))
  2040. return -EFAULT;
  2041. if (!isspace(c))
  2042. break;
  2043. left--;
  2044. }
  2045. }
  2046. if (write && first)
  2047. return -EINVAL;
  2048. *lenp -= left;
  2049. *ppos += *lenp;
  2050. return 0;
  2051. #undef TMPBUFLEN
  2052. }
  2053. static int do_proc_dointvec(struct ctl_table *table, int write,
  2054. void __user *buffer, size_t *lenp, loff_t *ppos,
  2055. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  2056. int write, void *data),
  2057. void *data)
  2058. {
  2059. return __do_proc_dointvec(table->data, table, write,
  2060. buffer, lenp, ppos, conv, data);
  2061. }
  2062. /**
  2063. * proc_dointvec - read a vector of integers
  2064. * @table: the sysctl table
  2065. * @write: %TRUE if this is a write to the sysctl file
  2066. * @buffer: the user buffer
  2067. * @lenp: the size of the user buffer
  2068. * @ppos: file position
  2069. *
  2070. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2071. * values from/to the user buffer, treated as an ASCII string.
  2072. *
  2073. * Returns 0 on success.
  2074. */
  2075. int proc_dointvec(struct ctl_table *table, int write,
  2076. void __user *buffer, size_t *lenp, loff_t *ppos)
  2077. {
  2078. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2079. NULL,NULL);
  2080. }
  2081. /*
  2082. * Taint values can only be increased
  2083. * This means we can safely use a temporary.
  2084. */
  2085. static int proc_taint(struct ctl_table *table, int write,
  2086. void __user *buffer, size_t *lenp, loff_t *ppos)
  2087. {
  2088. struct ctl_table t;
  2089. unsigned long tmptaint = get_taint();
  2090. int err;
  2091. if (write && !capable(CAP_SYS_ADMIN))
  2092. return -EPERM;
  2093. t = *table;
  2094. t.data = &tmptaint;
  2095. err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
  2096. if (err < 0)
  2097. return err;
  2098. if (write) {
  2099. /*
  2100. * Poor man's atomic or. Not worth adding a primitive
  2101. * to everyone's atomic.h for this
  2102. */
  2103. int i;
  2104. for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
  2105. if ((tmptaint >> i) & 1)
  2106. add_taint(i);
  2107. }
  2108. }
  2109. return err;
  2110. }
  2111. struct do_proc_dointvec_minmax_conv_param {
  2112. int *min;
  2113. int *max;
  2114. };
  2115. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  2116. int *valp,
  2117. int write, void *data)
  2118. {
  2119. struct do_proc_dointvec_minmax_conv_param *param = data;
  2120. if (write) {
  2121. int val = *negp ? -*lvalp : *lvalp;
  2122. if ((param->min && *param->min > val) ||
  2123. (param->max && *param->max < val))
  2124. return -EINVAL;
  2125. *valp = val;
  2126. } else {
  2127. int val = *valp;
  2128. if (val < 0) {
  2129. *negp = -1;
  2130. *lvalp = (unsigned long)-val;
  2131. } else {
  2132. *negp = 0;
  2133. *lvalp = (unsigned long)val;
  2134. }
  2135. }
  2136. return 0;
  2137. }
  2138. /**
  2139. * proc_dointvec_minmax - read a vector of integers with min/max values
  2140. * @table: the sysctl table
  2141. * @write: %TRUE if this is a write to the sysctl file
  2142. * @buffer: the user buffer
  2143. * @lenp: the size of the user buffer
  2144. * @ppos: file position
  2145. *
  2146. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2147. * values from/to the user buffer, treated as an ASCII string.
  2148. *
  2149. * This routine will ensure the values are within the range specified by
  2150. * table->extra1 (min) and table->extra2 (max).
  2151. *
  2152. * Returns 0 on success.
  2153. */
  2154. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2155. void __user *buffer, size_t *lenp, loff_t *ppos)
  2156. {
  2157. struct do_proc_dointvec_minmax_conv_param param = {
  2158. .min = (int *) table->extra1,
  2159. .max = (int *) table->extra2,
  2160. };
  2161. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2162. do_proc_dointvec_minmax_conv, &param);
  2163. }
  2164. static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
  2165. void __user *buffer,
  2166. size_t *lenp, loff_t *ppos,
  2167. unsigned long convmul,
  2168. unsigned long convdiv)
  2169. {
  2170. #define TMPBUFLEN 21
  2171. unsigned long *i, *min, *max, val;
  2172. int vleft, first=1, neg;
  2173. size_t len, left;
  2174. char buf[TMPBUFLEN], *p;
  2175. char __user *s = buffer;
  2176. if (!data || !table->maxlen || !*lenp ||
  2177. (*ppos && !write)) {
  2178. *lenp = 0;
  2179. return 0;
  2180. }
  2181. i = (unsigned long *) data;
  2182. min = (unsigned long *) table->extra1;
  2183. max = (unsigned long *) table->extra2;
  2184. vleft = table->maxlen / sizeof(unsigned long);
  2185. left = *lenp;
  2186. for (; left && vleft--; i++, min++, max++, first=0) {
  2187. if (write) {
  2188. while (left) {
  2189. char c;
  2190. if (get_user(c, s))
  2191. return -EFAULT;
  2192. if (!isspace(c))
  2193. break;
  2194. left--;
  2195. s++;
  2196. }
  2197. if (!left)
  2198. break;
  2199. neg = 0;
  2200. len = left;
  2201. if (len > TMPBUFLEN-1)
  2202. len = TMPBUFLEN-1;
  2203. if (copy_from_user(buf, s, len))
  2204. return -EFAULT;
  2205. buf[len] = 0;
  2206. p = buf;
  2207. if (*p == '-' && left > 1) {
  2208. neg = 1;
  2209. p++;
  2210. }
  2211. if (*p < '0' || *p > '9')
  2212. break;
  2213. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  2214. len = p-buf;
  2215. if ((len < left) && *p && !isspace(*p))
  2216. break;
  2217. if (neg)
  2218. val = -val;
  2219. s += len;
  2220. left -= len;
  2221. if(neg)
  2222. continue;
  2223. if ((min && val < *min) || (max && val > *max))
  2224. continue;
  2225. *i = val;
  2226. } else {
  2227. p = buf;
  2228. if (!first)
  2229. *p++ = '\t';
  2230. sprintf(p, "%lu", convdiv * (*i) / convmul);
  2231. len = strlen(buf);
  2232. if (len > left)
  2233. len = left;
  2234. if(copy_to_user(s, buf, len))
  2235. return -EFAULT;
  2236. left -= len;
  2237. s += len;
  2238. }
  2239. }
  2240. if (!write && !first && left) {
  2241. if(put_user('\n', s))
  2242. return -EFAULT;
  2243. left--, s++;
  2244. }
  2245. if (write) {
  2246. while (left) {
  2247. char c;
  2248. if (get_user(c, s++))
  2249. return -EFAULT;
  2250. if (!isspace(c))
  2251. break;
  2252. left--;
  2253. }
  2254. }
  2255. if (write && first)
  2256. return -EINVAL;
  2257. *lenp -= left;
  2258. *ppos += *lenp;
  2259. return 0;
  2260. #undef TMPBUFLEN
  2261. }
  2262. static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
  2263. void __user *buffer,
  2264. size_t *lenp, loff_t *ppos,
  2265. unsigned long convmul,
  2266. unsigned long convdiv)
  2267. {
  2268. return __do_proc_doulongvec_minmax(table->data, table, write,
  2269. buffer, lenp, ppos, convmul, convdiv);
  2270. }
  2271. /**
  2272. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  2273. * @table: the sysctl table
  2274. * @write: %TRUE if this is a write to the sysctl file
  2275. * @buffer: the user buffer
  2276. * @lenp: the size of the user buffer
  2277. * @ppos: file position
  2278. *
  2279. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2280. * values from/to the user buffer, treated as an ASCII string.
  2281. *
  2282. * This routine will ensure the values are within the range specified by
  2283. * table->extra1 (min) and table->extra2 (max).
  2284. *
  2285. * Returns 0 on success.
  2286. */
  2287. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2288. void __user *buffer, size_t *lenp, loff_t *ppos)
  2289. {
  2290. return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
  2291. }
  2292. /**
  2293. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  2294. * @table: the sysctl table
  2295. * @write: %TRUE if this is a write to the sysctl file
  2296. * @buffer: the user buffer
  2297. * @lenp: the size of the user buffer
  2298. * @ppos: file position
  2299. *
  2300. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2301. * values from/to the user buffer, treated as an ASCII string. The values
  2302. * are treated as milliseconds, and converted to jiffies when they are stored.
  2303. *
  2304. * This routine will ensure the values are within the range specified by
  2305. * table->extra1 (min) and table->extra2 (max).
  2306. *
  2307. * Returns 0 on success.
  2308. */
  2309. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2310. void __user *buffer,
  2311. size_t *lenp, loff_t *ppos)
  2312. {
  2313. return do_proc_doulongvec_minmax(table, write, buffer,
  2314. lenp, ppos, HZ, 1000l);
  2315. }
  2316. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  2317. int *valp,
  2318. int write, void *data)
  2319. {
  2320. if (write) {
  2321. if (*lvalp > LONG_MAX / HZ)
  2322. return 1;
  2323. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2324. } else {
  2325. int val = *valp;
  2326. unsigned long lval;
  2327. if (val < 0) {
  2328. *negp = -1;
  2329. lval = (unsigned long)-val;
  2330. } else {
  2331. *negp = 0;
  2332. lval = (unsigned long)val;
  2333. }
  2334. *lvalp = lval / HZ;
  2335. }
  2336. return 0;
  2337. }
  2338. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2339. int *valp,
  2340. int write, void *data)
  2341. {
  2342. if (write) {
  2343. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2344. return 1;
  2345. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2346. } else {
  2347. int val = *valp;
  2348. unsigned long lval;
  2349. if (val < 0) {
  2350. *negp = -1;
  2351. lval = (unsigned long)-val;
  2352. } else {
  2353. *negp = 0;
  2354. lval = (unsigned long)val;
  2355. }
  2356. *lvalp = jiffies_to_clock_t(lval);
  2357. }
  2358. return 0;
  2359. }
  2360. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2361. int *valp,
  2362. int write, void *data)
  2363. {
  2364. if (write) {
  2365. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2366. } else {
  2367. int val = *valp;
  2368. unsigned long lval;
  2369. if (val < 0) {
  2370. *negp = -1;
  2371. lval = (unsigned long)-val;
  2372. } else {
  2373. *negp = 0;
  2374. lval = (unsigned long)val;
  2375. }
  2376. *lvalp = jiffies_to_msecs(lval);
  2377. }
  2378. return 0;
  2379. }
  2380. /**
  2381. * proc_dointvec_jiffies - read a vector of integers as seconds
  2382. * @table: the sysctl table
  2383. * @write: %TRUE if this is a write to the sysctl file
  2384. * @buffer: the user buffer
  2385. * @lenp: the size of the user buffer
  2386. * @ppos: file position
  2387. *
  2388. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2389. * values from/to the user buffer, treated as an ASCII string.
  2390. * The values read are assumed to be in seconds, and are converted into
  2391. * jiffies.
  2392. *
  2393. * Returns 0 on success.
  2394. */
  2395. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2396. void __user *buffer, size_t *lenp, loff_t *ppos)
  2397. {
  2398. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2399. do_proc_dointvec_jiffies_conv,NULL);
  2400. }
  2401. /**
  2402. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2403. * @table: the sysctl table
  2404. * @write: %TRUE if this is a write to the sysctl file
  2405. * @buffer: the user buffer
  2406. * @lenp: the size of the user buffer
  2407. * @ppos: pointer to the file position
  2408. *
  2409. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2410. * values from/to the user buffer, treated as an ASCII string.
  2411. * The values read are assumed to be in 1/USER_HZ seconds, and
  2412. * are converted into jiffies.
  2413. *
  2414. * Returns 0 on success.
  2415. */
  2416. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2417. void __user *buffer, size_t *lenp, loff_t *ppos)
  2418. {
  2419. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2420. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2421. }
  2422. /**
  2423. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2424. * @table: the sysctl table
  2425. * @write: %TRUE if this is a write to the sysctl file
  2426. * @buffer: the user buffer
  2427. * @lenp: the size of the user buffer
  2428. * @ppos: file position
  2429. * @ppos: the current position in the file
  2430. *
  2431. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2432. * values from/to the user buffer, treated as an ASCII string.
  2433. * The values read are assumed to be in 1/1000 seconds, and
  2434. * are converted into jiffies.
  2435. *
  2436. * Returns 0 on success.
  2437. */
  2438. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2439. void __user *buffer, size_t *lenp, loff_t *ppos)
  2440. {
  2441. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2442. do_proc_dointvec_ms_jiffies_conv, NULL);
  2443. }
  2444. static int proc_do_cad_pid(struct ctl_table *table, int write,
  2445. void __user *buffer, size_t *lenp, loff_t *ppos)
  2446. {
  2447. struct pid *new_pid;
  2448. pid_t tmp;
  2449. int r;
  2450. tmp = pid_vnr(cad_pid);
  2451. r = __do_proc_dointvec(&tmp, table, write, buffer,
  2452. lenp, ppos, NULL, NULL);
  2453. if (r || !write)
  2454. return r;
  2455. new_pid = find_get_pid(tmp);
  2456. if (!new_pid)
  2457. return -ESRCH;
  2458. put_pid(xchg(&cad_pid, new_pid));
  2459. return 0;
  2460. }
  2461. #else /* CONFIG_PROC_FS */
  2462. int proc_dostring(struct ctl_table *table, int write,
  2463. void __user *buffer, size_t *lenp, loff_t *ppos)
  2464. {
  2465. return -ENOSYS;
  2466. }
  2467. int proc_dointvec(struct ctl_table *table, int write,
  2468. void __user *buffer, size_t *lenp, loff_t *ppos)
  2469. {
  2470. return -ENOSYS;
  2471. }
  2472. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2473. void __user *buffer, size_t *lenp, loff_t *ppos)
  2474. {
  2475. return -ENOSYS;
  2476. }
  2477. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2478. void __user *buffer, size_t *lenp, loff_t *ppos)
  2479. {
  2480. return -ENOSYS;
  2481. }
  2482. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2483. void __user *buffer, size_t *lenp, loff_t *ppos)
  2484. {
  2485. return -ENOSYS;
  2486. }
  2487. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2488. void __user *buffer, size_t *lenp, loff_t *ppos)
  2489. {
  2490. return -ENOSYS;
  2491. }
  2492. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2493. void __user *buffer, size_t *lenp, loff_t *ppos)
  2494. {
  2495. return -ENOSYS;
  2496. }
  2497. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2498. void __user *buffer,
  2499. size_t *lenp, loff_t *ppos)
  2500. {
  2501. return -ENOSYS;
  2502. }
  2503. #endif /* CONFIG_PROC_FS */
  2504. /*
  2505. * No sense putting this after each symbol definition, twice,
  2506. * exception granted :-)
  2507. */
  2508. EXPORT_SYMBOL(proc_dointvec);
  2509. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2510. EXPORT_SYMBOL(proc_dointvec_minmax);
  2511. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2512. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2513. EXPORT_SYMBOL(proc_dostring);
  2514. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2515. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2516. EXPORT_SYMBOL(register_sysctl_table);
  2517. EXPORT_SYMBOL(register_sysctl_paths);
  2518. EXPORT_SYMBOL(unregister_sysctl_table);