sysctl.c 62 KB

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