sysctl.c 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619
  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/capability.h>
  27. #include <linux/ctype.h>
  28. #include <linux/utsname.h>
  29. #include <linux/smp_lock.h>
  30. #include <linux/fs.h>
  31. #include <linux/init.h>
  32. #include <linux/kernel.h>
  33. #include <linux/kobject.h>
  34. #include <linux/net.h>
  35. #include <linux/sysrq.h>
  36. #include <linux/highuid.h>
  37. #include <linux/writeback.h>
  38. #include <linux/hugetlb.h>
  39. #include <linux/security.h>
  40. #include <linux/initrd.h>
  41. #include <linux/times.h>
  42. #include <linux/limits.h>
  43. #include <linux/dcache.h>
  44. #include <linux/syscalls.h>
  45. #include <linux/nfs_fs.h>
  46. #include <linux/acpi.h>
  47. #include <linux/reboot.h>
  48. #include <asm/uaccess.h>
  49. #include <asm/processor.h>
  50. #ifdef CONFIG_X86
  51. #include <asm/nmi.h>
  52. #include <asm/stacktrace.h>
  53. #endif
  54. #if defined(CONFIG_SYSCTL)
  55. /* External variables not in a header file. */
  56. extern int C_A_D;
  57. extern int print_fatal_signals;
  58. extern int sysctl_overcommit_memory;
  59. extern int sysctl_overcommit_ratio;
  60. extern int sysctl_panic_on_oom;
  61. extern int sysctl_oom_kill_allocating_task;
  62. extern int max_threads;
  63. extern int core_uses_pid;
  64. extern int suid_dumpable;
  65. extern char core_pattern[];
  66. extern int pid_max;
  67. extern int min_free_kbytes;
  68. extern int printk_ratelimit_jiffies;
  69. extern int printk_ratelimit_burst;
  70. extern int pid_max_min, pid_max_max;
  71. extern int sysctl_drop_caches;
  72. extern int percpu_pagelist_fraction;
  73. extern int compat_log;
  74. extern int maps_protect;
  75. extern int sysctl_stat_interval;
  76. extern int audit_argv_kb;
  77. /* Constants used for minimum and maximum */
  78. #ifdef CONFIG_DETECT_SOFTLOCKUP
  79. static int one = 1;
  80. static int sixty = 60;
  81. #endif
  82. #ifdef CONFIG_MMU
  83. static int two = 2;
  84. #endif
  85. static int zero;
  86. static int one_hundred = 100;
  87. /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
  88. static int maxolduid = 65535;
  89. static int minolduid;
  90. static int min_percpu_pagelist_fract = 8;
  91. static int ngroups_max = NGROUPS_MAX;
  92. #ifdef CONFIG_KMOD
  93. extern char modprobe_path[];
  94. #endif
  95. #ifdef CONFIG_CHR_DEV_SG
  96. extern int sg_big_buff;
  97. #endif
  98. #ifdef __sparc__
  99. extern char reboot_command [];
  100. extern int stop_a_enabled;
  101. extern int scons_pwroff;
  102. #endif
  103. #ifdef __hppa__
  104. extern int pwrsw_enabled;
  105. extern int unaligned_enabled;
  106. #endif
  107. #ifdef CONFIG_S390
  108. #ifdef CONFIG_MATHEMU
  109. extern int sysctl_ieee_emulation_warnings;
  110. #endif
  111. extern int sysctl_userprocess_debug;
  112. extern int spin_retry;
  113. #endif
  114. extern int sysctl_hz_timer;
  115. #ifdef CONFIG_BSD_PROCESS_ACCT
  116. extern int acct_parm[];
  117. #endif
  118. #ifdef CONFIG_IA64
  119. extern int no_unaligned_warning;
  120. #endif
  121. #ifdef CONFIG_RT_MUTEXES
  122. extern int max_lock_depth;
  123. #endif
  124. #ifdef CONFIG_SYSCTL_SYSCALL
  125. static int parse_table(int __user *, int, void __user *, size_t __user *,
  126. void __user *, size_t, ctl_table *);
  127. #endif
  128. #ifdef CONFIG_PROC_SYSCTL
  129. static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
  130. void __user *buffer, size_t *lenp, loff_t *ppos);
  131. static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
  132. void __user *buffer, size_t *lenp, loff_t *ppos);
  133. #endif
  134. static ctl_table root_table[];
  135. static struct ctl_table_header root_table_header =
  136. { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
  137. static ctl_table kern_table[];
  138. static ctl_table vm_table[];
  139. static ctl_table fs_table[];
  140. static ctl_table debug_table[];
  141. static ctl_table dev_table[];
  142. extern ctl_table random_table[];
  143. #ifdef CONFIG_UNIX98_PTYS
  144. extern ctl_table pty_table[];
  145. #endif
  146. #ifdef CONFIG_INOTIFY_USER
  147. extern ctl_table inotify_table[];
  148. #endif
  149. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  150. int sysctl_legacy_va_layout;
  151. #endif
  152. extern int prove_locking;
  153. extern int lock_stat;
  154. /* The default sysctl tables: */
  155. static ctl_table root_table[] = {
  156. {
  157. .ctl_name = CTL_KERN,
  158. .procname = "kernel",
  159. .mode = 0555,
  160. .child = kern_table,
  161. },
  162. {
  163. .ctl_name = CTL_VM,
  164. .procname = "vm",
  165. .mode = 0555,
  166. .child = vm_table,
  167. },
  168. #ifdef CONFIG_NET
  169. {
  170. .ctl_name = CTL_NET,
  171. .procname = "net",
  172. .mode = 0555,
  173. .child = net_table,
  174. },
  175. #endif
  176. {
  177. .ctl_name = CTL_FS,
  178. .procname = "fs",
  179. .mode = 0555,
  180. .child = fs_table,
  181. },
  182. {
  183. .ctl_name = CTL_DEBUG,
  184. .procname = "debug",
  185. .mode = 0555,
  186. .child = debug_table,
  187. },
  188. {
  189. .ctl_name = CTL_DEV,
  190. .procname = "dev",
  191. .mode = 0555,
  192. .child = dev_table,
  193. },
  194. /*
  195. * NOTE: do not add new entries to this table unless you have read
  196. * Documentation/sysctl/ctl_unnumbered.txt
  197. */
  198. { .ctl_name = 0 }
  199. };
  200. #ifdef CONFIG_SCHED_DEBUG
  201. static unsigned long min_sched_granularity_ns = 100000; /* 100 usecs */
  202. static unsigned long max_sched_granularity_ns = 1000000000; /* 1 second */
  203. static unsigned long min_wakeup_granularity_ns; /* 0 usecs */
  204. static unsigned long max_wakeup_granularity_ns = 1000000000; /* 1 second */
  205. #endif
  206. static ctl_table kern_table[] = {
  207. #ifdef CONFIG_SCHED_DEBUG
  208. {
  209. .ctl_name = CTL_UNNUMBERED,
  210. .procname = "sched_nr_latency",
  211. .data = &sysctl_sched_nr_latency,
  212. .maxlen = sizeof(unsigned int),
  213. .mode = 0644,
  214. .proc_handler = &proc_dointvec,
  215. },
  216. {
  217. .ctl_name = CTL_UNNUMBERED,
  218. .procname = "sched_latency_ns",
  219. .data = &sysctl_sched_latency,
  220. .maxlen = sizeof(unsigned int),
  221. .mode = 0644,
  222. .proc_handler = &proc_dointvec_minmax,
  223. .strategy = &sysctl_intvec,
  224. .extra1 = &min_sched_granularity_ns,
  225. .extra2 = &max_sched_granularity_ns,
  226. },
  227. {
  228. .ctl_name = CTL_UNNUMBERED,
  229. .procname = "sched_wakeup_granularity_ns",
  230. .data = &sysctl_sched_wakeup_granularity,
  231. .maxlen = sizeof(unsigned int),
  232. .mode = 0644,
  233. .proc_handler = &proc_dointvec_minmax,
  234. .strategy = &sysctl_intvec,
  235. .extra1 = &min_wakeup_granularity_ns,
  236. .extra2 = &max_wakeup_granularity_ns,
  237. },
  238. {
  239. .ctl_name = CTL_UNNUMBERED,
  240. .procname = "sched_batch_wakeup_granularity_ns",
  241. .data = &sysctl_sched_batch_wakeup_granularity,
  242. .maxlen = sizeof(unsigned int),
  243. .mode = 0644,
  244. .proc_handler = &proc_dointvec_minmax,
  245. .strategy = &sysctl_intvec,
  246. .extra1 = &min_wakeup_granularity_ns,
  247. .extra2 = &max_wakeup_granularity_ns,
  248. },
  249. {
  250. .ctl_name = CTL_UNNUMBERED,
  251. .procname = "sched_child_runs_first",
  252. .data = &sysctl_sched_child_runs_first,
  253. .maxlen = sizeof(unsigned int),
  254. .mode = 0644,
  255. .proc_handler = &proc_dointvec,
  256. },
  257. {
  258. .ctl_name = CTL_UNNUMBERED,
  259. .procname = "sched_features",
  260. .data = &sysctl_sched_features,
  261. .maxlen = sizeof(unsigned int),
  262. .mode = 0644,
  263. .proc_handler = &proc_dointvec,
  264. },
  265. {
  266. .ctl_name = CTL_UNNUMBERED,
  267. .procname = "sched_migration_cost",
  268. .data = &sysctl_sched_migration_cost,
  269. .maxlen = sizeof(unsigned int),
  270. .mode = 0644,
  271. .proc_handler = &proc_dointvec,
  272. },
  273. #endif
  274. {
  275. .ctl_name = CTL_UNNUMBERED,
  276. .procname = "sched_compat_yield",
  277. .data = &sysctl_sched_compat_yield,
  278. .maxlen = sizeof(unsigned int),
  279. .mode = 0644,
  280. .proc_handler = &proc_dointvec,
  281. },
  282. #ifdef CONFIG_PROVE_LOCKING
  283. {
  284. .ctl_name = CTL_UNNUMBERED,
  285. .procname = "prove_locking",
  286. .data = &prove_locking,
  287. .maxlen = sizeof(int),
  288. .mode = 0644,
  289. .proc_handler = &proc_dointvec,
  290. },
  291. #endif
  292. #ifdef CONFIG_LOCK_STAT
  293. {
  294. .ctl_name = CTL_UNNUMBERED,
  295. .procname = "lock_stat",
  296. .data = &lock_stat,
  297. .maxlen = sizeof(int),
  298. .mode = 0644,
  299. .proc_handler = &proc_dointvec,
  300. },
  301. #endif
  302. {
  303. .ctl_name = KERN_PANIC,
  304. .procname = "panic",
  305. .data = &panic_timeout,
  306. .maxlen = sizeof(int),
  307. .mode = 0644,
  308. .proc_handler = &proc_dointvec,
  309. },
  310. {
  311. .ctl_name = KERN_CORE_USES_PID,
  312. .procname = "core_uses_pid",
  313. .data = &core_uses_pid,
  314. .maxlen = sizeof(int),
  315. .mode = 0644,
  316. .proc_handler = &proc_dointvec,
  317. },
  318. #ifdef CONFIG_AUDITSYSCALL
  319. {
  320. .ctl_name = CTL_UNNUMBERED,
  321. .procname = "audit_argv_kb",
  322. .data = &audit_argv_kb,
  323. .maxlen = sizeof(int),
  324. .mode = 0644,
  325. .proc_handler = &proc_dointvec,
  326. },
  327. #endif
  328. {
  329. .ctl_name = KERN_CORE_PATTERN,
  330. .procname = "core_pattern",
  331. .data = core_pattern,
  332. .maxlen = CORENAME_MAX_SIZE,
  333. .mode = 0644,
  334. .proc_handler = &proc_dostring,
  335. .strategy = &sysctl_string,
  336. },
  337. #ifdef CONFIG_PROC_SYSCTL
  338. {
  339. .ctl_name = KERN_TAINTED,
  340. .procname = "tainted",
  341. .data = &tainted,
  342. .maxlen = sizeof(int),
  343. .mode = 0644,
  344. .proc_handler = &proc_dointvec_taint,
  345. },
  346. #endif
  347. {
  348. .ctl_name = KERN_CAP_BSET,
  349. .procname = "cap-bound",
  350. .data = &cap_bset,
  351. .maxlen = sizeof(kernel_cap_t),
  352. .mode = 0600,
  353. .proc_handler = &proc_dointvec_bset,
  354. },
  355. #ifdef CONFIG_BLK_DEV_INITRD
  356. {
  357. .ctl_name = KERN_REALROOTDEV,
  358. .procname = "real-root-dev",
  359. .data = &real_root_dev,
  360. .maxlen = sizeof(int),
  361. .mode = 0644,
  362. .proc_handler = &proc_dointvec,
  363. },
  364. #endif
  365. {
  366. .ctl_name = CTL_UNNUMBERED,
  367. .procname = "print-fatal-signals",
  368. .data = &print_fatal_signals,
  369. .maxlen = sizeof(int),
  370. .mode = 0644,
  371. .proc_handler = &proc_dointvec,
  372. },
  373. #ifdef __sparc__
  374. {
  375. .ctl_name = KERN_SPARC_REBOOT,
  376. .procname = "reboot-cmd",
  377. .data = reboot_command,
  378. .maxlen = 256,
  379. .mode = 0644,
  380. .proc_handler = &proc_dostring,
  381. .strategy = &sysctl_string,
  382. },
  383. {
  384. .ctl_name = KERN_SPARC_STOP_A,
  385. .procname = "stop-a",
  386. .data = &stop_a_enabled,
  387. .maxlen = sizeof (int),
  388. .mode = 0644,
  389. .proc_handler = &proc_dointvec,
  390. },
  391. {
  392. .ctl_name = KERN_SPARC_SCONS_PWROFF,
  393. .procname = "scons-poweroff",
  394. .data = &scons_pwroff,
  395. .maxlen = sizeof (int),
  396. .mode = 0644,
  397. .proc_handler = &proc_dointvec,
  398. },
  399. #endif
  400. #ifdef __hppa__
  401. {
  402. .ctl_name = KERN_HPPA_PWRSW,
  403. .procname = "soft-power",
  404. .data = &pwrsw_enabled,
  405. .maxlen = sizeof (int),
  406. .mode = 0644,
  407. .proc_handler = &proc_dointvec,
  408. },
  409. {
  410. .ctl_name = KERN_HPPA_UNALIGNED,
  411. .procname = "unaligned-trap",
  412. .data = &unaligned_enabled,
  413. .maxlen = sizeof (int),
  414. .mode = 0644,
  415. .proc_handler = &proc_dointvec,
  416. },
  417. #endif
  418. {
  419. .ctl_name = KERN_CTLALTDEL,
  420. .procname = "ctrl-alt-del",
  421. .data = &C_A_D,
  422. .maxlen = sizeof(int),
  423. .mode = 0644,
  424. .proc_handler = &proc_dointvec,
  425. },
  426. {
  427. .ctl_name = KERN_PRINTK,
  428. .procname = "printk",
  429. .data = &console_loglevel,
  430. .maxlen = 4*sizeof(int),
  431. .mode = 0644,
  432. .proc_handler = &proc_dointvec,
  433. },
  434. #ifdef CONFIG_KMOD
  435. {
  436. .ctl_name = KERN_MODPROBE,
  437. .procname = "modprobe",
  438. .data = &modprobe_path,
  439. .maxlen = KMOD_PATH_LEN,
  440. .mode = 0644,
  441. .proc_handler = &proc_dostring,
  442. .strategy = &sysctl_string,
  443. },
  444. #endif
  445. #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
  446. {
  447. .ctl_name = KERN_HOTPLUG,
  448. .procname = "hotplug",
  449. .data = &uevent_helper,
  450. .maxlen = UEVENT_HELPER_PATH_LEN,
  451. .mode = 0644,
  452. .proc_handler = &proc_dostring,
  453. .strategy = &sysctl_string,
  454. },
  455. #endif
  456. #ifdef CONFIG_CHR_DEV_SG
  457. {
  458. .ctl_name = KERN_SG_BIG_BUFF,
  459. .procname = "sg-big-buff",
  460. .data = &sg_big_buff,
  461. .maxlen = sizeof (int),
  462. .mode = 0444,
  463. .proc_handler = &proc_dointvec,
  464. },
  465. #endif
  466. #ifdef CONFIG_BSD_PROCESS_ACCT
  467. {
  468. .ctl_name = KERN_ACCT,
  469. .procname = "acct",
  470. .data = &acct_parm,
  471. .maxlen = 3*sizeof(int),
  472. .mode = 0644,
  473. .proc_handler = &proc_dointvec,
  474. },
  475. #endif
  476. #ifdef CONFIG_MAGIC_SYSRQ
  477. {
  478. .ctl_name = KERN_SYSRQ,
  479. .procname = "sysrq",
  480. .data = &__sysrq_enabled,
  481. .maxlen = sizeof (int),
  482. .mode = 0644,
  483. .proc_handler = &proc_dointvec,
  484. },
  485. #endif
  486. #ifdef CONFIG_PROC_SYSCTL
  487. {
  488. .ctl_name = KERN_CADPID,
  489. .procname = "cad_pid",
  490. .data = NULL,
  491. .maxlen = sizeof (int),
  492. .mode = 0600,
  493. .proc_handler = &proc_do_cad_pid,
  494. },
  495. #endif
  496. {
  497. .ctl_name = KERN_MAX_THREADS,
  498. .procname = "threads-max",
  499. .data = &max_threads,
  500. .maxlen = sizeof(int),
  501. .mode = 0644,
  502. .proc_handler = &proc_dointvec,
  503. },
  504. {
  505. .ctl_name = KERN_RANDOM,
  506. .procname = "random",
  507. .mode = 0555,
  508. .child = random_table,
  509. },
  510. #ifdef CONFIG_UNIX98_PTYS
  511. {
  512. .ctl_name = KERN_PTY,
  513. .procname = "pty",
  514. .mode = 0555,
  515. .child = pty_table,
  516. },
  517. #endif
  518. {
  519. .ctl_name = KERN_OVERFLOWUID,
  520. .procname = "overflowuid",
  521. .data = &overflowuid,
  522. .maxlen = sizeof(int),
  523. .mode = 0644,
  524. .proc_handler = &proc_dointvec_minmax,
  525. .strategy = &sysctl_intvec,
  526. .extra1 = &minolduid,
  527. .extra2 = &maxolduid,
  528. },
  529. {
  530. .ctl_name = KERN_OVERFLOWGID,
  531. .procname = "overflowgid",
  532. .data = &overflowgid,
  533. .maxlen = sizeof(int),
  534. .mode = 0644,
  535. .proc_handler = &proc_dointvec_minmax,
  536. .strategy = &sysctl_intvec,
  537. .extra1 = &minolduid,
  538. .extra2 = &maxolduid,
  539. },
  540. #ifdef CONFIG_S390
  541. #ifdef CONFIG_MATHEMU
  542. {
  543. .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
  544. .procname = "ieee_emulation_warnings",
  545. .data = &sysctl_ieee_emulation_warnings,
  546. .maxlen = sizeof(int),
  547. .mode = 0644,
  548. .proc_handler = &proc_dointvec,
  549. },
  550. #endif
  551. #ifdef CONFIG_NO_IDLE_HZ
  552. {
  553. .ctl_name = KERN_HZ_TIMER,
  554. .procname = "hz_timer",
  555. .data = &sysctl_hz_timer,
  556. .maxlen = sizeof(int),
  557. .mode = 0644,
  558. .proc_handler = &proc_dointvec,
  559. },
  560. #endif
  561. {
  562. .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
  563. .procname = "userprocess_debug",
  564. .data = &sysctl_userprocess_debug,
  565. .maxlen = sizeof(int),
  566. .mode = 0644,
  567. .proc_handler = &proc_dointvec,
  568. },
  569. #endif
  570. {
  571. .ctl_name = KERN_PIDMAX,
  572. .procname = "pid_max",
  573. .data = &pid_max,
  574. .maxlen = sizeof (int),
  575. .mode = 0644,
  576. .proc_handler = &proc_dointvec_minmax,
  577. .strategy = sysctl_intvec,
  578. .extra1 = &pid_max_min,
  579. .extra2 = &pid_max_max,
  580. },
  581. {
  582. .ctl_name = KERN_PANIC_ON_OOPS,
  583. .procname = "panic_on_oops",
  584. .data = &panic_on_oops,
  585. .maxlen = sizeof(int),
  586. .mode = 0644,
  587. .proc_handler = &proc_dointvec,
  588. },
  589. {
  590. .ctl_name = KERN_PRINTK_RATELIMIT,
  591. .procname = "printk_ratelimit",
  592. .data = &printk_ratelimit_jiffies,
  593. .maxlen = sizeof(int),
  594. .mode = 0644,
  595. .proc_handler = &proc_dointvec_jiffies,
  596. .strategy = &sysctl_jiffies,
  597. },
  598. {
  599. .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
  600. .procname = "printk_ratelimit_burst",
  601. .data = &printk_ratelimit_burst,
  602. .maxlen = sizeof(int),
  603. .mode = 0644,
  604. .proc_handler = &proc_dointvec,
  605. },
  606. {
  607. .ctl_name = KERN_NGROUPS_MAX,
  608. .procname = "ngroups_max",
  609. .data = &ngroups_max,
  610. .maxlen = sizeof (int),
  611. .mode = 0444,
  612. .proc_handler = &proc_dointvec,
  613. },
  614. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
  615. {
  616. .ctl_name = KERN_UNKNOWN_NMI_PANIC,
  617. .procname = "unknown_nmi_panic",
  618. .data = &unknown_nmi_panic,
  619. .maxlen = sizeof (int),
  620. .mode = 0644,
  621. .proc_handler = &proc_dointvec,
  622. },
  623. {
  624. .ctl_name = KERN_NMI_WATCHDOG,
  625. .procname = "nmi_watchdog",
  626. .data = &nmi_watchdog_enabled,
  627. .maxlen = sizeof (int),
  628. .mode = 0644,
  629. .proc_handler = &proc_nmi_enabled,
  630. },
  631. #endif
  632. #if defined(CONFIG_X86)
  633. {
  634. .ctl_name = KERN_PANIC_ON_NMI,
  635. .procname = "panic_on_unrecovered_nmi",
  636. .data = &panic_on_unrecovered_nmi,
  637. .maxlen = sizeof(int),
  638. .mode = 0644,
  639. .proc_handler = &proc_dointvec,
  640. },
  641. {
  642. .ctl_name = KERN_BOOTLOADER_TYPE,
  643. .procname = "bootloader_type",
  644. .data = &bootloader_type,
  645. .maxlen = sizeof (int),
  646. .mode = 0444,
  647. .proc_handler = &proc_dointvec,
  648. },
  649. {
  650. .ctl_name = CTL_UNNUMBERED,
  651. .procname = "kstack_depth_to_print",
  652. .data = &kstack_depth_to_print,
  653. .maxlen = sizeof(int),
  654. .mode = 0644,
  655. .proc_handler = &proc_dointvec,
  656. },
  657. #endif
  658. #if defined(CONFIG_MMU)
  659. {
  660. .ctl_name = KERN_RANDOMIZE,
  661. .procname = "randomize_va_space",
  662. .data = &randomize_va_space,
  663. .maxlen = sizeof(int),
  664. .mode = 0644,
  665. .proc_handler = &proc_dointvec,
  666. },
  667. #endif
  668. #if defined(CONFIG_S390) && defined(CONFIG_SMP)
  669. {
  670. .ctl_name = KERN_SPIN_RETRY,
  671. .procname = "spin_retry",
  672. .data = &spin_retry,
  673. .maxlen = sizeof (int),
  674. .mode = 0644,
  675. .proc_handler = &proc_dointvec,
  676. },
  677. #endif
  678. #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
  679. {
  680. .ctl_name = KERN_ACPI_VIDEO_FLAGS,
  681. .procname = "acpi_video_flags",
  682. .data = &acpi_realmode_flags,
  683. .maxlen = sizeof (unsigned long),
  684. .mode = 0644,
  685. .proc_handler = &proc_doulongvec_minmax,
  686. },
  687. #endif
  688. #ifdef CONFIG_IA64
  689. {
  690. .ctl_name = KERN_IA64_UNALIGNED,
  691. .procname = "ignore-unaligned-usertrap",
  692. .data = &no_unaligned_warning,
  693. .maxlen = sizeof (int),
  694. .mode = 0644,
  695. .proc_handler = &proc_dointvec,
  696. },
  697. #endif
  698. #ifdef CONFIG_DETECT_SOFTLOCKUP
  699. {
  700. .ctl_name = CTL_UNNUMBERED,
  701. .procname = "softlockup_thresh",
  702. .data = &softlockup_thresh,
  703. .maxlen = sizeof(int),
  704. .mode = 0644,
  705. .proc_handler = &proc_dointvec_minmax,
  706. .strategy = &sysctl_intvec,
  707. .extra1 = &one,
  708. .extra2 = &sixty,
  709. },
  710. #endif
  711. #ifdef CONFIG_COMPAT
  712. {
  713. .ctl_name = KERN_COMPAT_LOG,
  714. .procname = "compat-log",
  715. .data = &compat_log,
  716. .maxlen = sizeof (int),
  717. .mode = 0644,
  718. .proc_handler = &proc_dointvec,
  719. },
  720. #endif
  721. #ifdef CONFIG_RT_MUTEXES
  722. {
  723. .ctl_name = KERN_MAX_LOCK_DEPTH,
  724. .procname = "max_lock_depth",
  725. .data = &max_lock_depth,
  726. .maxlen = sizeof(int),
  727. .mode = 0644,
  728. .proc_handler = &proc_dointvec,
  729. },
  730. #endif
  731. #ifdef CONFIG_PROC_FS
  732. {
  733. .ctl_name = CTL_UNNUMBERED,
  734. .procname = "maps_protect",
  735. .data = &maps_protect,
  736. .maxlen = sizeof(int),
  737. .mode = 0644,
  738. .proc_handler = &proc_dointvec,
  739. },
  740. #endif
  741. {
  742. .ctl_name = CTL_UNNUMBERED,
  743. .procname = "poweroff_cmd",
  744. .data = &poweroff_cmd,
  745. .maxlen = POWEROFF_CMD_PATH_LEN,
  746. .mode = 0644,
  747. .proc_handler = &proc_dostring,
  748. .strategy = &sysctl_string,
  749. },
  750. /*
  751. * NOTE: do not add new entries to this table unless you have read
  752. * Documentation/sysctl/ctl_unnumbered.txt
  753. */
  754. { .ctl_name = 0 }
  755. };
  756. static ctl_table vm_table[] = {
  757. {
  758. .ctl_name = VM_OVERCOMMIT_MEMORY,
  759. .procname = "overcommit_memory",
  760. .data = &sysctl_overcommit_memory,
  761. .maxlen = sizeof(sysctl_overcommit_memory),
  762. .mode = 0644,
  763. .proc_handler = &proc_dointvec,
  764. },
  765. {
  766. .ctl_name = VM_PANIC_ON_OOM,
  767. .procname = "panic_on_oom",
  768. .data = &sysctl_panic_on_oom,
  769. .maxlen = sizeof(sysctl_panic_on_oom),
  770. .mode = 0644,
  771. .proc_handler = &proc_dointvec,
  772. },
  773. {
  774. .ctl_name = CTL_UNNUMBERED,
  775. .procname = "oom_kill_allocating_task",
  776. .data = &sysctl_oom_kill_allocating_task,
  777. .maxlen = sizeof(sysctl_oom_kill_allocating_task),
  778. .mode = 0644,
  779. .proc_handler = &proc_dointvec,
  780. },
  781. {
  782. .ctl_name = VM_OVERCOMMIT_RATIO,
  783. .procname = "overcommit_ratio",
  784. .data = &sysctl_overcommit_ratio,
  785. .maxlen = sizeof(sysctl_overcommit_ratio),
  786. .mode = 0644,
  787. .proc_handler = &proc_dointvec,
  788. },
  789. {
  790. .ctl_name = VM_PAGE_CLUSTER,
  791. .procname = "page-cluster",
  792. .data = &page_cluster,
  793. .maxlen = sizeof(int),
  794. .mode = 0644,
  795. .proc_handler = &proc_dointvec,
  796. },
  797. {
  798. .ctl_name = VM_DIRTY_BACKGROUND,
  799. .procname = "dirty_background_ratio",
  800. .data = &dirty_background_ratio,
  801. .maxlen = sizeof(dirty_background_ratio),
  802. .mode = 0644,
  803. .proc_handler = &proc_dointvec_minmax,
  804. .strategy = &sysctl_intvec,
  805. .extra1 = &zero,
  806. .extra2 = &one_hundred,
  807. },
  808. {
  809. .ctl_name = VM_DIRTY_RATIO,
  810. .procname = "dirty_ratio",
  811. .data = &vm_dirty_ratio,
  812. .maxlen = sizeof(vm_dirty_ratio),
  813. .mode = 0644,
  814. .proc_handler = &dirty_ratio_handler,
  815. .strategy = &sysctl_intvec,
  816. .extra1 = &zero,
  817. .extra2 = &one_hundred,
  818. },
  819. {
  820. .ctl_name = VM_DIRTY_WB_CS,
  821. .procname = "dirty_writeback_centisecs",
  822. .data = &dirty_writeback_interval,
  823. .maxlen = sizeof(dirty_writeback_interval),
  824. .mode = 0644,
  825. .proc_handler = &dirty_writeback_centisecs_handler,
  826. },
  827. {
  828. .ctl_name = VM_DIRTY_EXPIRE_CS,
  829. .procname = "dirty_expire_centisecs",
  830. .data = &dirty_expire_interval,
  831. .maxlen = sizeof(dirty_expire_interval),
  832. .mode = 0644,
  833. .proc_handler = &proc_dointvec_userhz_jiffies,
  834. },
  835. {
  836. .ctl_name = VM_NR_PDFLUSH_THREADS,
  837. .procname = "nr_pdflush_threads",
  838. .data = &nr_pdflush_threads,
  839. .maxlen = sizeof nr_pdflush_threads,
  840. .mode = 0444 /* read-only*/,
  841. .proc_handler = &proc_dointvec,
  842. },
  843. {
  844. .ctl_name = VM_SWAPPINESS,
  845. .procname = "swappiness",
  846. .data = &vm_swappiness,
  847. .maxlen = sizeof(vm_swappiness),
  848. .mode = 0644,
  849. .proc_handler = &proc_dointvec_minmax,
  850. .strategy = &sysctl_intvec,
  851. .extra1 = &zero,
  852. .extra2 = &one_hundred,
  853. },
  854. #ifdef CONFIG_HUGETLB_PAGE
  855. {
  856. .ctl_name = VM_HUGETLB_PAGES,
  857. .procname = "nr_hugepages",
  858. .data = &max_huge_pages,
  859. .maxlen = sizeof(unsigned long),
  860. .mode = 0644,
  861. .proc_handler = &hugetlb_sysctl_handler,
  862. .extra1 = (void *)&hugetlb_zero,
  863. .extra2 = (void *)&hugetlb_infinity,
  864. },
  865. {
  866. .ctl_name = VM_HUGETLB_GROUP,
  867. .procname = "hugetlb_shm_group",
  868. .data = &sysctl_hugetlb_shm_group,
  869. .maxlen = sizeof(gid_t),
  870. .mode = 0644,
  871. .proc_handler = &proc_dointvec,
  872. },
  873. {
  874. .ctl_name = CTL_UNNUMBERED,
  875. .procname = "hugepages_treat_as_movable",
  876. .data = &hugepages_treat_as_movable,
  877. .maxlen = sizeof(int),
  878. .mode = 0644,
  879. .proc_handler = &hugetlb_treat_movable_handler,
  880. },
  881. {
  882. .ctl_name = CTL_UNNUMBERED,
  883. .procname = "hugetlb_dynamic_pool",
  884. .data = &hugetlb_dynamic_pool,
  885. .maxlen = sizeof(hugetlb_dynamic_pool),
  886. .mode = 0644,
  887. .proc_handler = &proc_dointvec,
  888. },
  889. #endif
  890. {
  891. .ctl_name = VM_LOWMEM_RESERVE_RATIO,
  892. .procname = "lowmem_reserve_ratio",
  893. .data = &sysctl_lowmem_reserve_ratio,
  894. .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
  895. .mode = 0644,
  896. .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
  897. .strategy = &sysctl_intvec,
  898. },
  899. {
  900. .ctl_name = VM_DROP_PAGECACHE,
  901. .procname = "drop_caches",
  902. .data = &sysctl_drop_caches,
  903. .maxlen = sizeof(int),
  904. .mode = 0644,
  905. .proc_handler = drop_caches_sysctl_handler,
  906. .strategy = &sysctl_intvec,
  907. },
  908. {
  909. .ctl_name = VM_MIN_FREE_KBYTES,
  910. .procname = "min_free_kbytes",
  911. .data = &min_free_kbytes,
  912. .maxlen = sizeof(min_free_kbytes),
  913. .mode = 0644,
  914. .proc_handler = &min_free_kbytes_sysctl_handler,
  915. .strategy = &sysctl_intvec,
  916. .extra1 = &zero,
  917. },
  918. {
  919. .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
  920. .procname = "percpu_pagelist_fraction",
  921. .data = &percpu_pagelist_fraction,
  922. .maxlen = sizeof(percpu_pagelist_fraction),
  923. .mode = 0644,
  924. .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
  925. .strategy = &sysctl_intvec,
  926. .extra1 = &min_percpu_pagelist_fract,
  927. },
  928. #ifdef CONFIG_MMU
  929. {
  930. .ctl_name = VM_MAX_MAP_COUNT,
  931. .procname = "max_map_count",
  932. .data = &sysctl_max_map_count,
  933. .maxlen = sizeof(sysctl_max_map_count),
  934. .mode = 0644,
  935. .proc_handler = &proc_dointvec
  936. },
  937. #endif
  938. {
  939. .ctl_name = VM_LAPTOP_MODE,
  940. .procname = "laptop_mode",
  941. .data = &laptop_mode,
  942. .maxlen = sizeof(laptop_mode),
  943. .mode = 0644,
  944. .proc_handler = &proc_dointvec_jiffies,
  945. .strategy = &sysctl_jiffies,
  946. },
  947. {
  948. .ctl_name = VM_BLOCK_DUMP,
  949. .procname = "block_dump",
  950. .data = &block_dump,
  951. .maxlen = sizeof(block_dump),
  952. .mode = 0644,
  953. .proc_handler = &proc_dointvec,
  954. .strategy = &sysctl_intvec,
  955. .extra1 = &zero,
  956. },
  957. {
  958. .ctl_name = VM_VFS_CACHE_PRESSURE,
  959. .procname = "vfs_cache_pressure",
  960. .data = &sysctl_vfs_cache_pressure,
  961. .maxlen = sizeof(sysctl_vfs_cache_pressure),
  962. .mode = 0644,
  963. .proc_handler = &proc_dointvec,
  964. .strategy = &sysctl_intvec,
  965. .extra1 = &zero,
  966. },
  967. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  968. {
  969. .ctl_name = VM_LEGACY_VA_LAYOUT,
  970. .procname = "legacy_va_layout",
  971. .data = &sysctl_legacy_va_layout,
  972. .maxlen = sizeof(sysctl_legacy_va_layout),
  973. .mode = 0644,
  974. .proc_handler = &proc_dointvec,
  975. .strategy = &sysctl_intvec,
  976. .extra1 = &zero,
  977. },
  978. #endif
  979. #ifdef CONFIG_NUMA
  980. {
  981. .ctl_name = VM_ZONE_RECLAIM_MODE,
  982. .procname = "zone_reclaim_mode",
  983. .data = &zone_reclaim_mode,
  984. .maxlen = sizeof(zone_reclaim_mode),
  985. .mode = 0644,
  986. .proc_handler = &proc_dointvec,
  987. .strategy = &sysctl_intvec,
  988. .extra1 = &zero,
  989. },
  990. {
  991. .ctl_name = VM_MIN_UNMAPPED,
  992. .procname = "min_unmapped_ratio",
  993. .data = &sysctl_min_unmapped_ratio,
  994. .maxlen = sizeof(sysctl_min_unmapped_ratio),
  995. .mode = 0644,
  996. .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
  997. .strategy = &sysctl_intvec,
  998. .extra1 = &zero,
  999. .extra2 = &one_hundred,
  1000. },
  1001. {
  1002. .ctl_name = VM_MIN_SLAB,
  1003. .procname = "min_slab_ratio",
  1004. .data = &sysctl_min_slab_ratio,
  1005. .maxlen = sizeof(sysctl_min_slab_ratio),
  1006. .mode = 0644,
  1007. .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
  1008. .strategy = &sysctl_intvec,
  1009. .extra1 = &zero,
  1010. .extra2 = &one_hundred,
  1011. },
  1012. #endif
  1013. #ifdef CONFIG_SMP
  1014. {
  1015. .ctl_name = CTL_UNNUMBERED,
  1016. .procname = "stat_interval",
  1017. .data = &sysctl_stat_interval,
  1018. .maxlen = sizeof(sysctl_stat_interval),
  1019. .mode = 0644,
  1020. .proc_handler = &proc_dointvec_jiffies,
  1021. .strategy = &sysctl_jiffies,
  1022. },
  1023. #endif
  1024. #ifdef CONFIG_SECURITY
  1025. {
  1026. .ctl_name = CTL_UNNUMBERED,
  1027. .procname = "mmap_min_addr",
  1028. .data = &mmap_min_addr,
  1029. .maxlen = sizeof(unsigned long),
  1030. .mode = 0644,
  1031. .proc_handler = &proc_doulongvec_minmax,
  1032. },
  1033. #endif
  1034. #ifdef CONFIG_NUMA
  1035. {
  1036. .ctl_name = CTL_UNNUMBERED,
  1037. .procname = "numa_zonelist_order",
  1038. .data = &numa_zonelist_order,
  1039. .maxlen = NUMA_ZONELIST_ORDER_LEN,
  1040. .mode = 0644,
  1041. .proc_handler = &numa_zonelist_order_handler,
  1042. .strategy = &sysctl_string,
  1043. },
  1044. #endif
  1045. #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
  1046. (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
  1047. {
  1048. .ctl_name = VM_VDSO_ENABLED,
  1049. .procname = "vdso_enabled",
  1050. .data = &vdso_enabled,
  1051. .maxlen = sizeof(vdso_enabled),
  1052. .mode = 0644,
  1053. .proc_handler = &proc_dointvec,
  1054. .strategy = &sysctl_intvec,
  1055. .extra1 = &zero,
  1056. },
  1057. #endif
  1058. /*
  1059. * NOTE: do not add new entries to this table unless you have read
  1060. * Documentation/sysctl/ctl_unnumbered.txt
  1061. */
  1062. { .ctl_name = 0 }
  1063. };
  1064. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1065. static ctl_table binfmt_misc_table[] = {
  1066. { .ctl_name = 0 }
  1067. };
  1068. #endif
  1069. static ctl_table fs_table[] = {
  1070. {
  1071. .ctl_name = FS_NRINODE,
  1072. .procname = "inode-nr",
  1073. .data = &inodes_stat,
  1074. .maxlen = 2*sizeof(int),
  1075. .mode = 0444,
  1076. .proc_handler = &proc_dointvec,
  1077. },
  1078. {
  1079. .ctl_name = FS_STATINODE,
  1080. .procname = "inode-state",
  1081. .data = &inodes_stat,
  1082. .maxlen = 7*sizeof(int),
  1083. .mode = 0444,
  1084. .proc_handler = &proc_dointvec,
  1085. },
  1086. {
  1087. .ctl_name = FS_NRFILE,
  1088. .procname = "file-nr",
  1089. .data = &files_stat,
  1090. .maxlen = 3*sizeof(int),
  1091. .mode = 0444,
  1092. .proc_handler = &proc_nr_files,
  1093. },
  1094. {
  1095. .ctl_name = FS_MAXFILE,
  1096. .procname = "file-max",
  1097. .data = &files_stat.max_files,
  1098. .maxlen = sizeof(int),
  1099. .mode = 0644,
  1100. .proc_handler = &proc_dointvec,
  1101. },
  1102. {
  1103. .ctl_name = FS_DENTRY,
  1104. .procname = "dentry-state",
  1105. .data = &dentry_stat,
  1106. .maxlen = 6*sizeof(int),
  1107. .mode = 0444,
  1108. .proc_handler = &proc_dointvec,
  1109. },
  1110. {
  1111. .ctl_name = FS_OVERFLOWUID,
  1112. .procname = "overflowuid",
  1113. .data = &fs_overflowuid,
  1114. .maxlen = sizeof(int),
  1115. .mode = 0644,
  1116. .proc_handler = &proc_dointvec_minmax,
  1117. .strategy = &sysctl_intvec,
  1118. .extra1 = &minolduid,
  1119. .extra2 = &maxolduid,
  1120. },
  1121. {
  1122. .ctl_name = FS_OVERFLOWGID,
  1123. .procname = "overflowgid",
  1124. .data = &fs_overflowgid,
  1125. .maxlen = sizeof(int),
  1126. .mode = 0644,
  1127. .proc_handler = &proc_dointvec_minmax,
  1128. .strategy = &sysctl_intvec,
  1129. .extra1 = &minolduid,
  1130. .extra2 = &maxolduid,
  1131. },
  1132. {
  1133. .ctl_name = FS_LEASES,
  1134. .procname = "leases-enable",
  1135. .data = &leases_enable,
  1136. .maxlen = sizeof(int),
  1137. .mode = 0644,
  1138. .proc_handler = &proc_dointvec,
  1139. },
  1140. #ifdef CONFIG_DNOTIFY
  1141. {
  1142. .ctl_name = FS_DIR_NOTIFY,
  1143. .procname = "dir-notify-enable",
  1144. .data = &dir_notify_enable,
  1145. .maxlen = sizeof(int),
  1146. .mode = 0644,
  1147. .proc_handler = &proc_dointvec,
  1148. },
  1149. #endif
  1150. #ifdef CONFIG_MMU
  1151. {
  1152. .ctl_name = FS_LEASE_TIME,
  1153. .procname = "lease-break-time",
  1154. .data = &lease_break_time,
  1155. .maxlen = sizeof(int),
  1156. .mode = 0644,
  1157. .proc_handler = &proc_dointvec_minmax,
  1158. .strategy = &sysctl_intvec,
  1159. .extra1 = &zero,
  1160. .extra2 = &two,
  1161. },
  1162. {
  1163. .ctl_name = FS_AIO_NR,
  1164. .procname = "aio-nr",
  1165. .data = &aio_nr,
  1166. .maxlen = sizeof(aio_nr),
  1167. .mode = 0444,
  1168. .proc_handler = &proc_doulongvec_minmax,
  1169. },
  1170. {
  1171. .ctl_name = FS_AIO_MAX_NR,
  1172. .procname = "aio-max-nr",
  1173. .data = &aio_max_nr,
  1174. .maxlen = sizeof(aio_max_nr),
  1175. .mode = 0644,
  1176. .proc_handler = &proc_doulongvec_minmax,
  1177. },
  1178. #ifdef CONFIG_INOTIFY_USER
  1179. {
  1180. .ctl_name = FS_INOTIFY,
  1181. .procname = "inotify",
  1182. .mode = 0555,
  1183. .child = inotify_table,
  1184. },
  1185. #endif
  1186. #endif
  1187. {
  1188. .ctl_name = KERN_SETUID_DUMPABLE,
  1189. .procname = "suid_dumpable",
  1190. .data = &suid_dumpable,
  1191. .maxlen = sizeof(int),
  1192. .mode = 0644,
  1193. .proc_handler = &proc_dointvec,
  1194. },
  1195. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1196. {
  1197. .ctl_name = CTL_UNNUMBERED,
  1198. .procname = "binfmt_misc",
  1199. .mode = 0555,
  1200. .child = binfmt_misc_table,
  1201. },
  1202. #endif
  1203. /*
  1204. * NOTE: do not add new entries to this table unless you have read
  1205. * Documentation/sysctl/ctl_unnumbered.txt
  1206. */
  1207. { .ctl_name = 0 }
  1208. };
  1209. static ctl_table debug_table[] = {
  1210. #if defined(CONFIG_X86) || defined(CONFIG_PPC)
  1211. {
  1212. .ctl_name = CTL_UNNUMBERED,
  1213. .procname = "exception-trace",
  1214. .data = &show_unhandled_signals,
  1215. .maxlen = sizeof(int),
  1216. .mode = 0644,
  1217. .proc_handler = proc_dointvec
  1218. },
  1219. #endif
  1220. { .ctl_name = 0 }
  1221. };
  1222. static ctl_table dev_table[] = {
  1223. { .ctl_name = 0 }
  1224. };
  1225. static DEFINE_SPINLOCK(sysctl_lock);
  1226. /* called under sysctl_lock */
  1227. static int use_table(struct ctl_table_header *p)
  1228. {
  1229. if (unlikely(p->unregistering))
  1230. return 0;
  1231. p->used++;
  1232. return 1;
  1233. }
  1234. /* called under sysctl_lock */
  1235. static void unuse_table(struct ctl_table_header *p)
  1236. {
  1237. if (!--p->used)
  1238. if (unlikely(p->unregistering))
  1239. complete(p->unregistering);
  1240. }
  1241. /* called under sysctl_lock, will reacquire if has to wait */
  1242. static void start_unregistering(struct ctl_table_header *p)
  1243. {
  1244. /*
  1245. * if p->used is 0, nobody will ever touch that entry again;
  1246. * we'll eliminate all paths to it before dropping sysctl_lock
  1247. */
  1248. if (unlikely(p->used)) {
  1249. struct completion wait;
  1250. init_completion(&wait);
  1251. p->unregistering = &wait;
  1252. spin_unlock(&sysctl_lock);
  1253. wait_for_completion(&wait);
  1254. spin_lock(&sysctl_lock);
  1255. }
  1256. /*
  1257. * do not remove from the list until nobody holds it; walking the
  1258. * list in do_sysctl() relies on that.
  1259. */
  1260. list_del_init(&p->ctl_entry);
  1261. }
  1262. void sysctl_head_finish(struct ctl_table_header *head)
  1263. {
  1264. if (!head)
  1265. return;
  1266. spin_lock(&sysctl_lock);
  1267. unuse_table(head);
  1268. spin_unlock(&sysctl_lock);
  1269. }
  1270. struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
  1271. {
  1272. struct ctl_table_header *head;
  1273. struct list_head *tmp;
  1274. spin_lock(&sysctl_lock);
  1275. if (prev) {
  1276. tmp = &prev->ctl_entry;
  1277. unuse_table(prev);
  1278. goto next;
  1279. }
  1280. tmp = &root_table_header.ctl_entry;
  1281. for (;;) {
  1282. head = list_entry(tmp, struct ctl_table_header, ctl_entry);
  1283. if (!use_table(head))
  1284. goto next;
  1285. spin_unlock(&sysctl_lock);
  1286. return head;
  1287. next:
  1288. tmp = tmp->next;
  1289. if (tmp == &root_table_header.ctl_entry)
  1290. break;
  1291. }
  1292. spin_unlock(&sysctl_lock);
  1293. return NULL;
  1294. }
  1295. #ifdef CONFIG_SYSCTL_SYSCALL
  1296. int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
  1297. void __user *newval, size_t newlen)
  1298. {
  1299. struct ctl_table_header *head;
  1300. int error = -ENOTDIR;
  1301. if (nlen <= 0 || nlen >= CTL_MAXNAME)
  1302. return -ENOTDIR;
  1303. if (oldval) {
  1304. int old_len;
  1305. if (!oldlenp || get_user(old_len, oldlenp))
  1306. return -EFAULT;
  1307. }
  1308. for (head = sysctl_head_next(NULL); head;
  1309. head = sysctl_head_next(head)) {
  1310. error = parse_table(name, nlen, oldval, oldlenp,
  1311. newval, newlen, head->ctl_table);
  1312. if (error != -ENOTDIR) {
  1313. sysctl_head_finish(head);
  1314. break;
  1315. }
  1316. }
  1317. return error;
  1318. }
  1319. asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
  1320. {
  1321. struct __sysctl_args tmp;
  1322. int error;
  1323. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1324. return -EFAULT;
  1325. lock_kernel();
  1326. error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
  1327. tmp.newval, tmp.newlen);
  1328. unlock_kernel();
  1329. return error;
  1330. }
  1331. #endif /* CONFIG_SYSCTL_SYSCALL */
  1332. /*
  1333. * sysctl_perm does NOT grant the superuser all rights automatically, because
  1334. * some sysctl variables are readonly even to root.
  1335. */
  1336. static int test_perm(int mode, int op)
  1337. {
  1338. if (!current->euid)
  1339. mode >>= 6;
  1340. else if (in_egroup_p(0))
  1341. mode >>= 3;
  1342. if ((mode & op & 0007) == op)
  1343. return 0;
  1344. return -EACCES;
  1345. }
  1346. int sysctl_perm(ctl_table *table, int op)
  1347. {
  1348. int error;
  1349. error = security_sysctl(table, op);
  1350. if (error)
  1351. return error;
  1352. return test_perm(table->mode, op);
  1353. }
  1354. #ifdef CONFIG_SYSCTL_SYSCALL
  1355. static int parse_table(int __user *name, int nlen,
  1356. void __user *oldval, size_t __user *oldlenp,
  1357. void __user *newval, size_t newlen,
  1358. ctl_table *table)
  1359. {
  1360. int n;
  1361. repeat:
  1362. if (!nlen)
  1363. return -ENOTDIR;
  1364. if (get_user(n, name))
  1365. return -EFAULT;
  1366. for ( ; table->ctl_name || table->procname; table++) {
  1367. if (!table->ctl_name)
  1368. continue;
  1369. if (n == table->ctl_name) {
  1370. int error;
  1371. if (table->child) {
  1372. if (sysctl_perm(table, 001))
  1373. return -EPERM;
  1374. name++;
  1375. nlen--;
  1376. table = table->child;
  1377. goto repeat;
  1378. }
  1379. error = do_sysctl_strategy(table, name, nlen,
  1380. oldval, oldlenp,
  1381. newval, newlen);
  1382. return error;
  1383. }
  1384. }
  1385. return -ENOTDIR;
  1386. }
  1387. /* Perform the actual read/write of a sysctl table entry. */
  1388. int do_sysctl_strategy (ctl_table *table,
  1389. int __user *name, int nlen,
  1390. void __user *oldval, size_t __user *oldlenp,
  1391. void __user *newval, size_t newlen)
  1392. {
  1393. int op = 0, rc;
  1394. size_t len;
  1395. if (oldval)
  1396. op |= 004;
  1397. if (newval)
  1398. op |= 002;
  1399. if (sysctl_perm(table, op))
  1400. return -EPERM;
  1401. if (table->strategy) {
  1402. rc = table->strategy(table, name, nlen, oldval, oldlenp,
  1403. newval, newlen);
  1404. if (rc < 0)
  1405. return rc;
  1406. if (rc > 0)
  1407. return 0;
  1408. }
  1409. /* If there is no strategy routine, or if the strategy returns
  1410. * zero, proceed with automatic r/w */
  1411. if (table->data && table->maxlen) {
  1412. if (oldval && oldlenp) {
  1413. if (get_user(len, oldlenp))
  1414. return -EFAULT;
  1415. if (len) {
  1416. if (len > table->maxlen)
  1417. len = table->maxlen;
  1418. if(copy_to_user(oldval, table->data, len))
  1419. return -EFAULT;
  1420. if(put_user(len, oldlenp))
  1421. return -EFAULT;
  1422. }
  1423. }
  1424. if (newval && newlen) {
  1425. len = newlen;
  1426. if (len > table->maxlen)
  1427. len = table->maxlen;
  1428. if(copy_from_user(table->data, newval, len))
  1429. return -EFAULT;
  1430. }
  1431. }
  1432. return 0;
  1433. }
  1434. #endif /* CONFIG_SYSCTL_SYSCALL */
  1435. static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
  1436. {
  1437. for (; table->ctl_name || table->procname; table++) {
  1438. table->parent = parent;
  1439. if (table->child)
  1440. sysctl_set_parent(table, table->child);
  1441. }
  1442. }
  1443. static __init int sysctl_init(void)
  1444. {
  1445. sysctl_set_parent(NULL, root_table);
  1446. return 0;
  1447. }
  1448. core_initcall(sysctl_init);
  1449. /**
  1450. * register_sysctl_table - register a sysctl hierarchy
  1451. * @table: the top-level table structure
  1452. *
  1453. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1454. * array. An entry with a ctl_name of 0 terminates the table.
  1455. *
  1456. * The members of the &ctl_table structure are used as follows:
  1457. *
  1458. * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
  1459. * must be unique within that level of sysctl
  1460. *
  1461. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1462. * enter a sysctl file
  1463. *
  1464. * data - a pointer to data for use by proc_handler
  1465. *
  1466. * maxlen - the maximum size in bytes of the data
  1467. *
  1468. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1469. *
  1470. * child - a pointer to the child sysctl table if this entry is a directory, or
  1471. * %NULL.
  1472. *
  1473. * proc_handler - the text handler routine (described below)
  1474. *
  1475. * strategy - the strategy routine (described below)
  1476. *
  1477. * de - for internal use by the sysctl routines
  1478. *
  1479. * extra1, extra2 - extra pointers usable by the proc handler routines
  1480. *
  1481. * Leaf nodes in the sysctl tree will be represented by a single file
  1482. * under /proc; non-leaf nodes will be represented by directories.
  1483. *
  1484. * sysctl(2) can automatically manage read and write requests through
  1485. * the sysctl table. The data and maxlen fields of the ctl_table
  1486. * struct enable minimal validation of the values being written to be
  1487. * performed, and the mode field allows minimal authentication.
  1488. *
  1489. * More sophisticated management can be enabled by the provision of a
  1490. * strategy routine with the table entry. This will be called before
  1491. * any automatic read or write of the data is performed.
  1492. *
  1493. * The strategy routine may return
  1494. *
  1495. * < 0 - Error occurred (error is passed to user process)
  1496. *
  1497. * 0 - OK - proceed with automatic read or write.
  1498. *
  1499. * > 0 - OK - read or write has been done by the strategy routine, so
  1500. * return immediately.
  1501. *
  1502. * There must be a proc_handler routine for any terminal nodes
  1503. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1504. * directory handler). Several default handlers are available to
  1505. * cover common cases -
  1506. *
  1507. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1508. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1509. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1510. *
  1511. * It is the handler's job to read the input buffer from user memory
  1512. * and process it. The handler should return 0 on success.
  1513. *
  1514. * This routine returns %NULL on a failure to register, and a pointer
  1515. * to the table header on success.
  1516. */
  1517. struct ctl_table_header *register_sysctl_table(ctl_table * table)
  1518. {
  1519. struct ctl_table_header *tmp;
  1520. tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
  1521. if (!tmp)
  1522. return NULL;
  1523. tmp->ctl_table = table;
  1524. INIT_LIST_HEAD(&tmp->ctl_entry);
  1525. tmp->used = 0;
  1526. tmp->unregistering = NULL;
  1527. sysctl_set_parent(NULL, table);
  1528. spin_lock(&sysctl_lock);
  1529. list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
  1530. spin_unlock(&sysctl_lock);
  1531. return tmp;
  1532. }
  1533. /**
  1534. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1535. * @header: the header returned from register_sysctl_table
  1536. *
  1537. * Unregisters the sysctl table and all children. proc entries may not
  1538. * actually be removed until they are no longer used by anyone.
  1539. */
  1540. void unregister_sysctl_table(struct ctl_table_header * header)
  1541. {
  1542. might_sleep();
  1543. spin_lock(&sysctl_lock);
  1544. start_unregistering(header);
  1545. spin_unlock(&sysctl_lock);
  1546. kfree(header);
  1547. }
  1548. #else /* !CONFIG_SYSCTL */
  1549. struct ctl_table_header *register_sysctl_table(ctl_table * table)
  1550. {
  1551. return NULL;
  1552. }
  1553. void unregister_sysctl_table(struct ctl_table_header * table)
  1554. {
  1555. }
  1556. #endif /* CONFIG_SYSCTL */
  1557. /*
  1558. * /proc/sys support
  1559. */
  1560. #ifdef CONFIG_PROC_SYSCTL
  1561. static int _proc_do_string(void* data, int maxlen, int write,
  1562. struct file *filp, void __user *buffer,
  1563. size_t *lenp, loff_t *ppos)
  1564. {
  1565. size_t len;
  1566. char __user *p;
  1567. char c;
  1568. if (!data || !maxlen || !*lenp) {
  1569. *lenp = 0;
  1570. return 0;
  1571. }
  1572. if (write) {
  1573. len = 0;
  1574. p = buffer;
  1575. while (len < *lenp) {
  1576. if (get_user(c, p++))
  1577. return -EFAULT;
  1578. if (c == 0 || c == '\n')
  1579. break;
  1580. len++;
  1581. }
  1582. if (len >= maxlen)
  1583. len = maxlen-1;
  1584. if(copy_from_user(data, buffer, len))
  1585. return -EFAULT;
  1586. ((char *) data)[len] = 0;
  1587. *ppos += *lenp;
  1588. } else {
  1589. len = strlen(data);
  1590. if (len > maxlen)
  1591. len = maxlen;
  1592. if (*ppos > len) {
  1593. *lenp = 0;
  1594. return 0;
  1595. }
  1596. data += *ppos;
  1597. len -= *ppos;
  1598. if (len > *lenp)
  1599. len = *lenp;
  1600. if (len)
  1601. if(copy_to_user(buffer, data, len))
  1602. return -EFAULT;
  1603. if (len < *lenp) {
  1604. if(put_user('\n', ((char __user *) buffer) + len))
  1605. return -EFAULT;
  1606. len++;
  1607. }
  1608. *lenp = len;
  1609. *ppos += len;
  1610. }
  1611. return 0;
  1612. }
  1613. /**
  1614. * proc_dostring - read a string sysctl
  1615. * @table: the sysctl table
  1616. * @write: %TRUE if this is a write to the sysctl file
  1617. * @filp: the file structure
  1618. * @buffer: the user buffer
  1619. * @lenp: the size of the user buffer
  1620. * @ppos: file position
  1621. *
  1622. * Reads/writes a string from/to the user buffer. If the kernel
  1623. * buffer provided is not large enough to hold the string, the
  1624. * string is truncated. The copied string is %NULL-terminated.
  1625. * If the string is being read by the user process, it is copied
  1626. * and a newline '\n' is added. It is truncated if the buffer is
  1627. * not large enough.
  1628. *
  1629. * Returns 0 on success.
  1630. */
  1631. int proc_dostring(ctl_table *table, int write, struct file *filp,
  1632. void __user *buffer, size_t *lenp, loff_t *ppos)
  1633. {
  1634. return _proc_do_string(table->data, table->maxlen, write, filp,
  1635. buffer, lenp, ppos);
  1636. }
  1637. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  1638. int *valp,
  1639. int write, void *data)
  1640. {
  1641. if (write) {
  1642. *valp = *negp ? -*lvalp : *lvalp;
  1643. } else {
  1644. int val = *valp;
  1645. if (val < 0) {
  1646. *negp = -1;
  1647. *lvalp = (unsigned long)-val;
  1648. } else {
  1649. *negp = 0;
  1650. *lvalp = (unsigned long)val;
  1651. }
  1652. }
  1653. return 0;
  1654. }
  1655. static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
  1656. int write, struct file *filp, void __user *buffer,
  1657. size_t *lenp, loff_t *ppos,
  1658. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1659. int write, void *data),
  1660. void *data)
  1661. {
  1662. #define TMPBUFLEN 21
  1663. int *i, vleft, first=1, neg, val;
  1664. unsigned long lval;
  1665. size_t left, len;
  1666. char buf[TMPBUFLEN], *p;
  1667. char __user *s = buffer;
  1668. if (!tbl_data || !table->maxlen || !*lenp ||
  1669. (*ppos && !write)) {
  1670. *lenp = 0;
  1671. return 0;
  1672. }
  1673. i = (int *) tbl_data;
  1674. vleft = table->maxlen / sizeof(*i);
  1675. left = *lenp;
  1676. if (!conv)
  1677. conv = do_proc_dointvec_conv;
  1678. for (; left && vleft--; i++, first=0) {
  1679. if (write) {
  1680. while (left) {
  1681. char c;
  1682. if (get_user(c, s))
  1683. return -EFAULT;
  1684. if (!isspace(c))
  1685. break;
  1686. left--;
  1687. s++;
  1688. }
  1689. if (!left)
  1690. break;
  1691. neg = 0;
  1692. len = left;
  1693. if (len > sizeof(buf) - 1)
  1694. len = sizeof(buf) - 1;
  1695. if (copy_from_user(buf, s, len))
  1696. return -EFAULT;
  1697. buf[len] = 0;
  1698. p = buf;
  1699. if (*p == '-' && left > 1) {
  1700. neg = 1;
  1701. p++;
  1702. }
  1703. if (*p < '0' || *p > '9')
  1704. break;
  1705. lval = simple_strtoul(p, &p, 0);
  1706. len = p-buf;
  1707. if ((len < left) && *p && !isspace(*p))
  1708. break;
  1709. if (neg)
  1710. val = -val;
  1711. s += len;
  1712. left -= len;
  1713. if (conv(&neg, &lval, i, 1, data))
  1714. break;
  1715. } else {
  1716. p = buf;
  1717. if (!first)
  1718. *p++ = '\t';
  1719. if (conv(&neg, &lval, i, 0, data))
  1720. break;
  1721. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  1722. len = strlen(buf);
  1723. if (len > left)
  1724. len = left;
  1725. if(copy_to_user(s, buf, len))
  1726. return -EFAULT;
  1727. left -= len;
  1728. s += len;
  1729. }
  1730. }
  1731. if (!write && !first && left) {
  1732. if(put_user('\n', s))
  1733. return -EFAULT;
  1734. left--, s++;
  1735. }
  1736. if (write) {
  1737. while (left) {
  1738. char c;
  1739. if (get_user(c, s++))
  1740. return -EFAULT;
  1741. if (!isspace(c))
  1742. break;
  1743. left--;
  1744. }
  1745. }
  1746. if (write && first)
  1747. return -EINVAL;
  1748. *lenp -= left;
  1749. *ppos += *lenp;
  1750. return 0;
  1751. #undef TMPBUFLEN
  1752. }
  1753. static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
  1754. void __user *buffer, size_t *lenp, loff_t *ppos,
  1755. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  1756. int write, void *data),
  1757. void *data)
  1758. {
  1759. return __do_proc_dointvec(table->data, table, write, filp,
  1760. buffer, lenp, ppos, conv, data);
  1761. }
  1762. /**
  1763. * proc_dointvec - read a vector of integers
  1764. * @table: the sysctl table
  1765. * @write: %TRUE if this is a write to the sysctl file
  1766. * @filp: the file structure
  1767. * @buffer: the user buffer
  1768. * @lenp: the size of the user buffer
  1769. * @ppos: file position
  1770. *
  1771. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  1772. * values from/to the user buffer, treated as an ASCII string.
  1773. *
  1774. * Returns 0 on success.
  1775. */
  1776. int proc_dointvec(ctl_table *table, int write, struct file *filp,
  1777. void __user *buffer, size_t *lenp, loff_t *ppos)
  1778. {
  1779. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  1780. NULL,NULL);
  1781. }
  1782. #define OP_SET 0
  1783. #define OP_AND 1
  1784. #define OP_OR 2
  1785. static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
  1786. int *valp,
  1787. int write, void *data)
  1788. {
  1789. int op = *(int *)data;
  1790. if (write) {
  1791. int val = *negp ? -*lvalp : *lvalp;
  1792. switch(op) {
  1793. case OP_SET: *valp = val; break;
  1794. case OP_AND: *valp &= val; break;
  1795. case OP_OR: *valp |= val; break;
  1796. }
  1797. } else {
  1798. int val = *valp;
  1799. if (val < 0) {
  1800. *negp = -1;
  1801. *lvalp = (unsigned long)-val;
  1802. } else {
  1803. *negp = 0;
  1804. *lvalp = (unsigned long)val;
  1805. }
  1806. }
  1807. return 0;
  1808. }
  1809. /*
  1810. * init may raise the set.
  1811. */
  1812. int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
  1813. void __user *buffer, size_t *lenp, loff_t *ppos)
  1814. {
  1815. int op;
  1816. if (write && !capable(CAP_SYS_MODULE)) {
  1817. return -EPERM;
  1818. }
  1819. op = is_init(current) ? OP_SET : OP_AND;
  1820. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  1821. do_proc_dointvec_bset_conv,&op);
  1822. }
  1823. /*
  1824. * Taint values can only be increased
  1825. */
  1826. static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
  1827. void __user *buffer, size_t *lenp, loff_t *ppos)
  1828. {
  1829. int op;
  1830. if (write && !capable(CAP_SYS_ADMIN))
  1831. return -EPERM;
  1832. op = OP_OR;
  1833. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  1834. do_proc_dointvec_bset_conv,&op);
  1835. }
  1836. struct do_proc_dointvec_minmax_conv_param {
  1837. int *min;
  1838. int *max;
  1839. };
  1840. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  1841. int *valp,
  1842. int write, void *data)
  1843. {
  1844. struct do_proc_dointvec_minmax_conv_param *param = data;
  1845. if (write) {
  1846. int val = *negp ? -*lvalp : *lvalp;
  1847. if ((param->min && *param->min > val) ||
  1848. (param->max && *param->max < val))
  1849. return -EINVAL;
  1850. *valp = val;
  1851. } else {
  1852. int val = *valp;
  1853. if (val < 0) {
  1854. *negp = -1;
  1855. *lvalp = (unsigned long)-val;
  1856. } else {
  1857. *negp = 0;
  1858. *lvalp = (unsigned long)val;
  1859. }
  1860. }
  1861. return 0;
  1862. }
  1863. /**
  1864. * proc_dointvec_minmax - read a vector of integers with min/max values
  1865. * @table: the sysctl table
  1866. * @write: %TRUE if this is a write to the sysctl file
  1867. * @filp: the file structure
  1868. * @buffer: the user buffer
  1869. * @lenp: the size of the user buffer
  1870. * @ppos: file position
  1871. *
  1872. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  1873. * values from/to the user buffer, treated as an ASCII string.
  1874. *
  1875. * This routine will ensure the values are within the range specified by
  1876. * table->extra1 (min) and table->extra2 (max).
  1877. *
  1878. * Returns 0 on success.
  1879. */
  1880. int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
  1881. void __user *buffer, size_t *lenp, loff_t *ppos)
  1882. {
  1883. struct do_proc_dointvec_minmax_conv_param param = {
  1884. .min = (int *) table->extra1,
  1885. .max = (int *) table->extra2,
  1886. };
  1887. return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
  1888. do_proc_dointvec_minmax_conv, &param);
  1889. }
  1890. static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
  1891. struct file *filp,
  1892. void __user *buffer,
  1893. size_t *lenp, loff_t *ppos,
  1894. unsigned long convmul,
  1895. unsigned long convdiv)
  1896. {
  1897. #define TMPBUFLEN 21
  1898. unsigned long *i, *min, *max, val;
  1899. int vleft, first=1, neg;
  1900. size_t len, left;
  1901. char buf[TMPBUFLEN], *p;
  1902. char __user *s = buffer;
  1903. if (!data || !table->maxlen || !*lenp ||
  1904. (*ppos && !write)) {
  1905. *lenp = 0;
  1906. return 0;
  1907. }
  1908. i = (unsigned long *) data;
  1909. min = (unsigned long *) table->extra1;
  1910. max = (unsigned long *) table->extra2;
  1911. vleft = table->maxlen / sizeof(unsigned long);
  1912. left = *lenp;
  1913. for (; left && vleft--; i++, min++, max++, first=0) {
  1914. if (write) {
  1915. while (left) {
  1916. char c;
  1917. if (get_user(c, s))
  1918. return -EFAULT;
  1919. if (!isspace(c))
  1920. break;
  1921. left--;
  1922. s++;
  1923. }
  1924. if (!left)
  1925. break;
  1926. neg = 0;
  1927. len = left;
  1928. if (len > TMPBUFLEN-1)
  1929. len = TMPBUFLEN-1;
  1930. if (copy_from_user(buf, s, len))
  1931. return -EFAULT;
  1932. buf[len] = 0;
  1933. p = buf;
  1934. if (*p == '-' && left > 1) {
  1935. neg = 1;
  1936. p++;
  1937. }
  1938. if (*p < '0' || *p > '9')
  1939. break;
  1940. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  1941. len = p-buf;
  1942. if ((len < left) && *p && !isspace(*p))
  1943. break;
  1944. if (neg)
  1945. val = -val;
  1946. s += len;
  1947. left -= len;
  1948. if(neg)
  1949. continue;
  1950. if ((min && val < *min) || (max && val > *max))
  1951. continue;
  1952. *i = val;
  1953. } else {
  1954. p = buf;
  1955. if (!first)
  1956. *p++ = '\t';
  1957. sprintf(p, "%lu", convdiv * (*i) / convmul);
  1958. len = strlen(buf);
  1959. if (len > left)
  1960. len = left;
  1961. if(copy_to_user(s, buf, len))
  1962. return -EFAULT;
  1963. left -= len;
  1964. s += len;
  1965. }
  1966. }
  1967. if (!write && !first && left) {
  1968. if(put_user('\n', s))
  1969. return -EFAULT;
  1970. left--, s++;
  1971. }
  1972. if (write) {
  1973. while (left) {
  1974. char c;
  1975. if (get_user(c, s++))
  1976. return -EFAULT;
  1977. if (!isspace(c))
  1978. break;
  1979. left--;
  1980. }
  1981. }
  1982. if (write && first)
  1983. return -EINVAL;
  1984. *lenp -= left;
  1985. *ppos += *lenp;
  1986. return 0;
  1987. #undef TMPBUFLEN
  1988. }
  1989. static int do_proc_doulongvec_minmax(ctl_table *table, int write,
  1990. struct file *filp,
  1991. void __user *buffer,
  1992. size_t *lenp, loff_t *ppos,
  1993. unsigned long convmul,
  1994. unsigned long convdiv)
  1995. {
  1996. return __do_proc_doulongvec_minmax(table->data, table, write,
  1997. filp, buffer, lenp, ppos, convmul, convdiv);
  1998. }
  1999. /**
  2000. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  2001. * @table: the sysctl table
  2002. * @write: %TRUE if this is a write to the sysctl file
  2003. * @filp: the file structure
  2004. * @buffer: the user buffer
  2005. * @lenp: the size of the user buffer
  2006. * @ppos: file position
  2007. *
  2008. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2009. * values from/to the user buffer, treated as an ASCII string.
  2010. *
  2011. * This routine will ensure the values are within the range specified by
  2012. * table->extra1 (min) and table->extra2 (max).
  2013. *
  2014. * Returns 0 on success.
  2015. */
  2016. int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
  2017. void __user *buffer, size_t *lenp, loff_t *ppos)
  2018. {
  2019. return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
  2020. }
  2021. /**
  2022. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  2023. * @table: the sysctl table
  2024. * @write: %TRUE if this is a write to the sysctl file
  2025. * @filp: the file structure
  2026. * @buffer: the user buffer
  2027. * @lenp: the size of the user buffer
  2028. * @ppos: file position
  2029. *
  2030. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2031. * values from/to the user buffer, treated as an ASCII string. The values
  2032. * are treated as milliseconds, and converted to jiffies when they are stored.
  2033. *
  2034. * This routine will ensure the values are within the range specified by
  2035. * table->extra1 (min) and table->extra2 (max).
  2036. *
  2037. * Returns 0 on success.
  2038. */
  2039. int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
  2040. struct file *filp,
  2041. void __user *buffer,
  2042. size_t *lenp, loff_t *ppos)
  2043. {
  2044. return do_proc_doulongvec_minmax(table, write, filp, buffer,
  2045. lenp, ppos, HZ, 1000l);
  2046. }
  2047. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  2048. int *valp,
  2049. int write, void *data)
  2050. {
  2051. if (write) {
  2052. if (*lvalp > LONG_MAX / HZ)
  2053. return 1;
  2054. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2055. } else {
  2056. int val = *valp;
  2057. unsigned long lval;
  2058. if (val < 0) {
  2059. *negp = -1;
  2060. lval = (unsigned long)-val;
  2061. } else {
  2062. *negp = 0;
  2063. lval = (unsigned long)val;
  2064. }
  2065. *lvalp = lval / HZ;
  2066. }
  2067. return 0;
  2068. }
  2069. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2070. int *valp,
  2071. int write, void *data)
  2072. {
  2073. if (write) {
  2074. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2075. return 1;
  2076. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2077. } else {
  2078. int val = *valp;
  2079. unsigned long lval;
  2080. if (val < 0) {
  2081. *negp = -1;
  2082. lval = (unsigned long)-val;
  2083. } else {
  2084. *negp = 0;
  2085. lval = (unsigned long)val;
  2086. }
  2087. *lvalp = jiffies_to_clock_t(lval);
  2088. }
  2089. return 0;
  2090. }
  2091. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2092. int *valp,
  2093. int write, void *data)
  2094. {
  2095. if (write) {
  2096. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2097. } else {
  2098. int val = *valp;
  2099. unsigned long lval;
  2100. if (val < 0) {
  2101. *negp = -1;
  2102. lval = (unsigned long)-val;
  2103. } else {
  2104. *negp = 0;
  2105. lval = (unsigned long)val;
  2106. }
  2107. *lvalp = jiffies_to_msecs(lval);
  2108. }
  2109. return 0;
  2110. }
  2111. /**
  2112. * proc_dointvec_jiffies - read a vector of integers as seconds
  2113. * @table: the sysctl table
  2114. * @write: %TRUE if this is a write to the sysctl file
  2115. * @filp: the file structure
  2116. * @buffer: the user buffer
  2117. * @lenp: the size of the user buffer
  2118. * @ppos: file position
  2119. *
  2120. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2121. * values from/to the user buffer, treated as an ASCII string.
  2122. * The values read are assumed to be in seconds, and are converted into
  2123. * jiffies.
  2124. *
  2125. * Returns 0 on success.
  2126. */
  2127. int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
  2128. void __user *buffer, size_t *lenp, loff_t *ppos)
  2129. {
  2130. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2131. do_proc_dointvec_jiffies_conv,NULL);
  2132. }
  2133. /**
  2134. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2135. * @table: the sysctl table
  2136. * @write: %TRUE if this is a write to the sysctl file
  2137. * @filp: the file structure
  2138. * @buffer: the user buffer
  2139. * @lenp: the size of the user buffer
  2140. * @ppos: pointer to the file position
  2141. *
  2142. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2143. * values from/to the user buffer, treated as an ASCII string.
  2144. * The values read are assumed to be in 1/USER_HZ seconds, and
  2145. * are converted into jiffies.
  2146. *
  2147. * Returns 0 on success.
  2148. */
  2149. int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
  2150. void __user *buffer, size_t *lenp, loff_t *ppos)
  2151. {
  2152. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2153. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2154. }
  2155. /**
  2156. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2157. * @table: the sysctl table
  2158. * @write: %TRUE if this is a write to the sysctl file
  2159. * @filp: the file structure
  2160. * @buffer: the user buffer
  2161. * @lenp: the size of the user buffer
  2162. * @ppos: file position
  2163. * @ppos: the current position in the file
  2164. *
  2165. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2166. * values from/to the user buffer, treated as an ASCII string.
  2167. * The values read are assumed to be in 1/1000 seconds, and
  2168. * are converted into jiffies.
  2169. *
  2170. * Returns 0 on success.
  2171. */
  2172. int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
  2173. void __user *buffer, size_t *lenp, loff_t *ppos)
  2174. {
  2175. return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
  2176. do_proc_dointvec_ms_jiffies_conv, NULL);
  2177. }
  2178. static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
  2179. void __user *buffer, size_t *lenp, loff_t *ppos)
  2180. {
  2181. struct pid *new_pid;
  2182. pid_t tmp;
  2183. int r;
  2184. tmp = pid_nr(cad_pid);
  2185. r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
  2186. lenp, ppos, NULL, NULL);
  2187. if (r || !write)
  2188. return r;
  2189. new_pid = find_get_pid(tmp);
  2190. if (!new_pid)
  2191. return -ESRCH;
  2192. put_pid(xchg(&cad_pid, new_pid));
  2193. return 0;
  2194. }
  2195. #else /* CONFIG_PROC_FS */
  2196. int proc_dostring(ctl_table *table, int write, struct file *filp,
  2197. void __user *buffer, size_t *lenp, loff_t *ppos)
  2198. {
  2199. return -ENOSYS;
  2200. }
  2201. int proc_dointvec(ctl_table *table, int write, struct file *filp,
  2202. void __user *buffer, size_t *lenp, loff_t *ppos)
  2203. {
  2204. return -ENOSYS;
  2205. }
  2206. int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
  2207. void __user *buffer, size_t *lenp, loff_t *ppos)
  2208. {
  2209. return -ENOSYS;
  2210. }
  2211. int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
  2212. void __user *buffer, size_t *lenp, loff_t *ppos)
  2213. {
  2214. return -ENOSYS;
  2215. }
  2216. int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
  2217. void __user *buffer, size_t *lenp, loff_t *ppos)
  2218. {
  2219. return -ENOSYS;
  2220. }
  2221. int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
  2222. void __user *buffer, size_t *lenp, loff_t *ppos)
  2223. {
  2224. return -ENOSYS;
  2225. }
  2226. int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
  2227. void __user *buffer, size_t *lenp, loff_t *ppos)
  2228. {
  2229. return -ENOSYS;
  2230. }
  2231. int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
  2232. void __user *buffer, size_t *lenp, loff_t *ppos)
  2233. {
  2234. return -ENOSYS;
  2235. }
  2236. int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
  2237. struct file *filp,
  2238. void __user *buffer,
  2239. size_t *lenp, loff_t *ppos)
  2240. {
  2241. return -ENOSYS;
  2242. }
  2243. #endif /* CONFIG_PROC_FS */
  2244. #ifdef CONFIG_SYSCTL_SYSCALL
  2245. /*
  2246. * General sysctl support routines
  2247. */
  2248. /* The generic string strategy routine: */
  2249. int sysctl_string(ctl_table *table, int __user *name, int nlen,
  2250. void __user *oldval, size_t __user *oldlenp,
  2251. void __user *newval, size_t newlen)
  2252. {
  2253. if (!table->data || !table->maxlen)
  2254. return -ENOTDIR;
  2255. if (oldval && oldlenp) {
  2256. size_t bufsize;
  2257. if (get_user(bufsize, oldlenp))
  2258. return -EFAULT;
  2259. if (bufsize) {
  2260. size_t len = strlen(table->data), copied;
  2261. /* This shouldn't trigger for a well-formed sysctl */
  2262. if (len > table->maxlen)
  2263. len = table->maxlen;
  2264. /* Copy up to a max of bufsize-1 bytes of the string */
  2265. copied = (len >= bufsize) ? bufsize - 1 : len;
  2266. if (copy_to_user(oldval, table->data, copied) ||
  2267. put_user(0, (char __user *)(oldval + copied)))
  2268. return -EFAULT;
  2269. if (put_user(len, oldlenp))
  2270. return -EFAULT;
  2271. }
  2272. }
  2273. if (newval && newlen) {
  2274. size_t len = newlen;
  2275. if (len > table->maxlen)
  2276. len = table->maxlen;
  2277. if(copy_from_user(table->data, newval, len))
  2278. return -EFAULT;
  2279. if (len == table->maxlen)
  2280. len--;
  2281. ((char *) table->data)[len] = 0;
  2282. }
  2283. return 1;
  2284. }
  2285. /*
  2286. * This function makes sure that all of the integers in the vector
  2287. * are between the minimum and maximum values given in the arrays
  2288. * table->extra1 and table->extra2, respectively.
  2289. */
  2290. int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
  2291. void __user *oldval, size_t __user *oldlenp,
  2292. void __user *newval, size_t newlen)
  2293. {
  2294. if (newval && newlen) {
  2295. int __user *vec = (int __user *) newval;
  2296. int *min = (int *) table->extra1;
  2297. int *max = (int *) table->extra2;
  2298. size_t length;
  2299. int i;
  2300. if (newlen % sizeof(int) != 0)
  2301. return -EINVAL;
  2302. if (!table->extra1 && !table->extra2)
  2303. return 0;
  2304. if (newlen > table->maxlen)
  2305. newlen = table->maxlen;
  2306. length = newlen / sizeof(int);
  2307. for (i = 0; i < length; i++) {
  2308. int value;
  2309. if (get_user(value, vec + i))
  2310. return -EFAULT;
  2311. if (min && value < min[i])
  2312. return -EINVAL;
  2313. if (max && value > max[i])
  2314. return -EINVAL;
  2315. }
  2316. }
  2317. return 0;
  2318. }
  2319. /* Strategy function to convert jiffies to seconds */
  2320. int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
  2321. void __user *oldval, size_t __user *oldlenp,
  2322. void __user *newval, size_t newlen)
  2323. {
  2324. if (oldval && oldlenp) {
  2325. size_t olen;
  2326. if (get_user(olen, oldlenp))
  2327. return -EFAULT;
  2328. if (olen) {
  2329. int val;
  2330. if (olen < sizeof(int))
  2331. return -EINVAL;
  2332. val = *(int *)(table->data) / HZ;
  2333. if (put_user(val, (int __user *)oldval))
  2334. return -EFAULT;
  2335. if (put_user(sizeof(int), oldlenp))
  2336. return -EFAULT;
  2337. }
  2338. }
  2339. if (newval && newlen) {
  2340. int new;
  2341. if (newlen != sizeof(int))
  2342. return -EINVAL;
  2343. if (get_user(new, (int __user *)newval))
  2344. return -EFAULT;
  2345. *(int *)(table->data) = new*HZ;
  2346. }
  2347. return 1;
  2348. }
  2349. /* Strategy function to convert jiffies to seconds */
  2350. int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
  2351. void __user *oldval, size_t __user *oldlenp,
  2352. void __user *newval, size_t newlen)
  2353. {
  2354. if (oldval && oldlenp) {
  2355. size_t olen;
  2356. if (get_user(olen, oldlenp))
  2357. return -EFAULT;
  2358. if (olen) {
  2359. int val;
  2360. if (olen < sizeof(int))
  2361. return -EINVAL;
  2362. val = jiffies_to_msecs(*(int *)(table->data));
  2363. if (put_user(val, (int __user *)oldval))
  2364. return -EFAULT;
  2365. if (put_user(sizeof(int), oldlenp))
  2366. return -EFAULT;
  2367. }
  2368. }
  2369. if (newval && newlen) {
  2370. int new;
  2371. if (newlen != sizeof(int))
  2372. return -EINVAL;
  2373. if (get_user(new, (int __user *)newval))
  2374. return -EFAULT;
  2375. *(int *)(table->data) = msecs_to_jiffies(new);
  2376. }
  2377. return 1;
  2378. }
  2379. #else /* CONFIG_SYSCTL_SYSCALL */
  2380. asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
  2381. {
  2382. static int msg_count;
  2383. struct __sysctl_args tmp;
  2384. int name[CTL_MAXNAME];
  2385. int i;
  2386. /* Read in the sysctl name for better debug message logging */
  2387. if (copy_from_user(&tmp, args, sizeof(tmp)))
  2388. return -EFAULT;
  2389. if (tmp.nlen <= 0 || tmp.nlen >= CTL_MAXNAME)
  2390. return -ENOTDIR;
  2391. for (i = 0; i < tmp.nlen; i++)
  2392. if (get_user(name[i], tmp.name + i))
  2393. return -EFAULT;
  2394. /* Ignore accesses to kernel.version */
  2395. if ((tmp.nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
  2396. goto out;
  2397. if (msg_count < 5) {
  2398. msg_count++;
  2399. printk(KERN_INFO
  2400. "warning: process `%s' used the removed sysctl "
  2401. "system call with ", current->comm);
  2402. for (i = 0; i < tmp.nlen; i++)
  2403. printk("%d.", name[i]);
  2404. printk("\n");
  2405. }
  2406. out:
  2407. return -ENOSYS;
  2408. }
  2409. int sysctl_string(ctl_table *table, int __user *name, int nlen,
  2410. void __user *oldval, size_t __user *oldlenp,
  2411. void __user *newval, size_t newlen)
  2412. {
  2413. return -ENOSYS;
  2414. }
  2415. int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
  2416. void __user *oldval, size_t __user *oldlenp,
  2417. void __user *newval, size_t newlen)
  2418. {
  2419. return -ENOSYS;
  2420. }
  2421. int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
  2422. void __user *oldval, size_t __user *oldlenp,
  2423. void __user *newval, size_t newlen)
  2424. {
  2425. return -ENOSYS;
  2426. }
  2427. int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
  2428. void __user *oldval, size_t __user *oldlenp,
  2429. void __user *newval, size_t newlen)
  2430. {
  2431. return -ENOSYS;
  2432. }
  2433. #endif /* CONFIG_SYSCTL_SYSCALL */
  2434. /*
  2435. * No sense putting this after each symbol definition, twice,
  2436. * exception granted :-)
  2437. */
  2438. EXPORT_SYMBOL(proc_dointvec);
  2439. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2440. EXPORT_SYMBOL(proc_dointvec_minmax);
  2441. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2442. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2443. EXPORT_SYMBOL(proc_dostring);
  2444. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2445. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2446. EXPORT_SYMBOL(register_sysctl_table);
  2447. EXPORT_SYMBOL(sysctl_intvec);
  2448. EXPORT_SYMBOL(sysctl_jiffies);
  2449. EXPORT_SYMBOL(sysctl_ms_jiffies);
  2450. EXPORT_SYMBOL(sysctl_string);
  2451. EXPORT_SYMBOL(unregister_sysctl_table);