sysctl.c 61 KB

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