sysctl.c 75 KB

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