sysctl.c 75 KB

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