sysctl.c 62 KB

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