sysctl.c 76 KB

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