sysctl.c 62 KB

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