sysctl.c 75 KB

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