sysctl.c 74 KB

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