sysctl.c 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677
  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_minmax,
  1105. .extra1 = &zero,
  1106. },
  1107. #else
  1108. {
  1109. .procname = "nr_trim_pages",
  1110. .data = &sysctl_nr_trim_pages,
  1111. .maxlen = sizeof(sysctl_nr_trim_pages),
  1112. .mode = 0644,
  1113. .proc_handler = proc_dointvec_minmax,
  1114. .extra1 = &zero,
  1115. },
  1116. #endif
  1117. {
  1118. .procname = "laptop_mode",
  1119. .data = &laptop_mode,
  1120. .maxlen = sizeof(laptop_mode),
  1121. .mode = 0644,
  1122. .proc_handler = proc_dointvec_jiffies,
  1123. },
  1124. {
  1125. .procname = "block_dump",
  1126. .data = &block_dump,
  1127. .maxlen = sizeof(block_dump),
  1128. .mode = 0644,
  1129. .proc_handler = proc_dointvec,
  1130. .extra1 = &zero,
  1131. },
  1132. {
  1133. .procname = "vfs_cache_pressure",
  1134. .data = &sysctl_vfs_cache_pressure,
  1135. .maxlen = sizeof(sysctl_vfs_cache_pressure),
  1136. .mode = 0644,
  1137. .proc_handler = proc_dointvec,
  1138. .extra1 = &zero,
  1139. },
  1140. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  1141. {
  1142. .procname = "legacy_va_layout",
  1143. .data = &sysctl_legacy_va_layout,
  1144. .maxlen = sizeof(sysctl_legacy_va_layout),
  1145. .mode = 0644,
  1146. .proc_handler = proc_dointvec,
  1147. .extra1 = &zero,
  1148. },
  1149. #endif
  1150. #ifdef CONFIG_NUMA
  1151. {
  1152. .procname = "zone_reclaim_mode",
  1153. .data = &zone_reclaim_mode,
  1154. .maxlen = sizeof(zone_reclaim_mode),
  1155. .mode = 0644,
  1156. .proc_handler = proc_dointvec,
  1157. .extra1 = &zero,
  1158. },
  1159. {
  1160. .procname = "min_unmapped_ratio",
  1161. .data = &sysctl_min_unmapped_ratio,
  1162. .maxlen = sizeof(sysctl_min_unmapped_ratio),
  1163. .mode = 0644,
  1164. .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
  1165. .extra1 = &zero,
  1166. .extra2 = &one_hundred,
  1167. },
  1168. {
  1169. .procname = "min_slab_ratio",
  1170. .data = &sysctl_min_slab_ratio,
  1171. .maxlen = sizeof(sysctl_min_slab_ratio),
  1172. .mode = 0644,
  1173. .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
  1174. .extra1 = &zero,
  1175. .extra2 = &one_hundred,
  1176. },
  1177. #endif
  1178. #ifdef CONFIG_SMP
  1179. {
  1180. .procname = "stat_interval",
  1181. .data = &sysctl_stat_interval,
  1182. .maxlen = sizeof(sysctl_stat_interval),
  1183. .mode = 0644,
  1184. .proc_handler = proc_dointvec_jiffies,
  1185. },
  1186. #endif
  1187. #ifdef CONFIG_MMU
  1188. {
  1189. .procname = "mmap_min_addr",
  1190. .data = &dac_mmap_min_addr,
  1191. .maxlen = sizeof(unsigned long),
  1192. .mode = 0644,
  1193. .proc_handler = mmap_min_addr_handler,
  1194. },
  1195. #endif
  1196. #ifdef CONFIG_NUMA
  1197. {
  1198. .procname = "numa_zonelist_order",
  1199. .data = &numa_zonelist_order,
  1200. .maxlen = NUMA_ZONELIST_ORDER_LEN,
  1201. .mode = 0644,
  1202. .proc_handler = numa_zonelist_order_handler,
  1203. },
  1204. #endif
  1205. #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
  1206. (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
  1207. {
  1208. .procname = "vdso_enabled",
  1209. .data = &vdso_enabled,
  1210. .maxlen = sizeof(vdso_enabled),
  1211. .mode = 0644,
  1212. .proc_handler = proc_dointvec,
  1213. .extra1 = &zero,
  1214. },
  1215. #endif
  1216. #ifdef CONFIG_HIGHMEM
  1217. {
  1218. .procname = "highmem_is_dirtyable",
  1219. .data = &vm_highmem_is_dirtyable,
  1220. .maxlen = sizeof(vm_highmem_is_dirtyable),
  1221. .mode = 0644,
  1222. .proc_handler = proc_dointvec_minmax,
  1223. .extra1 = &zero,
  1224. .extra2 = &one,
  1225. },
  1226. #endif
  1227. {
  1228. .procname = "scan_unevictable_pages",
  1229. .data = &scan_unevictable_pages,
  1230. .maxlen = sizeof(scan_unevictable_pages),
  1231. .mode = 0644,
  1232. .proc_handler = scan_unevictable_handler,
  1233. },
  1234. #ifdef CONFIG_MEMORY_FAILURE
  1235. {
  1236. .procname = "memory_failure_early_kill",
  1237. .data = &sysctl_memory_failure_early_kill,
  1238. .maxlen = sizeof(sysctl_memory_failure_early_kill),
  1239. .mode = 0644,
  1240. .proc_handler = proc_dointvec_minmax,
  1241. .extra1 = &zero,
  1242. .extra2 = &one,
  1243. },
  1244. {
  1245. .procname = "memory_failure_recovery",
  1246. .data = &sysctl_memory_failure_recovery,
  1247. .maxlen = sizeof(sysctl_memory_failure_recovery),
  1248. .mode = 0644,
  1249. .proc_handler = proc_dointvec_minmax,
  1250. .extra1 = &zero,
  1251. .extra2 = &one,
  1252. },
  1253. #endif
  1254. /*
  1255. * NOTE: do not add new entries to this table unless you have read
  1256. * Documentation/sysctl/ctl_unnumbered.txt
  1257. */
  1258. { }
  1259. };
  1260. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1261. static struct ctl_table binfmt_misc_table[] = {
  1262. { }
  1263. };
  1264. #endif
  1265. static struct ctl_table fs_table[] = {
  1266. {
  1267. .procname = "inode-nr",
  1268. .data = &inodes_stat,
  1269. .maxlen = 2*sizeof(int),
  1270. .mode = 0444,
  1271. .proc_handler = proc_dointvec,
  1272. },
  1273. {
  1274. .procname = "inode-state",
  1275. .data = &inodes_stat,
  1276. .maxlen = 7*sizeof(int),
  1277. .mode = 0444,
  1278. .proc_handler = proc_dointvec,
  1279. },
  1280. {
  1281. .procname = "file-nr",
  1282. .data = &files_stat,
  1283. .maxlen = 3*sizeof(int),
  1284. .mode = 0444,
  1285. .proc_handler = proc_nr_files,
  1286. },
  1287. {
  1288. .procname = "file-max",
  1289. .data = &files_stat.max_files,
  1290. .maxlen = sizeof(int),
  1291. .mode = 0644,
  1292. .proc_handler = proc_dointvec,
  1293. },
  1294. {
  1295. .procname = "nr_open",
  1296. .data = &sysctl_nr_open,
  1297. .maxlen = sizeof(int),
  1298. .mode = 0644,
  1299. .proc_handler = proc_dointvec_minmax,
  1300. .extra1 = &sysctl_nr_open_min,
  1301. .extra2 = &sysctl_nr_open_max,
  1302. },
  1303. {
  1304. .procname = "dentry-state",
  1305. .data = &dentry_stat,
  1306. .maxlen = 6*sizeof(int),
  1307. .mode = 0444,
  1308. .proc_handler = proc_dointvec,
  1309. },
  1310. {
  1311. .procname = "overflowuid",
  1312. .data = &fs_overflowuid,
  1313. .maxlen = sizeof(int),
  1314. .mode = 0644,
  1315. .proc_handler = proc_dointvec_minmax,
  1316. .extra1 = &minolduid,
  1317. .extra2 = &maxolduid,
  1318. },
  1319. {
  1320. .procname = "overflowgid",
  1321. .data = &fs_overflowgid,
  1322. .maxlen = sizeof(int),
  1323. .mode = 0644,
  1324. .proc_handler = proc_dointvec_minmax,
  1325. .extra1 = &minolduid,
  1326. .extra2 = &maxolduid,
  1327. },
  1328. #ifdef CONFIG_FILE_LOCKING
  1329. {
  1330. .procname = "leases-enable",
  1331. .data = &leases_enable,
  1332. .maxlen = sizeof(int),
  1333. .mode = 0644,
  1334. .proc_handler = proc_dointvec,
  1335. },
  1336. #endif
  1337. #ifdef CONFIG_DNOTIFY
  1338. {
  1339. .procname = "dir-notify-enable",
  1340. .data = &dir_notify_enable,
  1341. .maxlen = sizeof(int),
  1342. .mode = 0644,
  1343. .proc_handler = proc_dointvec,
  1344. },
  1345. #endif
  1346. #ifdef CONFIG_MMU
  1347. #ifdef CONFIG_FILE_LOCKING
  1348. {
  1349. .procname = "lease-break-time",
  1350. .data = &lease_break_time,
  1351. .maxlen = sizeof(int),
  1352. .mode = 0644,
  1353. .proc_handler = proc_dointvec,
  1354. },
  1355. #endif
  1356. #ifdef CONFIG_AIO
  1357. {
  1358. .procname = "aio-nr",
  1359. .data = &aio_nr,
  1360. .maxlen = sizeof(aio_nr),
  1361. .mode = 0444,
  1362. .proc_handler = proc_doulongvec_minmax,
  1363. },
  1364. {
  1365. .procname = "aio-max-nr",
  1366. .data = &aio_max_nr,
  1367. .maxlen = sizeof(aio_max_nr),
  1368. .mode = 0644,
  1369. .proc_handler = proc_doulongvec_minmax,
  1370. },
  1371. #endif /* CONFIG_AIO */
  1372. #ifdef CONFIG_INOTIFY_USER
  1373. {
  1374. .procname = "inotify",
  1375. .mode = 0555,
  1376. .child = inotify_table,
  1377. },
  1378. #endif
  1379. #ifdef CONFIG_EPOLL
  1380. {
  1381. .procname = "epoll",
  1382. .mode = 0555,
  1383. .child = epoll_table,
  1384. },
  1385. #endif
  1386. #endif
  1387. {
  1388. .procname = "suid_dumpable",
  1389. .data = &suid_dumpable,
  1390. .maxlen = sizeof(int),
  1391. .mode = 0644,
  1392. .proc_handler = proc_dointvec_minmax,
  1393. .extra1 = &zero,
  1394. .extra2 = &two,
  1395. },
  1396. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1397. {
  1398. .procname = "binfmt_misc",
  1399. .mode = 0555,
  1400. .child = binfmt_misc_table,
  1401. },
  1402. #endif
  1403. /*
  1404. * NOTE: do not add new entries to this table unless you have read
  1405. * Documentation/sysctl/ctl_unnumbered.txt
  1406. */
  1407. { }
  1408. };
  1409. static struct ctl_table debug_table[] = {
  1410. #if defined(CONFIG_X86) || defined(CONFIG_PPC)
  1411. {
  1412. .procname = "exception-trace",
  1413. .data = &show_unhandled_signals,
  1414. .maxlen = sizeof(int),
  1415. .mode = 0644,
  1416. .proc_handler = proc_dointvec
  1417. },
  1418. #endif
  1419. { }
  1420. };
  1421. static struct ctl_table dev_table[] = {
  1422. { }
  1423. };
  1424. static DEFINE_SPINLOCK(sysctl_lock);
  1425. /* called under sysctl_lock */
  1426. static int use_table(struct ctl_table_header *p)
  1427. {
  1428. if (unlikely(p->unregistering))
  1429. return 0;
  1430. p->used++;
  1431. return 1;
  1432. }
  1433. /* called under sysctl_lock */
  1434. static void unuse_table(struct ctl_table_header *p)
  1435. {
  1436. if (!--p->used)
  1437. if (unlikely(p->unregistering))
  1438. complete(p->unregistering);
  1439. }
  1440. /* called under sysctl_lock, will reacquire if has to wait */
  1441. static void start_unregistering(struct ctl_table_header *p)
  1442. {
  1443. /*
  1444. * if p->used is 0, nobody will ever touch that entry again;
  1445. * we'll eliminate all paths to it before dropping sysctl_lock
  1446. */
  1447. if (unlikely(p->used)) {
  1448. struct completion wait;
  1449. init_completion(&wait);
  1450. p->unregistering = &wait;
  1451. spin_unlock(&sysctl_lock);
  1452. wait_for_completion(&wait);
  1453. spin_lock(&sysctl_lock);
  1454. } else {
  1455. /* anything non-NULL; we'll never dereference it */
  1456. p->unregistering = ERR_PTR(-EINVAL);
  1457. }
  1458. /*
  1459. * do not remove from the list until nobody holds it; walking the
  1460. * list in do_sysctl() relies on that.
  1461. */
  1462. list_del_init(&p->ctl_entry);
  1463. }
  1464. void sysctl_head_get(struct ctl_table_header *head)
  1465. {
  1466. spin_lock(&sysctl_lock);
  1467. head->count++;
  1468. spin_unlock(&sysctl_lock);
  1469. }
  1470. void sysctl_head_put(struct ctl_table_header *head)
  1471. {
  1472. spin_lock(&sysctl_lock);
  1473. if (!--head->count)
  1474. kfree(head);
  1475. spin_unlock(&sysctl_lock);
  1476. }
  1477. struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
  1478. {
  1479. if (!head)
  1480. BUG();
  1481. spin_lock(&sysctl_lock);
  1482. if (!use_table(head))
  1483. head = ERR_PTR(-ENOENT);
  1484. spin_unlock(&sysctl_lock);
  1485. return head;
  1486. }
  1487. void sysctl_head_finish(struct ctl_table_header *head)
  1488. {
  1489. if (!head)
  1490. return;
  1491. spin_lock(&sysctl_lock);
  1492. unuse_table(head);
  1493. spin_unlock(&sysctl_lock);
  1494. }
  1495. static struct ctl_table_set *
  1496. lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
  1497. {
  1498. struct ctl_table_set *set = &root->default_set;
  1499. if (root->lookup)
  1500. set = root->lookup(root, namespaces);
  1501. return set;
  1502. }
  1503. static struct list_head *
  1504. lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
  1505. {
  1506. struct ctl_table_set *set = lookup_header_set(root, namespaces);
  1507. return &set->list;
  1508. }
  1509. struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
  1510. struct ctl_table_header *prev)
  1511. {
  1512. struct ctl_table_root *root;
  1513. struct list_head *header_list;
  1514. struct ctl_table_header *head;
  1515. struct list_head *tmp;
  1516. spin_lock(&sysctl_lock);
  1517. if (prev) {
  1518. head = prev;
  1519. tmp = &prev->ctl_entry;
  1520. unuse_table(prev);
  1521. goto next;
  1522. }
  1523. tmp = &root_table_header.ctl_entry;
  1524. for (;;) {
  1525. head = list_entry(tmp, struct ctl_table_header, ctl_entry);
  1526. if (!use_table(head))
  1527. goto next;
  1528. spin_unlock(&sysctl_lock);
  1529. return head;
  1530. next:
  1531. root = head->root;
  1532. tmp = tmp->next;
  1533. header_list = lookup_header_list(root, namespaces);
  1534. if (tmp != header_list)
  1535. continue;
  1536. do {
  1537. root = list_entry(root->root_list.next,
  1538. struct ctl_table_root, root_list);
  1539. if (root == &sysctl_table_root)
  1540. goto out;
  1541. header_list = lookup_header_list(root, namespaces);
  1542. } while (list_empty(header_list));
  1543. tmp = header_list->next;
  1544. }
  1545. out:
  1546. spin_unlock(&sysctl_lock);
  1547. return NULL;
  1548. }
  1549. struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
  1550. {
  1551. return __sysctl_head_next(current->nsproxy, prev);
  1552. }
  1553. void register_sysctl_root(struct ctl_table_root *root)
  1554. {
  1555. spin_lock(&sysctl_lock);
  1556. list_add_tail(&root->root_list, &sysctl_table_root.root_list);
  1557. spin_unlock(&sysctl_lock);
  1558. }
  1559. /*
  1560. * sysctl_perm does NOT grant the superuser all rights automatically, because
  1561. * some sysctl variables are readonly even to root.
  1562. */
  1563. static int test_perm(int mode, int op)
  1564. {
  1565. if (!current_euid())
  1566. mode >>= 6;
  1567. else if (in_egroup_p(0))
  1568. mode >>= 3;
  1569. if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
  1570. return 0;
  1571. return -EACCES;
  1572. }
  1573. int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
  1574. {
  1575. int error;
  1576. int mode;
  1577. error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
  1578. if (error)
  1579. return error;
  1580. if (root->permissions)
  1581. mode = root->permissions(root, current->nsproxy, table);
  1582. else
  1583. mode = table->mode;
  1584. return test_perm(mode, op);
  1585. }
  1586. static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
  1587. {
  1588. for (; table->procname; table++) {
  1589. table->parent = parent;
  1590. if (table->child)
  1591. sysctl_set_parent(table, table->child);
  1592. }
  1593. }
  1594. static __init int sysctl_init(void)
  1595. {
  1596. sysctl_set_parent(NULL, root_table);
  1597. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1598. {
  1599. int err;
  1600. err = sysctl_check_table(current->nsproxy, root_table);
  1601. }
  1602. #endif
  1603. return 0;
  1604. }
  1605. core_initcall(sysctl_init);
  1606. static struct ctl_table *is_branch_in(struct ctl_table *branch,
  1607. struct ctl_table *table)
  1608. {
  1609. struct ctl_table *p;
  1610. const char *s = branch->procname;
  1611. /* branch should have named subdirectory as its first element */
  1612. if (!s || !branch->child)
  1613. return NULL;
  1614. /* ... and nothing else */
  1615. if (branch[1].procname)
  1616. return NULL;
  1617. /* table should contain subdirectory with the same name */
  1618. for (p = table; p->procname; p++) {
  1619. if (!p->child)
  1620. continue;
  1621. if (p->procname && strcmp(p->procname, s) == 0)
  1622. return p;
  1623. }
  1624. return NULL;
  1625. }
  1626. /* see if attaching q to p would be an improvement */
  1627. static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
  1628. {
  1629. struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
  1630. struct ctl_table *next;
  1631. int is_better = 0;
  1632. int not_in_parent = !p->attached_by;
  1633. while ((next = is_branch_in(by, to)) != NULL) {
  1634. if (by == q->attached_by)
  1635. is_better = 1;
  1636. if (to == p->attached_by)
  1637. not_in_parent = 1;
  1638. by = by->child;
  1639. to = next->child;
  1640. }
  1641. if (is_better && not_in_parent) {
  1642. q->attached_by = by;
  1643. q->attached_to = to;
  1644. q->parent = p;
  1645. }
  1646. }
  1647. /**
  1648. * __register_sysctl_paths - register a sysctl hierarchy
  1649. * @root: List of sysctl headers to register on
  1650. * @namespaces: Data to compute which lists of sysctl entries are visible
  1651. * @path: The path to the directory the sysctl table is in.
  1652. * @table: the top-level table structure
  1653. *
  1654. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1655. * array. A completely 0 filled entry terminates the table.
  1656. *
  1657. * The members of the &struct ctl_table structure are used as follows:
  1658. *
  1659. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1660. * enter a sysctl file
  1661. *
  1662. * data - a pointer to data for use by proc_handler
  1663. *
  1664. * maxlen - the maximum size in bytes of the data
  1665. *
  1666. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1667. *
  1668. * child - a pointer to the child sysctl table if this entry is a directory, or
  1669. * %NULL.
  1670. *
  1671. * proc_handler - the text handler routine (described below)
  1672. *
  1673. * de - for internal use by the sysctl routines
  1674. *
  1675. * extra1, extra2 - extra pointers usable by the proc handler routines
  1676. *
  1677. * Leaf nodes in the sysctl tree will be represented by a single file
  1678. * under /proc; non-leaf nodes will be represented by directories.
  1679. *
  1680. * sysctl(2) can automatically manage read and write requests through
  1681. * the sysctl table. The data and maxlen fields of the ctl_table
  1682. * struct enable minimal validation of the values being written to be
  1683. * performed, and the mode field allows minimal authentication.
  1684. *
  1685. * There must be a proc_handler routine for any terminal nodes
  1686. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1687. * directory handler). Several default handlers are available to
  1688. * cover common cases -
  1689. *
  1690. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1691. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1692. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1693. *
  1694. * It is the handler's job to read the input buffer from user memory
  1695. * and process it. The handler should return 0 on success.
  1696. *
  1697. * This routine returns %NULL on a failure to register, and a pointer
  1698. * to the table header on success.
  1699. */
  1700. struct ctl_table_header *__register_sysctl_paths(
  1701. struct ctl_table_root *root,
  1702. struct nsproxy *namespaces,
  1703. const struct ctl_path *path, struct ctl_table *table)
  1704. {
  1705. struct ctl_table_header *header;
  1706. struct ctl_table *new, **prevp;
  1707. unsigned int n, npath;
  1708. struct ctl_table_set *set;
  1709. /* Count the path components */
  1710. for (npath = 0; path[npath].procname; ++npath)
  1711. ;
  1712. /*
  1713. * For each path component, allocate a 2-element ctl_table array.
  1714. * The first array element will be filled with the sysctl entry
  1715. * for this, the second will be the sentinel (procname == 0).
  1716. *
  1717. * We allocate everything in one go so that we don't have to
  1718. * worry about freeing additional memory in unregister_sysctl_table.
  1719. */
  1720. header = kzalloc(sizeof(struct ctl_table_header) +
  1721. (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
  1722. if (!header)
  1723. return NULL;
  1724. new = (struct ctl_table *) (header + 1);
  1725. /* Now connect the dots */
  1726. prevp = &header->ctl_table;
  1727. for (n = 0; n < npath; ++n, ++path) {
  1728. /* Copy the procname */
  1729. new->procname = path->procname;
  1730. new->mode = 0555;
  1731. *prevp = new;
  1732. prevp = &new->child;
  1733. new += 2;
  1734. }
  1735. *prevp = table;
  1736. header->ctl_table_arg = table;
  1737. INIT_LIST_HEAD(&header->ctl_entry);
  1738. header->used = 0;
  1739. header->unregistering = NULL;
  1740. header->root = root;
  1741. sysctl_set_parent(NULL, header->ctl_table);
  1742. header->count = 1;
  1743. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1744. if (sysctl_check_table(namespaces, header->ctl_table)) {
  1745. kfree(header);
  1746. return NULL;
  1747. }
  1748. #endif
  1749. spin_lock(&sysctl_lock);
  1750. header->set = lookup_header_set(root, namespaces);
  1751. header->attached_by = header->ctl_table;
  1752. header->attached_to = root_table;
  1753. header->parent = &root_table_header;
  1754. for (set = header->set; set; set = set->parent) {
  1755. struct ctl_table_header *p;
  1756. list_for_each_entry(p, &set->list, ctl_entry) {
  1757. if (p->unregistering)
  1758. continue;
  1759. try_attach(p, header);
  1760. }
  1761. }
  1762. header->parent->count++;
  1763. list_add_tail(&header->ctl_entry, &header->set->list);
  1764. spin_unlock(&sysctl_lock);
  1765. return header;
  1766. }
  1767. /**
  1768. * register_sysctl_table_path - register a sysctl table hierarchy
  1769. * @path: The path to the directory the sysctl table is in.
  1770. * @table: the top-level table structure
  1771. *
  1772. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1773. * array. A completely 0 filled entry terminates the table.
  1774. *
  1775. * See __register_sysctl_paths for more details.
  1776. */
  1777. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1778. struct ctl_table *table)
  1779. {
  1780. return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
  1781. path, table);
  1782. }
  1783. /**
  1784. * register_sysctl_table - register a sysctl table hierarchy
  1785. * @table: the top-level table structure
  1786. *
  1787. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1788. * array. A completely 0 filled entry terminates the table.
  1789. *
  1790. * See register_sysctl_paths for more details.
  1791. */
  1792. struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
  1793. {
  1794. static const struct ctl_path null_path[] = { {} };
  1795. return register_sysctl_paths(null_path, table);
  1796. }
  1797. /**
  1798. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1799. * @header: the header returned from register_sysctl_table
  1800. *
  1801. * Unregisters the sysctl table and all children. proc entries may not
  1802. * actually be removed until they are no longer used by anyone.
  1803. */
  1804. void unregister_sysctl_table(struct ctl_table_header * header)
  1805. {
  1806. might_sleep();
  1807. if (header == NULL)
  1808. return;
  1809. spin_lock(&sysctl_lock);
  1810. start_unregistering(header);
  1811. if (!--header->parent->count) {
  1812. WARN_ON(1);
  1813. kfree(header->parent);
  1814. }
  1815. if (!--header->count)
  1816. kfree(header);
  1817. spin_unlock(&sysctl_lock);
  1818. }
  1819. int sysctl_is_seen(struct ctl_table_header *p)
  1820. {
  1821. struct ctl_table_set *set = p->set;
  1822. int res;
  1823. spin_lock(&sysctl_lock);
  1824. if (p->unregistering)
  1825. res = 0;
  1826. else if (!set->is_seen)
  1827. res = 1;
  1828. else
  1829. res = set->is_seen(set);
  1830. spin_unlock(&sysctl_lock);
  1831. return res;
  1832. }
  1833. void setup_sysctl_set(struct ctl_table_set *p,
  1834. struct ctl_table_set *parent,
  1835. int (*is_seen)(struct ctl_table_set *))
  1836. {
  1837. INIT_LIST_HEAD(&p->list);
  1838. p->parent = parent ? parent : &sysctl_table_root.default_set;
  1839. p->is_seen = is_seen;
  1840. }
  1841. #else /* !CONFIG_SYSCTL */
  1842. struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
  1843. {
  1844. return NULL;
  1845. }
  1846. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1847. struct ctl_table *table)
  1848. {
  1849. return NULL;
  1850. }
  1851. void unregister_sysctl_table(struct ctl_table_header * table)
  1852. {
  1853. }
  1854. void setup_sysctl_set(struct ctl_table_set *p,
  1855. struct ctl_table_set *parent,
  1856. int (*is_seen)(struct ctl_table_set *))
  1857. {
  1858. }
  1859. void sysctl_head_put(struct ctl_table_header *head)
  1860. {
  1861. }
  1862. #endif /* CONFIG_SYSCTL */
  1863. /*
  1864. * /proc/sys support
  1865. */
  1866. #ifdef CONFIG_PROC_SYSCTL
  1867. static int _proc_do_string(void* data, int maxlen, int write,
  1868. void __user *buffer,
  1869. size_t *lenp, loff_t *ppos)
  1870. {
  1871. size_t len;
  1872. char __user *p;
  1873. char c;
  1874. if (!data || !maxlen || !*lenp) {
  1875. *lenp = 0;
  1876. return 0;
  1877. }
  1878. if (write) {
  1879. len = 0;
  1880. p = buffer;
  1881. while (len < *lenp) {
  1882. if (get_user(c, p++))
  1883. return -EFAULT;
  1884. if (c == 0 || c == '\n')
  1885. break;
  1886. len++;
  1887. }
  1888. if (len >= maxlen)
  1889. len = maxlen-1;
  1890. if(copy_from_user(data, buffer, len))
  1891. return -EFAULT;
  1892. ((char *) data)[len] = 0;
  1893. *ppos += *lenp;
  1894. } else {
  1895. len = strlen(data);
  1896. if (len > maxlen)
  1897. len = maxlen;
  1898. if (*ppos > len) {
  1899. *lenp = 0;
  1900. return 0;
  1901. }
  1902. data += *ppos;
  1903. len -= *ppos;
  1904. if (len > *lenp)
  1905. len = *lenp;
  1906. if (len)
  1907. if(copy_to_user(buffer, data, len))
  1908. return -EFAULT;
  1909. if (len < *lenp) {
  1910. if(put_user('\n', ((char __user *) buffer) + len))
  1911. return -EFAULT;
  1912. len++;
  1913. }
  1914. *lenp = len;
  1915. *ppos += len;
  1916. }
  1917. return 0;
  1918. }
  1919. /**
  1920. * proc_dostring - read a string sysctl
  1921. * @table: the sysctl table
  1922. * @write: %TRUE if this is a write to the sysctl file
  1923. * @buffer: the user buffer
  1924. * @lenp: the size of the user buffer
  1925. * @ppos: file position
  1926. *
  1927. * Reads/writes a string from/to the user buffer. If the kernel
  1928. * buffer provided is not large enough to hold the string, the
  1929. * string is truncated. The copied string is %NULL-terminated.
  1930. * If the string is being read by the user process, it is copied
  1931. * and a newline '\n' is added. It is truncated if the buffer is
  1932. * not large enough.
  1933. *
  1934. * Returns 0 on success.
  1935. */
  1936. int proc_dostring(struct ctl_table *table, int write,
  1937. void __user *buffer, size_t *lenp, loff_t *ppos)
  1938. {
  1939. return _proc_do_string(table->data, table->maxlen, write,
  1940. buffer, lenp, ppos);
  1941. }
  1942. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  1943. int *valp,
  1944. int write, void *data)
  1945. {
  1946. if (write) {
  1947. *valp = *negp ? -*lvalp : *lvalp;
  1948. } else {
  1949. int val = *valp;
  1950. if (val < 0) {
  1951. *negp = -1;
  1952. *lvalp = (unsigned long)-val;
  1953. } else {
  1954. *negp = 0;
  1955. *lvalp = (unsigned long)val;
  1956. }
  1957. }
  1958. return 0;
  1959. }
  1960. static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
  1961. int write, void __user *buffer,
  1962. size_t *lenp, loff_t *ppos,
  1963. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1964. int write, void *data),
  1965. void *data)
  1966. {
  1967. #define TMPBUFLEN 21
  1968. int *i, vleft, first = 1, neg;
  1969. unsigned long lval;
  1970. size_t left, len;
  1971. char buf[TMPBUFLEN], *p;
  1972. char __user *s = buffer;
  1973. if (!tbl_data || !table->maxlen || !*lenp ||
  1974. (*ppos && !write)) {
  1975. *lenp = 0;
  1976. return 0;
  1977. }
  1978. i = (int *) tbl_data;
  1979. vleft = table->maxlen / sizeof(*i);
  1980. left = *lenp;
  1981. if (!conv)
  1982. conv = do_proc_dointvec_conv;
  1983. for (; left && vleft--; i++, first=0) {
  1984. if (write) {
  1985. while (left) {
  1986. char c;
  1987. if (get_user(c, s))
  1988. return -EFAULT;
  1989. if (!isspace(c))
  1990. break;
  1991. left--;
  1992. s++;
  1993. }
  1994. if (!left)
  1995. break;
  1996. neg = 0;
  1997. len = left;
  1998. if (len > sizeof(buf) - 1)
  1999. len = sizeof(buf) - 1;
  2000. if (copy_from_user(buf, s, len))
  2001. return -EFAULT;
  2002. buf[len] = 0;
  2003. p = buf;
  2004. if (*p == '-' && left > 1) {
  2005. neg = 1;
  2006. p++;
  2007. }
  2008. if (*p < '0' || *p > '9')
  2009. break;
  2010. lval = simple_strtoul(p, &p, 0);
  2011. len = p-buf;
  2012. if ((len < left) && *p && !isspace(*p))
  2013. break;
  2014. s += len;
  2015. left -= len;
  2016. if (conv(&neg, &lval, i, 1, data))
  2017. break;
  2018. } else {
  2019. p = buf;
  2020. if (!first)
  2021. *p++ = '\t';
  2022. if (conv(&neg, &lval, i, 0, data))
  2023. break;
  2024. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  2025. len = strlen(buf);
  2026. if (len > left)
  2027. len = left;
  2028. if(copy_to_user(s, buf, len))
  2029. return -EFAULT;
  2030. left -= len;
  2031. s += len;
  2032. }
  2033. }
  2034. if (!write && !first && left) {
  2035. if(put_user('\n', s))
  2036. return -EFAULT;
  2037. left--, s++;
  2038. }
  2039. if (write) {
  2040. while (left) {
  2041. char c;
  2042. if (get_user(c, s++))
  2043. return -EFAULT;
  2044. if (!isspace(c))
  2045. break;
  2046. left--;
  2047. }
  2048. }
  2049. if (write && first)
  2050. return -EINVAL;
  2051. *lenp -= left;
  2052. *ppos += *lenp;
  2053. return 0;
  2054. #undef TMPBUFLEN
  2055. }
  2056. static int do_proc_dointvec(struct ctl_table *table, int write,
  2057. void __user *buffer, size_t *lenp, loff_t *ppos,
  2058. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  2059. int write, void *data),
  2060. void *data)
  2061. {
  2062. return __do_proc_dointvec(table->data, table, write,
  2063. buffer, lenp, ppos, conv, data);
  2064. }
  2065. /**
  2066. * proc_dointvec - read a vector of integers
  2067. * @table: the sysctl table
  2068. * @write: %TRUE if this is a write to the sysctl file
  2069. * @buffer: the user buffer
  2070. * @lenp: the size of the user buffer
  2071. * @ppos: file position
  2072. *
  2073. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2074. * values from/to the user buffer, treated as an ASCII string.
  2075. *
  2076. * Returns 0 on success.
  2077. */
  2078. int proc_dointvec(struct ctl_table *table, int write,
  2079. void __user *buffer, size_t *lenp, loff_t *ppos)
  2080. {
  2081. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2082. NULL,NULL);
  2083. }
  2084. /*
  2085. * Taint values can only be increased
  2086. * This means we can safely use a temporary.
  2087. */
  2088. static int proc_taint(struct ctl_table *table, int write,
  2089. void __user *buffer, size_t *lenp, loff_t *ppos)
  2090. {
  2091. struct ctl_table t;
  2092. unsigned long tmptaint = get_taint();
  2093. int err;
  2094. if (write && !capable(CAP_SYS_ADMIN))
  2095. return -EPERM;
  2096. t = *table;
  2097. t.data = &tmptaint;
  2098. err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
  2099. if (err < 0)
  2100. return err;
  2101. if (write) {
  2102. /*
  2103. * Poor man's atomic or. Not worth adding a primitive
  2104. * to everyone's atomic.h for this
  2105. */
  2106. int i;
  2107. for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
  2108. if ((tmptaint >> i) & 1)
  2109. add_taint(i);
  2110. }
  2111. }
  2112. return err;
  2113. }
  2114. struct do_proc_dointvec_minmax_conv_param {
  2115. int *min;
  2116. int *max;
  2117. };
  2118. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  2119. int *valp,
  2120. int write, void *data)
  2121. {
  2122. struct do_proc_dointvec_minmax_conv_param *param = data;
  2123. if (write) {
  2124. int val = *negp ? -*lvalp : *lvalp;
  2125. if ((param->min && *param->min > val) ||
  2126. (param->max && *param->max < val))
  2127. return -EINVAL;
  2128. *valp = val;
  2129. } else {
  2130. int val = *valp;
  2131. if (val < 0) {
  2132. *negp = -1;
  2133. *lvalp = (unsigned long)-val;
  2134. } else {
  2135. *negp = 0;
  2136. *lvalp = (unsigned long)val;
  2137. }
  2138. }
  2139. return 0;
  2140. }
  2141. /**
  2142. * proc_dointvec_minmax - read a vector of integers with min/max values
  2143. * @table: the sysctl table
  2144. * @write: %TRUE if this is a write to the sysctl file
  2145. * @buffer: the user buffer
  2146. * @lenp: the size of the user buffer
  2147. * @ppos: file position
  2148. *
  2149. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2150. * values from/to the user buffer, treated as an ASCII string.
  2151. *
  2152. * This routine will ensure the values are within the range specified by
  2153. * table->extra1 (min) and table->extra2 (max).
  2154. *
  2155. * Returns 0 on success.
  2156. */
  2157. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2158. void __user *buffer, size_t *lenp, loff_t *ppos)
  2159. {
  2160. struct do_proc_dointvec_minmax_conv_param param = {
  2161. .min = (int *) table->extra1,
  2162. .max = (int *) table->extra2,
  2163. };
  2164. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2165. do_proc_dointvec_minmax_conv, &param);
  2166. }
  2167. static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
  2168. void __user *buffer,
  2169. size_t *lenp, loff_t *ppos,
  2170. unsigned long convmul,
  2171. unsigned long convdiv)
  2172. {
  2173. #define TMPBUFLEN 21
  2174. unsigned long *i, *min, *max, val;
  2175. int vleft, first=1, neg;
  2176. size_t len, left;
  2177. char buf[TMPBUFLEN], *p;
  2178. char __user *s = buffer;
  2179. if (!data || !table->maxlen || !*lenp ||
  2180. (*ppos && !write)) {
  2181. *lenp = 0;
  2182. return 0;
  2183. }
  2184. i = (unsigned long *) data;
  2185. min = (unsigned long *) table->extra1;
  2186. max = (unsigned long *) table->extra2;
  2187. vleft = table->maxlen / sizeof(unsigned long);
  2188. left = *lenp;
  2189. for (; left && vleft--; i++, min++, max++, first=0) {
  2190. if (write) {
  2191. while (left) {
  2192. char c;
  2193. if (get_user(c, s))
  2194. return -EFAULT;
  2195. if (!isspace(c))
  2196. break;
  2197. left--;
  2198. s++;
  2199. }
  2200. if (!left)
  2201. break;
  2202. neg = 0;
  2203. len = left;
  2204. if (len > TMPBUFLEN-1)
  2205. len = TMPBUFLEN-1;
  2206. if (copy_from_user(buf, s, len))
  2207. return -EFAULT;
  2208. buf[len] = 0;
  2209. p = buf;
  2210. if (*p == '-' && left > 1) {
  2211. neg = 1;
  2212. p++;
  2213. }
  2214. if (*p < '0' || *p > '9')
  2215. break;
  2216. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  2217. len = p-buf;
  2218. if ((len < left) && *p && !isspace(*p))
  2219. break;
  2220. if (neg)
  2221. val = -val;
  2222. s += len;
  2223. left -= len;
  2224. if(neg)
  2225. continue;
  2226. if ((min && val < *min) || (max && val > *max))
  2227. continue;
  2228. *i = val;
  2229. } else {
  2230. p = buf;
  2231. if (!first)
  2232. *p++ = '\t';
  2233. sprintf(p, "%lu", convdiv * (*i) / convmul);
  2234. len = strlen(buf);
  2235. if (len > left)
  2236. len = left;
  2237. if(copy_to_user(s, buf, len))
  2238. return -EFAULT;
  2239. left -= len;
  2240. s += len;
  2241. }
  2242. }
  2243. if (!write && !first && left) {
  2244. if(put_user('\n', s))
  2245. return -EFAULT;
  2246. left--, s++;
  2247. }
  2248. if (write) {
  2249. while (left) {
  2250. char c;
  2251. if (get_user(c, s++))
  2252. return -EFAULT;
  2253. if (!isspace(c))
  2254. break;
  2255. left--;
  2256. }
  2257. }
  2258. if (write && first)
  2259. return -EINVAL;
  2260. *lenp -= left;
  2261. *ppos += *lenp;
  2262. return 0;
  2263. #undef TMPBUFLEN
  2264. }
  2265. static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
  2266. void __user *buffer,
  2267. size_t *lenp, loff_t *ppos,
  2268. unsigned long convmul,
  2269. unsigned long convdiv)
  2270. {
  2271. return __do_proc_doulongvec_minmax(table->data, table, write,
  2272. buffer, lenp, ppos, convmul, convdiv);
  2273. }
  2274. /**
  2275. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  2276. * @table: the sysctl table
  2277. * @write: %TRUE if this is a write to the sysctl file
  2278. * @buffer: the user buffer
  2279. * @lenp: the size of the user buffer
  2280. * @ppos: file position
  2281. *
  2282. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2283. * values from/to the user buffer, treated as an ASCII string.
  2284. *
  2285. * This routine will ensure the values are within the range specified by
  2286. * table->extra1 (min) and table->extra2 (max).
  2287. *
  2288. * Returns 0 on success.
  2289. */
  2290. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2291. void __user *buffer, size_t *lenp, loff_t *ppos)
  2292. {
  2293. return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
  2294. }
  2295. /**
  2296. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  2297. * @table: the sysctl table
  2298. * @write: %TRUE if this is a write to the sysctl file
  2299. * @buffer: the user buffer
  2300. * @lenp: the size of the user buffer
  2301. * @ppos: file position
  2302. *
  2303. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2304. * values from/to the user buffer, treated as an ASCII string. The values
  2305. * are treated as milliseconds, and converted to jiffies when they are stored.
  2306. *
  2307. * This routine will ensure the values are within the range specified by
  2308. * table->extra1 (min) and table->extra2 (max).
  2309. *
  2310. * Returns 0 on success.
  2311. */
  2312. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2313. void __user *buffer,
  2314. size_t *lenp, loff_t *ppos)
  2315. {
  2316. return do_proc_doulongvec_minmax(table, write, buffer,
  2317. lenp, ppos, HZ, 1000l);
  2318. }
  2319. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  2320. int *valp,
  2321. int write, void *data)
  2322. {
  2323. if (write) {
  2324. if (*lvalp > LONG_MAX / HZ)
  2325. return 1;
  2326. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2327. } else {
  2328. int val = *valp;
  2329. unsigned long lval;
  2330. if (val < 0) {
  2331. *negp = -1;
  2332. lval = (unsigned long)-val;
  2333. } else {
  2334. *negp = 0;
  2335. lval = (unsigned long)val;
  2336. }
  2337. *lvalp = lval / HZ;
  2338. }
  2339. return 0;
  2340. }
  2341. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2342. int *valp,
  2343. int write, void *data)
  2344. {
  2345. if (write) {
  2346. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2347. return 1;
  2348. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2349. } else {
  2350. int val = *valp;
  2351. unsigned long lval;
  2352. if (val < 0) {
  2353. *negp = -1;
  2354. lval = (unsigned long)-val;
  2355. } else {
  2356. *negp = 0;
  2357. lval = (unsigned long)val;
  2358. }
  2359. *lvalp = jiffies_to_clock_t(lval);
  2360. }
  2361. return 0;
  2362. }
  2363. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2364. int *valp,
  2365. int write, void *data)
  2366. {
  2367. if (write) {
  2368. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2369. } else {
  2370. int val = *valp;
  2371. unsigned long lval;
  2372. if (val < 0) {
  2373. *negp = -1;
  2374. lval = (unsigned long)-val;
  2375. } else {
  2376. *negp = 0;
  2377. lval = (unsigned long)val;
  2378. }
  2379. *lvalp = jiffies_to_msecs(lval);
  2380. }
  2381. return 0;
  2382. }
  2383. /**
  2384. * proc_dointvec_jiffies - read a vector of integers as seconds
  2385. * @table: the sysctl table
  2386. * @write: %TRUE if this is a write to the sysctl file
  2387. * @buffer: the user buffer
  2388. * @lenp: the size of the user buffer
  2389. * @ppos: file position
  2390. *
  2391. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2392. * values from/to the user buffer, treated as an ASCII string.
  2393. * The values read are assumed to be in seconds, and are converted into
  2394. * jiffies.
  2395. *
  2396. * Returns 0 on success.
  2397. */
  2398. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2399. void __user *buffer, size_t *lenp, loff_t *ppos)
  2400. {
  2401. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2402. do_proc_dointvec_jiffies_conv,NULL);
  2403. }
  2404. /**
  2405. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2406. * @table: the sysctl table
  2407. * @write: %TRUE if this is a write to the sysctl file
  2408. * @buffer: the user buffer
  2409. * @lenp: the size of the user buffer
  2410. * @ppos: pointer to the file position
  2411. *
  2412. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2413. * values from/to the user buffer, treated as an ASCII string.
  2414. * The values read are assumed to be in 1/USER_HZ seconds, and
  2415. * are converted into jiffies.
  2416. *
  2417. * Returns 0 on success.
  2418. */
  2419. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2420. void __user *buffer, size_t *lenp, loff_t *ppos)
  2421. {
  2422. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2423. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2424. }
  2425. /**
  2426. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2427. * @table: the sysctl table
  2428. * @write: %TRUE if this is a write to the sysctl file
  2429. * @buffer: the user buffer
  2430. * @lenp: the size of the user buffer
  2431. * @ppos: file position
  2432. * @ppos: the current position in the file
  2433. *
  2434. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2435. * values from/to the user buffer, treated as an ASCII string.
  2436. * The values read are assumed to be in 1/1000 seconds, and
  2437. * are converted into jiffies.
  2438. *
  2439. * Returns 0 on success.
  2440. */
  2441. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2442. void __user *buffer, size_t *lenp, loff_t *ppos)
  2443. {
  2444. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2445. do_proc_dointvec_ms_jiffies_conv, NULL);
  2446. }
  2447. static int proc_do_cad_pid(struct ctl_table *table, int write,
  2448. void __user *buffer, size_t *lenp, loff_t *ppos)
  2449. {
  2450. struct pid *new_pid;
  2451. pid_t tmp;
  2452. int r;
  2453. tmp = pid_vnr(cad_pid);
  2454. r = __do_proc_dointvec(&tmp, table, write, buffer,
  2455. lenp, ppos, NULL, NULL);
  2456. if (r || !write)
  2457. return r;
  2458. new_pid = find_get_pid(tmp);
  2459. if (!new_pid)
  2460. return -ESRCH;
  2461. put_pid(xchg(&cad_pid, new_pid));
  2462. return 0;
  2463. }
  2464. #else /* CONFIG_PROC_FS */
  2465. int proc_dostring(struct ctl_table *table, int write,
  2466. void __user *buffer, size_t *lenp, loff_t *ppos)
  2467. {
  2468. return -ENOSYS;
  2469. }
  2470. int proc_dointvec(struct ctl_table *table, int write,
  2471. void __user *buffer, size_t *lenp, loff_t *ppos)
  2472. {
  2473. return -ENOSYS;
  2474. }
  2475. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2476. void __user *buffer, size_t *lenp, loff_t *ppos)
  2477. {
  2478. return -ENOSYS;
  2479. }
  2480. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2481. void __user *buffer, size_t *lenp, loff_t *ppos)
  2482. {
  2483. return -ENOSYS;
  2484. }
  2485. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2486. void __user *buffer, size_t *lenp, loff_t *ppos)
  2487. {
  2488. return -ENOSYS;
  2489. }
  2490. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2491. void __user *buffer, size_t *lenp, loff_t *ppos)
  2492. {
  2493. return -ENOSYS;
  2494. }
  2495. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2496. void __user *buffer, size_t *lenp, loff_t *ppos)
  2497. {
  2498. return -ENOSYS;
  2499. }
  2500. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2501. void __user *buffer,
  2502. size_t *lenp, loff_t *ppos)
  2503. {
  2504. return -ENOSYS;
  2505. }
  2506. #endif /* CONFIG_PROC_FS */
  2507. /*
  2508. * No sense putting this after each symbol definition, twice,
  2509. * exception granted :-)
  2510. */
  2511. EXPORT_SYMBOL(proc_dointvec);
  2512. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2513. EXPORT_SYMBOL(proc_dointvec_minmax);
  2514. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2515. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2516. EXPORT_SYMBOL(proc_dostring);
  2517. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2518. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2519. EXPORT_SYMBOL(register_sysctl_table);
  2520. EXPORT_SYMBOL(register_sysctl_paths);
  2521. EXPORT_SYMBOL(unregister_sysctl_table);