sysctl.c 75 KB

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