sysctl.c 74 KB

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