sysctl.c 75 KB

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