sysctl.c 62 KB

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