sysctl.c 75 KB

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