sysctl.c 75 KB

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