sysctl.c 74 KB

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