sysctl.c 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959
  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/aio.h>
  22. #include <linux/mm.h>
  23. #include <linux/swap.h>
  24. #include <linux/slab.h>
  25. #include <linux/sysctl.h>
  26. #include <linux/bitmap.h>
  27. #include <linux/signal.h>
  28. #include <linux/printk.h>
  29. #include <linux/proc_fs.h>
  30. #include <linux/security.h>
  31. #include <linux/ctype.h>
  32. #include <linux/kmemcheck.h>
  33. #include <linux/kmemleak.h>
  34. #include <linux/fs.h>
  35. #include <linux/init.h>
  36. #include <linux/kernel.h>
  37. #include <linux/kobject.h>
  38. #include <linux/net.h>
  39. #include <linux/sysrq.h>
  40. #include <linux/highuid.h>
  41. #include <linux/writeback.h>
  42. #include <linux/ratelimit.h>
  43. #include <linux/compaction.h>
  44. #include <linux/hugetlb.h>
  45. #include <linux/initrd.h>
  46. #include <linux/key.h>
  47. #include <linux/times.h>
  48. #include <linux/limits.h>
  49. #include <linux/dcache.h>
  50. #include <linux/dnotify.h>
  51. #include <linux/syscalls.h>
  52. #include <linux/vmstat.h>
  53. #include <linux/nfs_fs.h>
  54. #include <linux/acpi.h>
  55. #include <linux/reboot.h>
  56. #include <linux/ftrace.h>
  57. #include <linux/perf_event.h>
  58. #include <linux/kprobes.h>
  59. #include <linux/pipe_fs_i.h>
  60. #include <linux/oom.h>
  61. #include <linux/kmod.h>
  62. #include <linux/capability.h>
  63. #include <linux/binfmts.h>
  64. #include <linux/sched/sysctl.h>
  65. #include <linux/kexec.h>
  66. #include <linux/bpf.h>
  67. #include <linux/mount.h>
  68. #include <asm/uaccess.h>
  69. #include <asm/processor.h>
  70. #ifdef CONFIG_X86
  71. #include <asm/nmi.h>
  72. #include <asm/stacktrace.h>
  73. #include <asm/io.h>
  74. #endif
  75. #ifdef CONFIG_SPARC
  76. #include <asm/setup.h>
  77. #endif
  78. #ifdef CONFIG_BSD_PROCESS_ACCT
  79. #include <linux/acct.h>
  80. #endif
  81. #ifdef CONFIG_RT_MUTEXES
  82. #include <linux/rtmutex.h>
  83. #endif
  84. #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
  85. #include <linux/lockdep.h>
  86. #endif
  87. #ifdef CONFIG_CHR_DEV_SG
  88. #include <scsi/sg.h>
  89. #endif
  90. #ifdef CONFIG_LOCKUP_DETECTOR
  91. #include <linux/nmi.h>
  92. #endif
  93. #if defined(CONFIG_SYSCTL)
  94. /* External variables not in a header file. */
  95. extern int suid_dumpable;
  96. #ifdef CONFIG_COREDUMP
  97. extern int core_uses_pid;
  98. extern char core_pattern[];
  99. extern unsigned int core_pipe_limit;
  100. #endif
  101. extern int pid_max;
  102. extern int pid_max_min, pid_max_max;
  103. extern int percpu_pagelist_fraction;
  104. extern int latencytop_enabled;
  105. extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
  106. #ifndef CONFIG_MMU
  107. extern int sysctl_nr_trim_pages;
  108. #endif
  109. /* Constants used for minimum and maximum */
  110. #ifdef CONFIG_LOCKUP_DETECTOR
  111. static int sixty = 60;
  112. #endif
  113. static int __maybe_unused neg_one = -1;
  114. static int zero;
  115. static int __maybe_unused one = 1;
  116. static int __maybe_unused two = 2;
  117. static int __maybe_unused four = 4;
  118. static unsigned long one_ul = 1;
  119. static int one_hundred = 100;
  120. static int one_thousand = 1000;
  121. #ifdef CONFIG_PRINTK
  122. static int ten_thousand = 10000;
  123. #endif
  124. #ifdef CONFIG_PERF_EVENTS
  125. static int six_hundred_forty_kb = 640 * 1024;
  126. #endif
  127. /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
  128. static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
  129. /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
  130. static int maxolduid = 65535;
  131. static int minolduid;
  132. static int ngroups_max = NGROUPS_MAX;
  133. static const int cap_last_cap = CAP_LAST_CAP;
  134. /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
  135. #ifdef CONFIG_DETECT_HUNG_TASK
  136. static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
  137. #endif
  138. #ifdef CONFIG_INOTIFY_USER
  139. #include <linux/inotify.h>
  140. #endif
  141. #ifdef CONFIG_SPARC
  142. #endif
  143. #ifdef __hppa__
  144. extern int pwrsw_enabled;
  145. #endif
  146. #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
  147. extern int unaligned_enabled;
  148. #endif
  149. #ifdef CONFIG_IA64
  150. extern int unaligned_dump_stack;
  151. #endif
  152. #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
  153. extern int no_unaligned_warning;
  154. #endif
  155. #ifdef CONFIG_PROC_SYSCTL
  156. #define SYSCTL_WRITES_LEGACY -1
  157. #define SYSCTL_WRITES_WARN 0
  158. #define SYSCTL_WRITES_STRICT 1
  159. static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
  160. static int proc_do_cad_pid(struct ctl_table *table, int write,
  161. void __user *buffer, size_t *lenp, loff_t *ppos);
  162. static int proc_taint(struct ctl_table *table, int write,
  163. void __user *buffer, size_t *lenp, loff_t *ppos);
  164. #endif
  165. #ifdef CONFIG_PRINTK
  166. static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
  167. void __user *buffer, size_t *lenp, loff_t *ppos);
  168. #endif
  169. static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
  170. void __user *buffer, size_t *lenp, loff_t *ppos);
  171. #ifdef CONFIG_COREDUMP
  172. static int proc_dostring_coredump(struct ctl_table *table, int write,
  173. void __user *buffer, size_t *lenp, loff_t *ppos);
  174. #endif
  175. #ifdef CONFIG_MAGIC_SYSRQ
  176. /* Note: sysrq code uses it's own private copy */
  177. static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
  178. static int sysrq_sysctl_handler(struct ctl_table *table, int write,
  179. void __user *buffer, size_t *lenp,
  180. loff_t *ppos)
  181. {
  182. int error;
  183. error = proc_dointvec(table, write, buffer, lenp, ppos);
  184. if (error)
  185. return error;
  186. if (write)
  187. sysrq_toggle_support(__sysrq_enabled);
  188. return 0;
  189. }
  190. #endif
  191. static struct ctl_table kern_table[];
  192. static struct ctl_table vm_table[];
  193. static struct ctl_table fs_table[];
  194. static struct ctl_table debug_table[];
  195. static struct ctl_table dev_table[];
  196. extern struct ctl_table random_table[];
  197. #ifdef CONFIG_EPOLL
  198. extern struct ctl_table epoll_table[];
  199. #endif
  200. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  201. int sysctl_legacy_va_layout;
  202. #endif
  203. /* The default sysctl tables: */
  204. static struct ctl_table sysctl_base_table[] = {
  205. {
  206. .procname = "kernel",
  207. .mode = 0555,
  208. .child = kern_table,
  209. },
  210. {
  211. .procname = "vm",
  212. .mode = 0555,
  213. .child = vm_table,
  214. },
  215. {
  216. .procname = "fs",
  217. .mode = 0555,
  218. .child = fs_table,
  219. },
  220. {
  221. .procname = "debug",
  222. .mode = 0555,
  223. .child = debug_table,
  224. },
  225. {
  226. .procname = "dev",
  227. .mode = 0555,
  228. .child = dev_table,
  229. },
  230. { }
  231. };
  232. #ifdef CONFIG_SCHED_DEBUG
  233. static int min_sched_granularity_ns = 100000; /* 100 usecs */
  234. static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
  235. static int min_wakeup_granularity_ns; /* 0 usecs */
  236. static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
  237. #ifdef CONFIG_SMP
  238. static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
  239. static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
  240. #endif /* CONFIG_SMP */
  241. #endif /* CONFIG_SCHED_DEBUG */
  242. #ifdef CONFIG_COMPACTION
  243. static int min_extfrag_threshold;
  244. static int max_extfrag_threshold = 1000;
  245. #endif
  246. static struct ctl_table kern_table[] = {
  247. {
  248. .procname = "sched_child_runs_first",
  249. .data = &sysctl_sched_child_runs_first,
  250. .maxlen = sizeof(unsigned int),
  251. .mode = 0644,
  252. .proc_handler = proc_dointvec,
  253. },
  254. #ifdef CONFIG_SCHED_DEBUG
  255. {
  256. .procname = "sched_min_granularity_ns",
  257. .data = &sysctl_sched_min_granularity,
  258. .maxlen = sizeof(unsigned int),
  259. .mode = 0644,
  260. .proc_handler = sched_proc_update_handler,
  261. .extra1 = &min_sched_granularity_ns,
  262. .extra2 = &max_sched_granularity_ns,
  263. },
  264. {
  265. .procname = "sched_latency_ns",
  266. .data = &sysctl_sched_latency,
  267. .maxlen = sizeof(unsigned int),
  268. .mode = 0644,
  269. .proc_handler = sched_proc_update_handler,
  270. .extra1 = &min_sched_granularity_ns,
  271. .extra2 = &max_sched_granularity_ns,
  272. },
  273. {
  274. .procname = "sched_wakeup_granularity_ns",
  275. .data = &sysctl_sched_wakeup_granularity,
  276. .maxlen = sizeof(unsigned int),
  277. .mode = 0644,
  278. .proc_handler = sched_proc_update_handler,
  279. .extra1 = &min_wakeup_granularity_ns,
  280. .extra2 = &max_wakeup_granularity_ns,
  281. },
  282. #ifdef CONFIG_SMP
  283. {
  284. .procname = "sched_tunable_scaling",
  285. .data = &sysctl_sched_tunable_scaling,
  286. .maxlen = sizeof(enum sched_tunable_scaling),
  287. .mode = 0644,
  288. .proc_handler = sched_proc_update_handler,
  289. .extra1 = &min_sched_tunable_scaling,
  290. .extra2 = &max_sched_tunable_scaling,
  291. },
  292. {
  293. .procname = "sched_migration_cost_ns",
  294. .data = &sysctl_sched_migration_cost,
  295. .maxlen = sizeof(unsigned int),
  296. .mode = 0644,
  297. .proc_handler = proc_dointvec,
  298. },
  299. {
  300. .procname = "sched_nr_migrate",
  301. .data = &sysctl_sched_nr_migrate,
  302. .maxlen = sizeof(unsigned int),
  303. .mode = 0644,
  304. .proc_handler = proc_dointvec,
  305. },
  306. {
  307. .procname = "sched_time_avg_ms",
  308. .data = &sysctl_sched_time_avg,
  309. .maxlen = sizeof(unsigned int),
  310. .mode = 0644,
  311. .proc_handler = proc_dointvec,
  312. },
  313. {
  314. .procname = "sched_shares_window_ns",
  315. .data = &sysctl_sched_shares_window,
  316. .maxlen = sizeof(unsigned int),
  317. .mode = 0644,
  318. .proc_handler = proc_dointvec,
  319. },
  320. #ifdef CONFIG_SCHEDSTATS
  321. {
  322. .procname = "sched_schedstats",
  323. .data = NULL,
  324. .maxlen = sizeof(unsigned int),
  325. .mode = 0644,
  326. .proc_handler = sysctl_schedstats,
  327. .extra1 = &zero,
  328. .extra2 = &one,
  329. },
  330. #endif /* CONFIG_SCHEDSTATS */
  331. #endif /* CONFIG_SMP */
  332. #ifdef CONFIG_NUMA_BALANCING
  333. {
  334. .procname = "numa_balancing_scan_delay_ms",
  335. .data = &sysctl_numa_balancing_scan_delay,
  336. .maxlen = sizeof(unsigned int),
  337. .mode = 0644,
  338. .proc_handler = proc_dointvec,
  339. },
  340. {
  341. .procname = "numa_balancing_scan_period_min_ms",
  342. .data = &sysctl_numa_balancing_scan_period_min,
  343. .maxlen = sizeof(unsigned int),
  344. .mode = 0644,
  345. .proc_handler = proc_dointvec,
  346. },
  347. {
  348. .procname = "numa_balancing_scan_period_max_ms",
  349. .data = &sysctl_numa_balancing_scan_period_max,
  350. .maxlen = sizeof(unsigned int),
  351. .mode = 0644,
  352. .proc_handler = proc_dointvec,
  353. },
  354. {
  355. .procname = "numa_balancing_scan_size_mb",
  356. .data = &sysctl_numa_balancing_scan_size,
  357. .maxlen = sizeof(unsigned int),
  358. .mode = 0644,
  359. .proc_handler = proc_dointvec_minmax,
  360. .extra1 = &one,
  361. },
  362. {
  363. .procname = "numa_balancing",
  364. .data = NULL, /* filled in by handler */
  365. .maxlen = sizeof(unsigned int),
  366. .mode = 0644,
  367. .proc_handler = sysctl_numa_balancing,
  368. .extra1 = &zero,
  369. .extra2 = &one,
  370. },
  371. #endif /* CONFIG_NUMA_BALANCING */
  372. #endif /* CONFIG_SCHED_DEBUG */
  373. {
  374. .procname = "sched_rt_period_us",
  375. .data = &sysctl_sched_rt_period,
  376. .maxlen = sizeof(unsigned int),
  377. .mode = 0644,
  378. .proc_handler = sched_rt_handler,
  379. },
  380. {
  381. .procname = "sched_rt_runtime_us",
  382. .data = &sysctl_sched_rt_runtime,
  383. .maxlen = sizeof(int),
  384. .mode = 0644,
  385. .proc_handler = sched_rt_handler,
  386. },
  387. {
  388. .procname = "sched_rr_timeslice_ms",
  389. .data = &sched_rr_timeslice,
  390. .maxlen = sizeof(int),
  391. .mode = 0644,
  392. .proc_handler = sched_rr_handler,
  393. },
  394. #ifdef CONFIG_SCHED_AUTOGROUP
  395. {
  396. .procname = "sched_autogroup_enabled",
  397. .data = &sysctl_sched_autogroup_enabled,
  398. .maxlen = sizeof(unsigned int),
  399. .mode = 0644,
  400. .proc_handler = proc_dointvec_minmax,
  401. .extra1 = &zero,
  402. .extra2 = &one,
  403. },
  404. #endif
  405. #ifdef CONFIG_CFS_BANDWIDTH
  406. {
  407. .procname = "sched_cfs_bandwidth_slice_us",
  408. .data = &sysctl_sched_cfs_bandwidth_slice,
  409. .maxlen = sizeof(unsigned int),
  410. .mode = 0644,
  411. .proc_handler = proc_dointvec_minmax,
  412. .extra1 = &one,
  413. },
  414. #endif
  415. #ifdef CONFIG_PROVE_LOCKING
  416. {
  417. .procname = "prove_locking",
  418. .data = &prove_locking,
  419. .maxlen = sizeof(int),
  420. .mode = 0644,
  421. .proc_handler = proc_dointvec,
  422. },
  423. #endif
  424. #ifdef CONFIG_LOCK_STAT
  425. {
  426. .procname = "lock_stat",
  427. .data = &lock_stat,
  428. .maxlen = sizeof(int),
  429. .mode = 0644,
  430. .proc_handler = proc_dointvec,
  431. },
  432. #endif
  433. {
  434. .procname = "panic",
  435. .data = &panic_timeout,
  436. .maxlen = sizeof(int),
  437. .mode = 0644,
  438. .proc_handler = proc_dointvec,
  439. },
  440. #ifdef CONFIG_COREDUMP
  441. {
  442. .procname = "core_uses_pid",
  443. .data = &core_uses_pid,
  444. .maxlen = sizeof(int),
  445. .mode = 0644,
  446. .proc_handler = proc_dointvec,
  447. },
  448. {
  449. .procname = "core_pattern",
  450. .data = core_pattern,
  451. .maxlen = CORENAME_MAX_SIZE,
  452. .mode = 0644,
  453. .proc_handler = proc_dostring_coredump,
  454. },
  455. {
  456. .procname = "core_pipe_limit",
  457. .data = &core_pipe_limit,
  458. .maxlen = sizeof(unsigned int),
  459. .mode = 0644,
  460. .proc_handler = proc_dointvec,
  461. },
  462. #endif
  463. #ifdef CONFIG_PROC_SYSCTL
  464. {
  465. .procname = "tainted",
  466. .maxlen = sizeof(long),
  467. .mode = 0644,
  468. .proc_handler = proc_taint,
  469. },
  470. {
  471. .procname = "sysctl_writes_strict",
  472. .data = &sysctl_writes_strict,
  473. .maxlen = sizeof(int),
  474. .mode = 0644,
  475. .proc_handler = proc_dointvec_minmax,
  476. .extra1 = &neg_one,
  477. .extra2 = &one,
  478. },
  479. #endif
  480. #ifdef CONFIG_LATENCYTOP
  481. {
  482. .procname = "latencytop",
  483. .data = &latencytop_enabled,
  484. .maxlen = sizeof(int),
  485. .mode = 0644,
  486. .proc_handler = sysctl_latencytop,
  487. },
  488. #endif
  489. #ifdef CONFIG_BLK_DEV_INITRD
  490. {
  491. .procname = "real-root-dev",
  492. .data = &real_root_dev,
  493. .maxlen = sizeof(int),
  494. .mode = 0644,
  495. .proc_handler = proc_dointvec,
  496. },
  497. #endif
  498. {
  499. .procname = "print-fatal-signals",
  500. .data = &print_fatal_signals,
  501. .maxlen = sizeof(int),
  502. .mode = 0644,
  503. .proc_handler = proc_dointvec,
  504. },
  505. #ifdef CONFIG_SPARC
  506. {
  507. .procname = "reboot-cmd",
  508. .data = reboot_command,
  509. .maxlen = 256,
  510. .mode = 0644,
  511. .proc_handler = proc_dostring,
  512. },
  513. {
  514. .procname = "stop-a",
  515. .data = &stop_a_enabled,
  516. .maxlen = sizeof (int),
  517. .mode = 0644,
  518. .proc_handler = proc_dointvec,
  519. },
  520. {
  521. .procname = "scons-poweroff",
  522. .data = &scons_pwroff,
  523. .maxlen = sizeof (int),
  524. .mode = 0644,
  525. .proc_handler = proc_dointvec,
  526. },
  527. #endif
  528. #ifdef CONFIG_SPARC64
  529. {
  530. .procname = "tsb-ratio",
  531. .data = &sysctl_tsb_ratio,
  532. .maxlen = sizeof (int),
  533. .mode = 0644,
  534. .proc_handler = proc_dointvec,
  535. },
  536. #endif
  537. #ifdef __hppa__
  538. {
  539. .procname = "soft-power",
  540. .data = &pwrsw_enabled,
  541. .maxlen = sizeof (int),
  542. .mode = 0644,
  543. .proc_handler = proc_dointvec,
  544. },
  545. #endif
  546. #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
  547. {
  548. .procname = "unaligned-trap",
  549. .data = &unaligned_enabled,
  550. .maxlen = sizeof (int),
  551. .mode = 0644,
  552. .proc_handler = proc_dointvec,
  553. },
  554. #endif
  555. {
  556. .procname = "ctrl-alt-del",
  557. .data = &C_A_D,
  558. .maxlen = sizeof(int),
  559. .mode = 0644,
  560. .proc_handler = proc_dointvec,
  561. },
  562. #ifdef CONFIG_FUNCTION_TRACER
  563. {
  564. .procname = "ftrace_enabled",
  565. .data = &ftrace_enabled,
  566. .maxlen = sizeof(int),
  567. .mode = 0644,
  568. .proc_handler = ftrace_enable_sysctl,
  569. },
  570. #endif
  571. #ifdef CONFIG_STACK_TRACER
  572. {
  573. .procname = "stack_tracer_enabled",
  574. .data = &stack_tracer_enabled,
  575. .maxlen = sizeof(int),
  576. .mode = 0644,
  577. .proc_handler = stack_trace_sysctl,
  578. },
  579. #endif
  580. #ifdef CONFIG_TRACING
  581. {
  582. .procname = "ftrace_dump_on_oops",
  583. .data = &ftrace_dump_on_oops,
  584. .maxlen = sizeof(int),
  585. .mode = 0644,
  586. .proc_handler = proc_dointvec,
  587. },
  588. {
  589. .procname = "traceoff_on_warning",
  590. .data = &__disable_trace_on_warning,
  591. .maxlen = sizeof(__disable_trace_on_warning),
  592. .mode = 0644,
  593. .proc_handler = proc_dointvec,
  594. },
  595. {
  596. .procname = "tracepoint_printk",
  597. .data = &tracepoint_printk,
  598. .maxlen = sizeof(tracepoint_printk),
  599. .mode = 0644,
  600. .proc_handler = proc_dointvec,
  601. },
  602. #endif
  603. #ifdef CONFIG_KEXEC_CORE
  604. {
  605. .procname = "kexec_load_disabled",
  606. .data = &kexec_load_disabled,
  607. .maxlen = sizeof(int),
  608. .mode = 0644,
  609. /* only handle a transition from default "0" to "1" */
  610. .proc_handler = proc_dointvec_minmax,
  611. .extra1 = &one,
  612. .extra2 = &one,
  613. },
  614. #endif
  615. #ifdef CONFIG_MODULES
  616. {
  617. .procname = "modprobe",
  618. .data = &modprobe_path,
  619. .maxlen = KMOD_PATH_LEN,
  620. .mode = 0644,
  621. .proc_handler = proc_dostring,
  622. },
  623. {
  624. .procname = "modules_disabled",
  625. .data = &modules_disabled,
  626. .maxlen = sizeof(int),
  627. .mode = 0644,
  628. /* only handle a transition from default "0" to "1" */
  629. .proc_handler = proc_dointvec_minmax,
  630. .extra1 = &one,
  631. .extra2 = &one,
  632. },
  633. #endif
  634. #ifdef CONFIG_UEVENT_HELPER
  635. {
  636. .procname = "hotplug",
  637. .data = &uevent_helper,
  638. .maxlen = UEVENT_HELPER_PATH_LEN,
  639. .mode = 0644,
  640. .proc_handler = proc_dostring,
  641. },
  642. #endif
  643. #ifdef CONFIG_CHR_DEV_SG
  644. {
  645. .procname = "sg-big-buff",
  646. .data = &sg_big_buff,
  647. .maxlen = sizeof (int),
  648. .mode = 0444,
  649. .proc_handler = proc_dointvec,
  650. },
  651. #endif
  652. #ifdef CONFIG_BSD_PROCESS_ACCT
  653. {
  654. .procname = "acct",
  655. .data = &acct_parm,
  656. .maxlen = 3*sizeof(int),
  657. .mode = 0644,
  658. .proc_handler = proc_dointvec,
  659. },
  660. #endif
  661. #ifdef CONFIG_MAGIC_SYSRQ
  662. {
  663. .procname = "sysrq",
  664. .data = &__sysrq_enabled,
  665. .maxlen = sizeof (int),
  666. .mode = 0644,
  667. .proc_handler = sysrq_sysctl_handler,
  668. },
  669. #endif
  670. #ifdef CONFIG_PROC_SYSCTL
  671. {
  672. .procname = "cad_pid",
  673. .data = NULL,
  674. .maxlen = sizeof (int),
  675. .mode = 0600,
  676. .proc_handler = proc_do_cad_pid,
  677. },
  678. #endif
  679. {
  680. .procname = "threads-max",
  681. .data = NULL,
  682. .maxlen = sizeof(int),
  683. .mode = 0644,
  684. .proc_handler = sysctl_max_threads,
  685. },
  686. {
  687. .procname = "random",
  688. .mode = 0555,
  689. .child = random_table,
  690. },
  691. {
  692. .procname = "usermodehelper",
  693. .mode = 0555,
  694. .child = usermodehelper_table,
  695. },
  696. {
  697. .procname = "overflowuid",
  698. .data = &overflowuid,
  699. .maxlen = sizeof(int),
  700. .mode = 0644,
  701. .proc_handler = proc_dointvec_minmax,
  702. .extra1 = &minolduid,
  703. .extra2 = &maxolduid,
  704. },
  705. {
  706. .procname = "overflowgid",
  707. .data = &overflowgid,
  708. .maxlen = sizeof(int),
  709. .mode = 0644,
  710. .proc_handler = proc_dointvec_minmax,
  711. .extra1 = &minolduid,
  712. .extra2 = &maxolduid,
  713. },
  714. #ifdef CONFIG_S390
  715. #ifdef CONFIG_MATHEMU
  716. {
  717. .procname = "ieee_emulation_warnings",
  718. .data = &sysctl_ieee_emulation_warnings,
  719. .maxlen = sizeof(int),
  720. .mode = 0644,
  721. .proc_handler = proc_dointvec,
  722. },
  723. #endif
  724. {
  725. .procname = "userprocess_debug",
  726. .data = &show_unhandled_signals,
  727. .maxlen = sizeof(int),
  728. .mode = 0644,
  729. .proc_handler = proc_dointvec,
  730. },
  731. #endif
  732. {
  733. .procname = "pid_max",
  734. .data = &pid_max,
  735. .maxlen = sizeof (int),
  736. .mode = 0644,
  737. .proc_handler = proc_dointvec_minmax,
  738. .extra1 = &pid_max_min,
  739. .extra2 = &pid_max_max,
  740. },
  741. {
  742. .procname = "panic_on_oops",
  743. .data = &panic_on_oops,
  744. .maxlen = sizeof(int),
  745. .mode = 0644,
  746. .proc_handler = proc_dointvec,
  747. },
  748. #if defined CONFIG_PRINTK
  749. {
  750. .procname = "printk",
  751. .data = &console_loglevel,
  752. .maxlen = 4*sizeof(int),
  753. .mode = 0644,
  754. .proc_handler = proc_dointvec,
  755. },
  756. {
  757. .procname = "printk_ratelimit",
  758. .data = &printk_ratelimit_state.interval,
  759. .maxlen = sizeof(int),
  760. .mode = 0644,
  761. .proc_handler = proc_dointvec_jiffies,
  762. },
  763. {
  764. .procname = "printk_ratelimit_burst",
  765. .data = &printk_ratelimit_state.burst,
  766. .maxlen = sizeof(int),
  767. .mode = 0644,
  768. .proc_handler = proc_dointvec,
  769. },
  770. {
  771. .procname = "printk_delay",
  772. .data = &printk_delay_msec,
  773. .maxlen = sizeof(int),
  774. .mode = 0644,
  775. .proc_handler = proc_dointvec_minmax,
  776. .extra1 = &zero,
  777. .extra2 = &ten_thousand,
  778. },
  779. {
  780. .procname = "printk_devkmsg",
  781. .data = devkmsg_log_str,
  782. .maxlen = DEVKMSG_STR_MAX_SIZE,
  783. .mode = 0644,
  784. .proc_handler = devkmsg_sysctl_set_loglvl,
  785. },
  786. {
  787. .procname = "dmesg_restrict",
  788. .data = &dmesg_restrict,
  789. .maxlen = sizeof(int),
  790. .mode = 0644,
  791. .proc_handler = proc_dointvec_minmax_sysadmin,
  792. .extra1 = &zero,
  793. .extra2 = &one,
  794. },
  795. {
  796. .procname = "kptr_restrict",
  797. .data = &kptr_restrict,
  798. .maxlen = sizeof(int),
  799. .mode = 0644,
  800. .proc_handler = proc_dointvec_minmax_sysadmin,
  801. .extra1 = &zero,
  802. .extra2 = &two,
  803. },
  804. #endif
  805. {
  806. .procname = "ngroups_max",
  807. .data = &ngroups_max,
  808. .maxlen = sizeof (int),
  809. .mode = 0444,
  810. .proc_handler = proc_dointvec,
  811. },
  812. {
  813. .procname = "cap_last_cap",
  814. .data = (void *)&cap_last_cap,
  815. .maxlen = sizeof(int),
  816. .mode = 0444,
  817. .proc_handler = proc_dointvec,
  818. },
  819. #if defined(CONFIG_LOCKUP_DETECTOR)
  820. {
  821. .procname = "watchdog",
  822. .data = &watchdog_user_enabled,
  823. .maxlen = sizeof (int),
  824. .mode = 0644,
  825. .proc_handler = proc_watchdog,
  826. .extra1 = &zero,
  827. .extra2 = &one,
  828. },
  829. {
  830. .procname = "watchdog_thresh",
  831. .data = &watchdog_thresh,
  832. .maxlen = sizeof(int),
  833. .mode = 0644,
  834. .proc_handler = proc_watchdog_thresh,
  835. .extra1 = &zero,
  836. .extra2 = &sixty,
  837. },
  838. {
  839. .procname = "nmi_watchdog",
  840. .data = &nmi_watchdog_enabled,
  841. .maxlen = sizeof (int),
  842. .mode = 0644,
  843. .proc_handler = proc_nmi_watchdog,
  844. .extra1 = &zero,
  845. #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
  846. .extra2 = &one,
  847. #else
  848. .extra2 = &zero,
  849. #endif
  850. },
  851. {
  852. .procname = "soft_watchdog",
  853. .data = &soft_watchdog_enabled,
  854. .maxlen = sizeof (int),
  855. .mode = 0644,
  856. .proc_handler = proc_soft_watchdog,
  857. .extra1 = &zero,
  858. .extra2 = &one,
  859. },
  860. {
  861. .procname = "watchdog_cpumask",
  862. .data = &watchdog_cpumask_bits,
  863. .maxlen = NR_CPUS,
  864. .mode = 0644,
  865. .proc_handler = proc_watchdog_cpumask,
  866. },
  867. {
  868. .procname = "softlockup_panic",
  869. .data = &softlockup_panic,
  870. .maxlen = sizeof(int),
  871. .mode = 0644,
  872. .proc_handler = proc_dointvec_minmax,
  873. .extra1 = &zero,
  874. .extra2 = &one,
  875. },
  876. #ifdef CONFIG_HARDLOCKUP_DETECTOR
  877. {
  878. .procname = "hardlockup_panic",
  879. .data = &hardlockup_panic,
  880. .maxlen = sizeof(int),
  881. .mode = 0644,
  882. .proc_handler = proc_dointvec_minmax,
  883. .extra1 = &zero,
  884. .extra2 = &one,
  885. },
  886. #endif
  887. #ifdef CONFIG_SMP
  888. {
  889. .procname = "softlockup_all_cpu_backtrace",
  890. .data = &sysctl_softlockup_all_cpu_backtrace,
  891. .maxlen = sizeof(int),
  892. .mode = 0644,
  893. .proc_handler = proc_dointvec_minmax,
  894. .extra1 = &zero,
  895. .extra2 = &one,
  896. },
  897. {
  898. .procname = "hardlockup_all_cpu_backtrace",
  899. .data = &sysctl_hardlockup_all_cpu_backtrace,
  900. .maxlen = sizeof(int),
  901. .mode = 0644,
  902. .proc_handler = proc_dointvec_minmax,
  903. .extra1 = &zero,
  904. .extra2 = &one,
  905. },
  906. #endif /* CONFIG_SMP */
  907. #endif
  908. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
  909. {
  910. .procname = "unknown_nmi_panic",
  911. .data = &unknown_nmi_panic,
  912. .maxlen = sizeof (int),
  913. .mode = 0644,
  914. .proc_handler = proc_dointvec,
  915. },
  916. #endif
  917. #if defined(CONFIG_X86)
  918. {
  919. .procname = "panic_on_unrecovered_nmi",
  920. .data = &panic_on_unrecovered_nmi,
  921. .maxlen = sizeof(int),
  922. .mode = 0644,
  923. .proc_handler = proc_dointvec,
  924. },
  925. {
  926. .procname = "panic_on_io_nmi",
  927. .data = &panic_on_io_nmi,
  928. .maxlen = sizeof(int),
  929. .mode = 0644,
  930. .proc_handler = proc_dointvec,
  931. },
  932. #ifdef CONFIG_DEBUG_STACKOVERFLOW
  933. {
  934. .procname = "panic_on_stackoverflow",
  935. .data = &sysctl_panic_on_stackoverflow,
  936. .maxlen = sizeof(int),
  937. .mode = 0644,
  938. .proc_handler = proc_dointvec,
  939. },
  940. #endif
  941. {
  942. .procname = "bootloader_type",
  943. .data = &bootloader_type,
  944. .maxlen = sizeof (int),
  945. .mode = 0444,
  946. .proc_handler = proc_dointvec,
  947. },
  948. {
  949. .procname = "bootloader_version",
  950. .data = &bootloader_version,
  951. .maxlen = sizeof (int),
  952. .mode = 0444,
  953. .proc_handler = proc_dointvec,
  954. },
  955. {
  956. .procname = "kstack_depth_to_print",
  957. .data = &kstack_depth_to_print,
  958. .maxlen = sizeof(int),
  959. .mode = 0644,
  960. .proc_handler = proc_dointvec,
  961. },
  962. {
  963. .procname = "io_delay_type",
  964. .data = &io_delay_type,
  965. .maxlen = sizeof(int),
  966. .mode = 0644,
  967. .proc_handler = proc_dointvec,
  968. },
  969. #endif
  970. #if defined(CONFIG_MMU)
  971. {
  972. .procname = "randomize_va_space",
  973. .data = &randomize_va_space,
  974. .maxlen = sizeof(int),
  975. .mode = 0644,
  976. .proc_handler = proc_dointvec,
  977. },
  978. #endif
  979. #if defined(CONFIG_S390) && defined(CONFIG_SMP)
  980. {
  981. .procname = "spin_retry",
  982. .data = &spin_retry,
  983. .maxlen = sizeof (int),
  984. .mode = 0644,
  985. .proc_handler = proc_dointvec,
  986. },
  987. #endif
  988. #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
  989. {
  990. .procname = "acpi_video_flags",
  991. .data = &acpi_realmode_flags,
  992. .maxlen = sizeof (unsigned long),
  993. .mode = 0644,
  994. .proc_handler = proc_doulongvec_minmax,
  995. },
  996. #endif
  997. #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
  998. {
  999. .procname = "ignore-unaligned-usertrap",
  1000. .data = &no_unaligned_warning,
  1001. .maxlen = sizeof (int),
  1002. .mode = 0644,
  1003. .proc_handler = proc_dointvec,
  1004. },
  1005. #endif
  1006. #ifdef CONFIG_IA64
  1007. {
  1008. .procname = "unaligned-dump-stack",
  1009. .data = &unaligned_dump_stack,
  1010. .maxlen = sizeof (int),
  1011. .mode = 0644,
  1012. .proc_handler = proc_dointvec,
  1013. },
  1014. #endif
  1015. #ifdef CONFIG_DETECT_HUNG_TASK
  1016. {
  1017. .procname = "hung_task_panic",
  1018. .data = &sysctl_hung_task_panic,
  1019. .maxlen = sizeof(int),
  1020. .mode = 0644,
  1021. .proc_handler = proc_dointvec_minmax,
  1022. .extra1 = &zero,
  1023. .extra2 = &one,
  1024. },
  1025. {
  1026. .procname = "hung_task_check_count",
  1027. .data = &sysctl_hung_task_check_count,
  1028. .maxlen = sizeof(int),
  1029. .mode = 0644,
  1030. .proc_handler = proc_dointvec_minmax,
  1031. .extra1 = &zero,
  1032. },
  1033. {
  1034. .procname = "hung_task_timeout_secs",
  1035. .data = &sysctl_hung_task_timeout_secs,
  1036. .maxlen = sizeof(unsigned long),
  1037. .mode = 0644,
  1038. .proc_handler = proc_dohung_task_timeout_secs,
  1039. .extra2 = &hung_task_timeout_max,
  1040. },
  1041. {
  1042. .procname = "hung_task_warnings",
  1043. .data = &sysctl_hung_task_warnings,
  1044. .maxlen = sizeof(int),
  1045. .mode = 0644,
  1046. .proc_handler = proc_dointvec_minmax,
  1047. .extra1 = &neg_one,
  1048. },
  1049. #endif
  1050. #ifdef CONFIG_RT_MUTEXES
  1051. {
  1052. .procname = "max_lock_depth",
  1053. .data = &max_lock_depth,
  1054. .maxlen = sizeof(int),
  1055. .mode = 0644,
  1056. .proc_handler = proc_dointvec,
  1057. },
  1058. #endif
  1059. {
  1060. .procname = "poweroff_cmd",
  1061. .data = &poweroff_cmd,
  1062. .maxlen = POWEROFF_CMD_PATH_LEN,
  1063. .mode = 0644,
  1064. .proc_handler = proc_dostring,
  1065. },
  1066. #ifdef CONFIG_KEYS
  1067. {
  1068. .procname = "keys",
  1069. .mode = 0555,
  1070. .child = key_sysctls,
  1071. },
  1072. #endif
  1073. #ifdef CONFIG_PERF_EVENTS
  1074. /*
  1075. * User-space scripts rely on the existence of this file
  1076. * as a feature check for perf_events being enabled.
  1077. *
  1078. * So it's an ABI, do not remove!
  1079. */
  1080. {
  1081. .procname = "perf_event_paranoid",
  1082. .data = &sysctl_perf_event_paranoid,
  1083. .maxlen = sizeof(sysctl_perf_event_paranoid),
  1084. .mode = 0644,
  1085. .proc_handler = proc_dointvec,
  1086. },
  1087. {
  1088. .procname = "perf_event_mlock_kb",
  1089. .data = &sysctl_perf_event_mlock,
  1090. .maxlen = sizeof(sysctl_perf_event_mlock),
  1091. .mode = 0644,
  1092. .proc_handler = proc_dointvec,
  1093. },
  1094. {
  1095. .procname = "perf_event_max_sample_rate",
  1096. .data = &sysctl_perf_event_sample_rate,
  1097. .maxlen = sizeof(sysctl_perf_event_sample_rate),
  1098. .mode = 0644,
  1099. .proc_handler = perf_proc_update_handler,
  1100. .extra1 = &one,
  1101. },
  1102. {
  1103. .procname = "perf_cpu_time_max_percent",
  1104. .data = &sysctl_perf_cpu_time_max_percent,
  1105. .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
  1106. .mode = 0644,
  1107. .proc_handler = perf_cpu_time_max_percent_handler,
  1108. .extra1 = &zero,
  1109. .extra2 = &one_hundred,
  1110. },
  1111. {
  1112. .procname = "perf_event_max_stack",
  1113. .data = &sysctl_perf_event_max_stack,
  1114. .maxlen = sizeof(sysctl_perf_event_max_stack),
  1115. .mode = 0644,
  1116. .proc_handler = perf_event_max_stack_handler,
  1117. .extra1 = &zero,
  1118. .extra2 = &six_hundred_forty_kb,
  1119. },
  1120. {
  1121. .procname = "perf_event_max_contexts_per_stack",
  1122. .data = &sysctl_perf_event_max_contexts_per_stack,
  1123. .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
  1124. .mode = 0644,
  1125. .proc_handler = perf_event_max_stack_handler,
  1126. .extra1 = &zero,
  1127. .extra2 = &one_thousand,
  1128. },
  1129. #endif
  1130. #ifdef CONFIG_KMEMCHECK
  1131. {
  1132. .procname = "kmemcheck",
  1133. .data = &kmemcheck_enabled,
  1134. .maxlen = sizeof(int),
  1135. .mode = 0644,
  1136. .proc_handler = proc_dointvec,
  1137. },
  1138. #endif
  1139. {
  1140. .procname = "panic_on_warn",
  1141. .data = &panic_on_warn,
  1142. .maxlen = sizeof(int),
  1143. .mode = 0644,
  1144. .proc_handler = proc_dointvec_minmax,
  1145. .extra1 = &zero,
  1146. .extra2 = &one,
  1147. },
  1148. #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
  1149. {
  1150. .procname = "timer_migration",
  1151. .data = &sysctl_timer_migration,
  1152. .maxlen = sizeof(unsigned int),
  1153. .mode = 0644,
  1154. .proc_handler = timer_migration_handler,
  1155. .extra1 = &zero,
  1156. .extra2 = &one,
  1157. },
  1158. #endif
  1159. #ifdef CONFIG_BPF_SYSCALL
  1160. {
  1161. .procname = "unprivileged_bpf_disabled",
  1162. .data = &sysctl_unprivileged_bpf_disabled,
  1163. .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
  1164. .mode = 0644,
  1165. /* only handle a transition from default "0" to "1" */
  1166. .proc_handler = proc_dointvec_minmax,
  1167. .extra1 = &one,
  1168. .extra2 = &one,
  1169. },
  1170. #endif
  1171. #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
  1172. {
  1173. .procname = "panic_on_rcu_stall",
  1174. .data = &sysctl_panic_on_rcu_stall,
  1175. .maxlen = sizeof(sysctl_panic_on_rcu_stall),
  1176. .mode = 0644,
  1177. .proc_handler = proc_dointvec_minmax,
  1178. .extra1 = &zero,
  1179. .extra2 = &one,
  1180. },
  1181. #endif
  1182. { }
  1183. };
  1184. static struct ctl_table vm_table[] = {
  1185. {
  1186. .procname = "overcommit_memory",
  1187. .data = &sysctl_overcommit_memory,
  1188. .maxlen = sizeof(sysctl_overcommit_memory),
  1189. .mode = 0644,
  1190. .proc_handler = proc_dointvec_minmax,
  1191. .extra1 = &zero,
  1192. .extra2 = &two,
  1193. },
  1194. {
  1195. .procname = "panic_on_oom",
  1196. .data = &sysctl_panic_on_oom,
  1197. .maxlen = sizeof(sysctl_panic_on_oom),
  1198. .mode = 0644,
  1199. .proc_handler = proc_dointvec_minmax,
  1200. .extra1 = &zero,
  1201. .extra2 = &two,
  1202. },
  1203. {
  1204. .procname = "oom_kill_allocating_task",
  1205. .data = &sysctl_oom_kill_allocating_task,
  1206. .maxlen = sizeof(sysctl_oom_kill_allocating_task),
  1207. .mode = 0644,
  1208. .proc_handler = proc_dointvec,
  1209. },
  1210. {
  1211. .procname = "oom_dump_tasks",
  1212. .data = &sysctl_oom_dump_tasks,
  1213. .maxlen = sizeof(sysctl_oom_dump_tasks),
  1214. .mode = 0644,
  1215. .proc_handler = proc_dointvec,
  1216. },
  1217. {
  1218. .procname = "overcommit_ratio",
  1219. .data = &sysctl_overcommit_ratio,
  1220. .maxlen = sizeof(sysctl_overcommit_ratio),
  1221. .mode = 0644,
  1222. .proc_handler = overcommit_ratio_handler,
  1223. },
  1224. {
  1225. .procname = "overcommit_kbytes",
  1226. .data = &sysctl_overcommit_kbytes,
  1227. .maxlen = sizeof(sysctl_overcommit_kbytes),
  1228. .mode = 0644,
  1229. .proc_handler = overcommit_kbytes_handler,
  1230. },
  1231. {
  1232. .procname = "page-cluster",
  1233. .data = &page_cluster,
  1234. .maxlen = sizeof(int),
  1235. .mode = 0644,
  1236. .proc_handler = proc_dointvec_minmax,
  1237. .extra1 = &zero,
  1238. },
  1239. {
  1240. .procname = "dirty_background_ratio",
  1241. .data = &dirty_background_ratio,
  1242. .maxlen = sizeof(dirty_background_ratio),
  1243. .mode = 0644,
  1244. .proc_handler = dirty_background_ratio_handler,
  1245. .extra1 = &zero,
  1246. .extra2 = &one_hundred,
  1247. },
  1248. {
  1249. .procname = "dirty_background_bytes",
  1250. .data = &dirty_background_bytes,
  1251. .maxlen = sizeof(dirty_background_bytes),
  1252. .mode = 0644,
  1253. .proc_handler = dirty_background_bytes_handler,
  1254. .extra1 = &one_ul,
  1255. },
  1256. {
  1257. .procname = "dirty_ratio",
  1258. .data = &vm_dirty_ratio,
  1259. .maxlen = sizeof(vm_dirty_ratio),
  1260. .mode = 0644,
  1261. .proc_handler = dirty_ratio_handler,
  1262. .extra1 = &zero,
  1263. .extra2 = &one_hundred,
  1264. },
  1265. {
  1266. .procname = "dirty_bytes",
  1267. .data = &vm_dirty_bytes,
  1268. .maxlen = sizeof(vm_dirty_bytes),
  1269. .mode = 0644,
  1270. .proc_handler = dirty_bytes_handler,
  1271. .extra1 = &dirty_bytes_min,
  1272. },
  1273. {
  1274. .procname = "dirty_writeback_centisecs",
  1275. .data = &dirty_writeback_interval,
  1276. .maxlen = sizeof(dirty_writeback_interval),
  1277. .mode = 0644,
  1278. .proc_handler = dirty_writeback_centisecs_handler,
  1279. },
  1280. {
  1281. .procname = "dirty_expire_centisecs",
  1282. .data = &dirty_expire_interval,
  1283. .maxlen = sizeof(dirty_expire_interval),
  1284. .mode = 0644,
  1285. .proc_handler = proc_dointvec_minmax,
  1286. .extra1 = &zero,
  1287. },
  1288. {
  1289. .procname = "dirtytime_expire_seconds",
  1290. .data = &dirtytime_expire_interval,
  1291. .maxlen = sizeof(dirty_expire_interval),
  1292. .mode = 0644,
  1293. .proc_handler = dirtytime_interval_handler,
  1294. .extra1 = &zero,
  1295. },
  1296. {
  1297. .procname = "nr_pdflush_threads",
  1298. .mode = 0444 /* read-only */,
  1299. .proc_handler = pdflush_proc_obsolete,
  1300. },
  1301. {
  1302. .procname = "swappiness",
  1303. .data = &vm_swappiness,
  1304. .maxlen = sizeof(vm_swappiness),
  1305. .mode = 0644,
  1306. .proc_handler = proc_dointvec_minmax,
  1307. .extra1 = &zero,
  1308. .extra2 = &one_hundred,
  1309. },
  1310. #ifdef CONFIG_HUGETLB_PAGE
  1311. {
  1312. .procname = "nr_hugepages",
  1313. .data = NULL,
  1314. .maxlen = sizeof(unsigned long),
  1315. .mode = 0644,
  1316. .proc_handler = hugetlb_sysctl_handler,
  1317. },
  1318. #ifdef CONFIG_NUMA
  1319. {
  1320. .procname = "nr_hugepages_mempolicy",
  1321. .data = NULL,
  1322. .maxlen = sizeof(unsigned long),
  1323. .mode = 0644,
  1324. .proc_handler = &hugetlb_mempolicy_sysctl_handler,
  1325. },
  1326. #endif
  1327. {
  1328. .procname = "hugetlb_shm_group",
  1329. .data = &sysctl_hugetlb_shm_group,
  1330. .maxlen = sizeof(gid_t),
  1331. .mode = 0644,
  1332. .proc_handler = proc_dointvec,
  1333. },
  1334. {
  1335. .procname = "hugepages_treat_as_movable",
  1336. .data = &hugepages_treat_as_movable,
  1337. .maxlen = sizeof(int),
  1338. .mode = 0644,
  1339. .proc_handler = proc_dointvec,
  1340. },
  1341. {
  1342. .procname = "nr_overcommit_hugepages",
  1343. .data = NULL,
  1344. .maxlen = sizeof(unsigned long),
  1345. .mode = 0644,
  1346. .proc_handler = hugetlb_overcommit_handler,
  1347. },
  1348. #endif
  1349. {
  1350. .procname = "lowmem_reserve_ratio",
  1351. .data = &sysctl_lowmem_reserve_ratio,
  1352. .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
  1353. .mode = 0644,
  1354. .proc_handler = lowmem_reserve_ratio_sysctl_handler,
  1355. },
  1356. {
  1357. .procname = "drop_caches",
  1358. .data = &sysctl_drop_caches,
  1359. .maxlen = sizeof(int),
  1360. .mode = 0644,
  1361. .proc_handler = drop_caches_sysctl_handler,
  1362. .extra1 = &one,
  1363. .extra2 = &four,
  1364. },
  1365. #ifdef CONFIG_COMPACTION
  1366. {
  1367. .procname = "compact_memory",
  1368. .data = &sysctl_compact_memory,
  1369. .maxlen = sizeof(int),
  1370. .mode = 0200,
  1371. .proc_handler = sysctl_compaction_handler,
  1372. },
  1373. {
  1374. .procname = "extfrag_threshold",
  1375. .data = &sysctl_extfrag_threshold,
  1376. .maxlen = sizeof(int),
  1377. .mode = 0644,
  1378. .proc_handler = sysctl_extfrag_handler,
  1379. .extra1 = &min_extfrag_threshold,
  1380. .extra2 = &max_extfrag_threshold,
  1381. },
  1382. {
  1383. .procname = "compact_unevictable_allowed",
  1384. .data = &sysctl_compact_unevictable_allowed,
  1385. .maxlen = sizeof(int),
  1386. .mode = 0644,
  1387. .proc_handler = proc_dointvec,
  1388. .extra1 = &zero,
  1389. .extra2 = &one,
  1390. },
  1391. #endif /* CONFIG_COMPACTION */
  1392. {
  1393. .procname = "min_free_kbytes",
  1394. .data = &min_free_kbytes,
  1395. .maxlen = sizeof(min_free_kbytes),
  1396. .mode = 0644,
  1397. .proc_handler = min_free_kbytes_sysctl_handler,
  1398. .extra1 = &zero,
  1399. },
  1400. {
  1401. .procname = "watermark_scale_factor",
  1402. .data = &watermark_scale_factor,
  1403. .maxlen = sizeof(watermark_scale_factor),
  1404. .mode = 0644,
  1405. .proc_handler = watermark_scale_factor_sysctl_handler,
  1406. .extra1 = &one,
  1407. .extra2 = &one_thousand,
  1408. },
  1409. {
  1410. .procname = "percpu_pagelist_fraction",
  1411. .data = &percpu_pagelist_fraction,
  1412. .maxlen = sizeof(percpu_pagelist_fraction),
  1413. .mode = 0644,
  1414. .proc_handler = percpu_pagelist_fraction_sysctl_handler,
  1415. .extra1 = &zero,
  1416. },
  1417. #ifdef CONFIG_MMU
  1418. {
  1419. .procname = "max_map_count",
  1420. .data = &sysctl_max_map_count,
  1421. .maxlen = sizeof(sysctl_max_map_count),
  1422. .mode = 0644,
  1423. .proc_handler = proc_dointvec_minmax,
  1424. .extra1 = &zero,
  1425. },
  1426. #else
  1427. {
  1428. .procname = "nr_trim_pages",
  1429. .data = &sysctl_nr_trim_pages,
  1430. .maxlen = sizeof(sysctl_nr_trim_pages),
  1431. .mode = 0644,
  1432. .proc_handler = proc_dointvec_minmax,
  1433. .extra1 = &zero,
  1434. },
  1435. #endif
  1436. {
  1437. .procname = "laptop_mode",
  1438. .data = &laptop_mode,
  1439. .maxlen = sizeof(laptop_mode),
  1440. .mode = 0644,
  1441. .proc_handler = proc_dointvec_jiffies,
  1442. },
  1443. {
  1444. .procname = "block_dump",
  1445. .data = &block_dump,
  1446. .maxlen = sizeof(block_dump),
  1447. .mode = 0644,
  1448. .proc_handler = proc_dointvec,
  1449. .extra1 = &zero,
  1450. },
  1451. {
  1452. .procname = "vfs_cache_pressure",
  1453. .data = &sysctl_vfs_cache_pressure,
  1454. .maxlen = sizeof(sysctl_vfs_cache_pressure),
  1455. .mode = 0644,
  1456. .proc_handler = proc_dointvec,
  1457. .extra1 = &zero,
  1458. },
  1459. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  1460. {
  1461. .procname = "legacy_va_layout",
  1462. .data = &sysctl_legacy_va_layout,
  1463. .maxlen = sizeof(sysctl_legacy_va_layout),
  1464. .mode = 0644,
  1465. .proc_handler = proc_dointvec,
  1466. .extra1 = &zero,
  1467. },
  1468. #endif
  1469. #ifdef CONFIG_NUMA
  1470. {
  1471. .procname = "zone_reclaim_mode",
  1472. .data = &node_reclaim_mode,
  1473. .maxlen = sizeof(node_reclaim_mode),
  1474. .mode = 0644,
  1475. .proc_handler = proc_dointvec,
  1476. .extra1 = &zero,
  1477. },
  1478. {
  1479. .procname = "min_unmapped_ratio",
  1480. .data = &sysctl_min_unmapped_ratio,
  1481. .maxlen = sizeof(sysctl_min_unmapped_ratio),
  1482. .mode = 0644,
  1483. .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
  1484. .extra1 = &zero,
  1485. .extra2 = &one_hundred,
  1486. },
  1487. {
  1488. .procname = "min_slab_ratio",
  1489. .data = &sysctl_min_slab_ratio,
  1490. .maxlen = sizeof(sysctl_min_slab_ratio),
  1491. .mode = 0644,
  1492. .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
  1493. .extra1 = &zero,
  1494. .extra2 = &one_hundred,
  1495. },
  1496. #endif
  1497. #ifdef CONFIG_SMP
  1498. {
  1499. .procname = "stat_interval",
  1500. .data = &sysctl_stat_interval,
  1501. .maxlen = sizeof(sysctl_stat_interval),
  1502. .mode = 0644,
  1503. .proc_handler = proc_dointvec_jiffies,
  1504. },
  1505. {
  1506. .procname = "stat_refresh",
  1507. .data = NULL,
  1508. .maxlen = 0,
  1509. .mode = 0600,
  1510. .proc_handler = vmstat_refresh,
  1511. },
  1512. #endif
  1513. #ifdef CONFIG_MMU
  1514. {
  1515. .procname = "mmap_min_addr",
  1516. .data = &dac_mmap_min_addr,
  1517. .maxlen = sizeof(unsigned long),
  1518. .mode = 0644,
  1519. .proc_handler = mmap_min_addr_handler,
  1520. },
  1521. #endif
  1522. #ifdef CONFIG_NUMA
  1523. {
  1524. .procname = "numa_zonelist_order",
  1525. .data = &numa_zonelist_order,
  1526. .maxlen = NUMA_ZONELIST_ORDER_LEN,
  1527. .mode = 0644,
  1528. .proc_handler = numa_zonelist_order_handler,
  1529. },
  1530. #endif
  1531. #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
  1532. (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
  1533. {
  1534. .procname = "vdso_enabled",
  1535. #ifdef CONFIG_X86_32
  1536. .data = &vdso32_enabled,
  1537. .maxlen = sizeof(vdso32_enabled),
  1538. #else
  1539. .data = &vdso_enabled,
  1540. .maxlen = sizeof(vdso_enabled),
  1541. #endif
  1542. .mode = 0644,
  1543. .proc_handler = proc_dointvec,
  1544. .extra1 = &zero,
  1545. },
  1546. #endif
  1547. #ifdef CONFIG_HIGHMEM
  1548. {
  1549. .procname = "highmem_is_dirtyable",
  1550. .data = &vm_highmem_is_dirtyable,
  1551. .maxlen = sizeof(vm_highmem_is_dirtyable),
  1552. .mode = 0644,
  1553. .proc_handler = proc_dointvec_minmax,
  1554. .extra1 = &zero,
  1555. .extra2 = &one,
  1556. },
  1557. #endif
  1558. #ifdef CONFIG_MEMORY_FAILURE
  1559. {
  1560. .procname = "memory_failure_early_kill",
  1561. .data = &sysctl_memory_failure_early_kill,
  1562. .maxlen = sizeof(sysctl_memory_failure_early_kill),
  1563. .mode = 0644,
  1564. .proc_handler = proc_dointvec_minmax,
  1565. .extra1 = &zero,
  1566. .extra2 = &one,
  1567. },
  1568. {
  1569. .procname = "memory_failure_recovery",
  1570. .data = &sysctl_memory_failure_recovery,
  1571. .maxlen = sizeof(sysctl_memory_failure_recovery),
  1572. .mode = 0644,
  1573. .proc_handler = proc_dointvec_minmax,
  1574. .extra1 = &zero,
  1575. .extra2 = &one,
  1576. },
  1577. #endif
  1578. {
  1579. .procname = "user_reserve_kbytes",
  1580. .data = &sysctl_user_reserve_kbytes,
  1581. .maxlen = sizeof(sysctl_user_reserve_kbytes),
  1582. .mode = 0644,
  1583. .proc_handler = proc_doulongvec_minmax,
  1584. },
  1585. {
  1586. .procname = "admin_reserve_kbytes",
  1587. .data = &sysctl_admin_reserve_kbytes,
  1588. .maxlen = sizeof(sysctl_admin_reserve_kbytes),
  1589. .mode = 0644,
  1590. .proc_handler = proc_doulongvec_minmax,
  1591. },
  1592. #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
  1593. {
  1594. .procname = "mmap_rnd_bits",
  1595. .data = &mmap_rnd_bits,
  1596. .maxlen = sizeof(mmap_rnd_bits),
  1597. .mode = 0600,
  1598. .proc_handler = proc_dointvec_minmax,
  1599. .extra1 = (void *)&mmap_rnd_bits_min,
  1600. .extra2 = (void *)&mmap_rnd_bits_max,
  1601. },
  1602. #endif
  1603. #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
  1604. {
  1605. .procname = "mmap_rnd_compat_bits",
  1606. .data = &mmap_rnd_compat_bits,
  1607. .maxlen = sizeof(mmap_rnd_compat_bits),
  1608. .mode = 0600,
  1609. .proc_handler = proc_dointvec_minmax,
  1610. .extra1 = (void *)&mmap_rnd_compat_bits_min,
  1611. .extra2 = (void *)&mmap_rnd_compat_bits_max,
  1612. },
  1613. #endif
  1614. { }
  1615. };
  1616. static struct ctl_table fs_table[] = {
  1617. {
  1618. .procname = "inode-nr",
  1619. .data = &inodes_stat,
  1620. .maxlen = 2*sizeof(long),
  1621. .mode = 0444,
  1622. .proc_handler = proc_nr_inodes,
  1623. },
  1624. {
  1625. .procname = "inode-state",
  1626. .data = &inodes_stat,
  1627. .maxlen = 7*sizeof(long),
  1628. .mode = 0444,
  1629. .proc_handler = proc_nr_inodes,
  1630. },
  1631. {
  1632. .procname = "file-nr",
  1633. .data = &files_stat,
  1634. .maxlen = sizeof(files_stat),
  1635. .mode = 0444,
  1636. .proc_handler = proc_nr_files,
  1637. },
  1638. {
  1639. .procname = "file-max",
  1640. .data = &files_stat.max_files,
  1641. .maxlen = sizeof(files_stat.max_files),
  1642. .mode = 0644,
  1643. .proc_handler = proc_doulongvec_minmax,
  1644. },
  1645. {
  1646. .procname = "nr_open",
  1647. .data = &sysctl_nr_open,
  1648. .maxlen = sizeof(unsigned int),
  1649. .mode = 0644,
  1650. .proc_handler = proc_dointvec_minmax,
  1651. .extra1 = &sysctl_nr_open_min,
  1652. .extra2 = &sysctl_nr_open_max,
  1653. },
  1654. {
  1655. .procname = "dentry-state",
  1656. .data = &dentry_stat,
  1657. .maxlen = 6*sizeof(long),
  1658. .mode = 0444,
  1659. .proc_handler = proc_nr_dentry,
  1660. },
  1661. {
  1662. .procname = "overflowuid",
  1663. .data = &fs_overflowuid,
  1664. .maxlen = sizeof(int),
  1665. .mode = 0644,
  1666. .proc_handler = proc_dointvec_minmax,
  1667. .extra1 = &minolduid,
  1668. .extra2 = &maxolduid,
  1669. },
  1670. {
  1671. .procname = "overflowgid",
  1672. .data = &fs_overflowgid,
  1673. .maxlen = sizeof(int),
  1674. .mode = 0644,
  1675. .proc_handler = proc_dointvec_minmax,
  1676. .extra1 = &minolduid,
  1677. .extra2 = &maxolduid,
  1678. },
  1679. #ifdef CONFIG_FILE_LOCKING
  1680. {
  1681. .procname = "leases-enable",
  1682. .data = &leases_enable,
  1683. .maxlen = sizeof(int),
  1684. .mode = 0644,
  1685. .proc_handler = proc_dointvec,
  1686. },
  1687. #endif
  1688. #ifdef CONFIG_DNOTIFY
  1689. {
  1690. .procname = "dir-notify-enable",
  1691. .data = &dir_notify_enable,
  1692. .maxlen = sizeof(int),
  1693. .mode = 0644,
  1694. .proc_handler = proc_dointvec,
  1695. },
  1696. #endif
  1697. #ifdef CONFIG_MMU
  1698. #ifdef CONFIG_FILE_LOCKING
  1699. {
  1700. .procname = "lease-break-time",
  1701. .data = &lease_break_time,
  1702. .maxlen = sizeof(int),
  1703. .mode = 0644,
  1704. .proc_handler = proc_dointvec,
  1705. },
  1706. #endif
  1707. #ifdef CONFIG_AIO
  1708. {
  1709. .procname = "aio-nr",
  1710. .data = &aio_nr,
  1711. .maxlen = sizeof(aio_nr),
  1712. .mode = 0444,
  1713. .proc_handler = proc_doulongvec_minmax,
  1714. },
  1715. {
  1716. .procname = "aio-max-nr",
  1717. .data = &aio_max_nr,
  1718. .maxlen = sizeof(aio_max_nr),
  1719. .mode = 0644,
  1720. .proc_handler = proc_doulongvec_minmax,
  1721. },
  1722. #endif /* CONFIG_AIO */
  1723. #ifdef CONFIG_INOTIFY_USER
  1724. {
  1725. .procname = "inotify",
  1726. .mode = 0555,
  1727. .child = inotify_table,
  1728. },
  1729. #endif
  1730. #ifdef CONFIG_EPOLL
  1731. {
  1732. .procname = "epoll",
  1733. .mode = 0555,
  1734. .child = epoll_table,
  1735. },
  1736. #endif
  1737. #endif
  1738. {
  1739. .procname = "protected_symlinks",
  1740. .data = &sysctl_protected_symlinks,
  1741. .maxlen = sizeof(int),
  1742. .mode = 0600,
  1743. .proc_handler = proc_dointvec_minmax,
  1744. .extra1 = &zero,
  1745. .extra2 = &one,
  1746. },
  1747. {
  1748. .procname = "protected_hardlinks",
  1749. .data = &sysctl_protected_hardlinks,
  1750. .maxlen = sizeof(int),
  1751. .mode = 0600,
  1752. .proc_handler = proc_dointvec_minmax,
  1753. .extra1 = &zero,
  1754. .extra2 = &one,
  1755. },
  1756. {
  1757. .procname = "suid_dumpable",
  1758. .data = &suid_dumpable,
  1759. .maxlen = sizeof(int),
  1760. .mode = 0644,
  1761. .proc_handler = proc_dointvec_minmax_coredump,
  1762. .extra1 = &zero,
  1763. .extra2 = &two,
  1764. },
  1765. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1766. {
  1767. .procname = "binfmt_misc",
  1768. .mode = 0555,
  1769. .child = sysctl_mount_point,
  1770. },
  1771. #endif
  1772. {
  1773. .procname = "pipe-max-size",
  1774. .data = &pipe_max_size,
  1775. .maxlen = sizeof(int),
  1776. .mode = 0644,
  1777. .proc_handler = &pipe_proc_fn,
  1778. .extra1 = &pipe_min_size,
  1779. },
  1780. {
  1781. .procname = "pipe-user-pages-hard",
  1782. .data = &pipe_user_pages_hard,
  1783. .maxlen = sizeof(pipe_user_pages_hard),
  1784. .mode = 0644,
  1785. .proc_handler = proc_doulongvec_minmax,
  1786. },
  1787. {
  1788. .procname = "pipe-user-pages-soft",
  1789. .data = &pipe_user_pages_soft,
  1790. .maxlen = sizeof(pipe_user_pages_soft),
  1791. .mode = 0644,
  1792. .proc_handler = proc_doulongvec_minmax,
  1793. },
  1794. {
  1795. .procname = "mount-max",
  1796. .data = &sysctl_mount_max,
  1797. .maxlen = sizeof(unsigned int),
  1798. .mode = 0644,
  1799. .proc_handler = proc_dointvec_minmax,
  1800. .extra1 = &one,
  1801. },
  1802. { }
  1803. };
  1804. static struct ctl_table debug_table[] = {
  1805. #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
  1806. {
  1807. .procname = "exception-trace",
  1808. .data = &show_unhandled_signals,
  1809. .maxlen = sizeof(int),
  1810. .mode = 0644,
  1811. .proc_handler = proc_dointvec
  1812. },
  1813. #endif
  1814. #if defined(CONFIG_OPTPROBES)
  1815. {
  1816. .procname = "kprobes-optimization",
  1817. .data = &sysctl_kprobes_optimization,
  1818. .maxlen = sizeof(int),
  1819. .mode = 0644,
  1820. .proc_handler = proc_kprobes_optimization_handler,
  1821. .extra1 = &zero,
  1822. .extra2 = &one,
  1823. },
  1824. #endif
  1825. { }
  1826. };
  1827. static struct ctl_table dev_table[] = {
  1828. { }
  1829. };
  1830. int __init sysctl_init(void)
  1831. {
  1832. struct ctl_table_header *hdr;
  1833. hdr = register_sysctl_table(sysctl_base_table);
  1834. kmemleak_not_leak(hdr);
  1835. return 0;
  1836. }
  1837. #endif /* CONFIG_SYSCTL */
  1838. /*
  1839. * /proc/sys support
  1840. */
  1841. #ifdef CONFIG_PROC_SYSCTL
  1842. static int _proc_do_string(char *data, int maxlen, int write,
  1843. char __user *buffer,
  1844. size_t *lenp, loff_t *ppos)
  1845. {
  1846. size_t len;
  1847. char __user *p;
  1848. char c;
  1849. if (!data || !maxlen || !*lenp) {
  1850. *lenp = 0;
  1851. return 0;
  1852. }
  1853. if (write) {
  1854. if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
  1855. /* Only continue writes not past the end of buffer. */
  1856. len = strlen(data);
  1857. if (len > maxlen - 1)
  1858. len = maxlen - 1;
  1859. if (*ppos > len)
  1860. return 0;
  1861. len = *ppos;
  1862. } else {
  1863. /* Start writing from beginning of buffer. */
  1864. len = 0;
  1865. }
  1866. *ppos += *lenp;
  1867. p = buffer;
  1868. while ((p - buffer) < *lenp && len < maxlen - 1) {
  1869. if (get_user(c, p++))
  1870. return -EFAULT;
  1871. if (c == 0 || c == '\n')
  1872. break;
  1873. data[len++] = c;
  1874. }
  1875. data[len] = 0;
  1876. } else {
  1877. len = strlen(data);
  1878. if (len > maxlen)
  1879. len = maxlen;
  1880. if (*ppos > len) {
  1881. *lenp = 0;
  1882. return 0;
  1883. }
  1884. data += *ppos;
  1885. len -= *ppos;
  1886. if (len > *lenp)
  1887. len = *lenp;
  1888. if (len)
  1889. if (copy_to_user(buffer, data, len))
  1890. return -EFAULT;
  1891. if (len < *lenp) {
  1892. if (put_user('\n', buffer + len))
  1893. return -EFAULT;
  1894. len++;
  1895. }
  1896. *lenp = len;
  1897. *ppos += len;
  1898. }
  1899. return 0;
  1900. }
  1901. static void warn_sysctl_write(struct ctl_table *table)
  1902. {
  1903. pr_warn_once("%s wrote to %s when file position was not 0!\n"
  1904. "This will not be supported in the future. To silence this\n"
  1905. "warning, set kernel.sysctl_writes_strict = -1\n",
  1906. current->comm, table->procname);
  1907. }
  1908. /**
  1909. * proc_dostring - read a string sysctl
  1910. * @table: the sysctl table
  1911. * @write: %TRUE if this is a write to the sysctl file
  1912. * @buffer: the user buffer
  1913. * @lenp: the size of the user buffer
  1914. * @ppos: file position
  1915. *
  1916. * Reads/writes a string from/to the user buffer. If the kernel
  1917. * buffer provided is not large enough to hold the string, the
  1918. * string is truncated. The copied string is %NULL-terminated.
  1919. * If the string is being read by the user process, it is copied
  1920. * and a newline '\n' is added. It is truncated if the buffer is
  1921. * not large enough.
  1922. *
  1923. * Returns 0 on success.
  1924. */
  1925. int proc_dostring(struct ctl_table *table, int write,
  1926. void __user *buffer, size_t *lenp, loff_t *ppos)
  1927. {
  1928. if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
  1929. warn_sysctl_write(table);
  1930. return _proc_do_string((char *)(table->data), table->maxlen, write,
  1931. (char __user *)buffer, lenp, ppos);
  1932. }
  1933. static size_t proc_skip_spaces(char **buf)
  1934. {
  1935. size_t ret;
  1936. char *tmp = skip_spaces(*buf);
  1937. ret = tmp - *buf;
  1938. *buf = tmp;
  1939. return ret;
  1940. }
  1941. static void proc_skip_char(char **buf, size_t *size, const char v)
  1942. {
  1943. while (*size) {
  1944. if (**buf != v)
  1945. break;
  1946. (*size)--;
  1947. (*buf)++;
  1948. }
  1949. }
  1950. #define TMPBUFLEN 22
  1951. /**
  1952. * proc_get_long - reads an ASCII formatted integer from a user buffer
  1953. *
  1954. * @buf: a kernel buffer
  1955. * @size: size of the kernel buffer
  1956. * @val: this is where the number will be stored
  1957. * @neg: set to %TRUE if number is negative
  1958. * @perm_tr: a vector which contains the allowed trailers
  1959. * @perm_tr_len: size of the perm_tr vector
  1960. * @tr: pointer to store the trailer character
  1961. *
  1962. * In case of success %0 is returned and @buf and @size are updated with
  1963. * the amount of bytes read. If @tr is non-NULL and a trailing
  1964. * character exists (size is non-zero after returning from this
  1965. * function), @tr is updated with the trailing character.
  1966. */
  1967. static int proc_get_long(char **buf, size_t *size,
  1968. unsigned long *val, bool *neg,
  1969. const char *perm_tr, unsigned perm_tr_len, char *tr)
  1970. {
  1971. int len;
  1972. char *p, tmp[TMPBUFLEN];
  1973. if (!*size)
  1974. return -EINVAL;
  1975. len = *size;
  1976. if (len > TMPBUFLEN - 1)
  1977. len = TMPBUFLEN - 1;
  1978. memcpy(tmp, *buf, len);
  1979. tmp[len] = 0;
  1980. p = tmp;
  1981. if (*p == '-' && *size > 1) {
  1982. *neg = true;
  1983. p++;
  1984. } else
  1985. *neg = false;
  1986. if (!isdigit(*p))
  1987. return -EINVAL;
  1988. *val = simple_strtoul(p, &p, 0);
  1989. len = p - tmp;
  1990. /* We don't know if the next char is whitespace thus we may accept
  1991. * invalid integers (e.g. 1234...a) or two integers instead of one
  1992. * (e.g. 123...1). So lets not allow such large numbers. */
  1993. if (len == TMPBUFLEN - 1)
  1994. return -EINVAL;
  1995. if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
  1996. return -EINVAL;
  1997. if (tr && (len < *size))
  1998. *tr = *p;
  1999. *buf += len;
  2000. *size -= len;
  2001. return 0;
  2002. }
  2003. /**
  2004. * proc_put_long - converts an integer to a decimal ASCII formatted string
  2005. *
  2006. * @buf: the user buffer
  2007. * @size: the size of the user buffer
  2008. * @val: the integer to be converted
  2009. * @neg: sign of the number, %TRUE for negative
  2010. *
  2011. * In case of success %0 is returned and @buf and @size are updated with
  2012. * the amount of bytes written.
  2013. */
  2014. static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
  2015. bool neg)
  2016. {
  2017. int len;
  2018. char tmp[TMPBUFLEN], *p = tmp;
  2019. sprintf(p, "%s%lu", neg ? "-" : "", val);
  2020. len = strlen(tmp);
  2021. if (len > *size)
  2022. len = *size;
  2023. if (copy_to_user(*buf, tmp, len))
  2024. return -EFAULT;
  2025. *size -= len;
  2026. *buf += len;
  2027. return 0;
  2028. }
  2029. #undef TMPBUFLEN
  2030. static int proc_put_char(void __user **buf, size_t *size, char c)
  2031. {
  2032. if (*size) {
  2033. char __user **buffer = (char __user **)buf;
  2034. if (put_user(c, *buffer))
  2035. return -EFAULT;
  2036. (*size)--, (*buffer)++;
  2037. *buf = *buffer;
  2038. }
  2039. return 0;
  2040. }
  2041. static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
  2042. int *valp,
  2043. int write, void *data)
  2044. {
  2045. if (write) {
  2046. if (*negp) {
  2047. if (*lvalp > (unsigned long) INT_MAX + 1)
  2048. return -EINVAL;
  2049. *valp = -*lvalp;
  2050. } else {
  2051. if (*lvalp > (unsigned long) INT_MAX)
  2052. return -EINVAL;
  2053. *valp = *lvalp;
  2054. }
  2055. } else {
  2056. int val = *valp;
  2057. if (val < 0) {
  2058. *negp = true;
  2059. *lvalp = -(unsigned long)val;
  2060. } else {
  2061. *negp = false;
  2062. *lvalp = (unsigned long)val;
  2063. }
  2064. }
  2065. return 0;
  2066. }
  2067. static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
  2068. int *valp,
  2069. int write, void *data)
  2070. {
  2071. if (write) {
  2072. if (*negp)
  2073. return -EINVAL;
  2074. if (*lvalp > UINT_MAX)
  2075. return -EINVAL;
  2076. *valp = *lvalp;
  2077. } else {
  2078. unsigned int val = *valp;
  2079. *negp = false;
  2080. *lvalp = (unsigned long)val;
  2081. }
  2082. return 0;
  2083. }
  2084. static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
  2085. static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
  2086. int write, void __user *buffer,
  2087. size_t *lenp, loff_t *ppos,
  2088. int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
  2089. int write, void *data),
  2090. void *data)
  2091. {
  2092. int *i, vleft, first = 1, err = 0;
  2093. size_t left;
  2094. char *kbuf = NULL, *p;
  2095. if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
  2096. *lenp = 0;
  2097. return 0;
  2098. }
  2099. i = (int *) tbl_data;
  2100. vleft = table->maxlen / sizeof(*i);
  2101. left = *lenp;
  2102. if (!conv)
  2103. conv = do_proc_dointvec_conv;
  2104. if (write) {
  2105. if (*ppos) {
  2106. switch (sysctl_writes_strict) {
  2107. case SYSCTL_WRITES_STRICT:
  2108. goto out;
  2109. case SYSCTL_WRITES_WARN:
  2110. warn_sysctl_write(table);
  2111. break;
  2112. default:
  2113. break;
  2114. }
  2115. }
  2116. if (left > PAGE_SIZE - 1)
  2117. left = PAGE_SIZE - 1;
  2118. p = kbuf = memdup_user_nul(buffer, left);
  2119. if (IS_ERR(kbuf))
  2120. return PTR_ERR(kbuf);
  2121. }
  2122. for (; left && vleft--; i++, first=0) {
  2123. unsigned long lval;
  2124. bool neg;
  2125. if (write) {
  2126. left -= proc_skip_spaces(&p);
  2127. if (!left)
  2128. break;
  2129. err = proc_get_long(&p, &left, &lval, &neg,
  2130. proc_wspace_sep,
  2131. sizeof(proc_wspace_sep), NULL);
  2132. if (err)
  2133. break;
  2134. if (conv(&neg, &lval, i, 1, data)) {
  2135. err = -EINVAL;
  2136. break;
  2137. }
  2138. } else {
  2139. if (conv(&neg, &lval, i, 0, data)) {
  2140. err = -EINVAL;
  2141. break;
  2142. }
  2143. if (!first)
  2144. err = proc_put_char(&buffer, &left, '\t');
  2145. if (err)
  2146. break;
  2147. err = proc_put_long(&buffer, &left, lval, neg);
  2148. if (err)
  2149. break;
  2150. }
  2151. }
  2152. if (!write && !first && left && !err)
  2153. err = proc_put_char(&buffer, &left, '\n');
  2154. if (write && !err && left)
  2155. left -= proc_skip_spaces(&p);
  2156. if (write) {
  2157. kfree(kbuf);
  2158. if (first)
  2159. return err ? : -EINVAL;
  2160. }
  2161. *lenp -= left;
  2162. out:
  2163. *ppos += *lenp;
  2164. return err;
  2165. }
  2166. static int do_proc_dointvec(struct ctl_table *table, int write,
  2167. void __user *buffer, size_t *lenp, loff_t *ppos,
  2168. int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
  2169. int write, void *data),
  2170. void *data)
  2171. {
  2172. return __do_proc_dointvec(table->data, table, write,
  2173. buffer, lenp, ppos, conv, data);
  2174. }
  2175. /**
  2176. * proc_dointvec - read a vector of integers
  2177. * @table: the sysctl table
  2178. * @write: %TRUE if this is a write to the sysctl file
  2179. * @buffer: the user buffer
  2180. * @lenp: the size of the user buffer
  2181. * @ppos: file position
  2182. *
  2183. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2184. * values from/to the user buffer, treated as an ASCII string.
  2185. *
  2186. * Returns 0 on success.
  2187. */
  2188. int proc_dointvec(struct ctl_table *table, int write,
  2189. void __user *buffer, size_t *lenp, loff_t *ppos)
  2190. {
  2191. return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
  2192. }
  2193. /**
  2194. * proc_douintvec - read a vector of unsigned integers
  2195. * @table: the sysctl table
  2196. * @write: %TRUE if this is a write to the sysctl file
  2197. * @buffer: the user buffer
  2198. * @lenp: the size of the user buffer
  2199. * @ppos: file position
  2200. *
  2201. * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
  2202. * values from/to the user buffer, treated as an ASCII string.
  2203. *
  2204. * Returns 0 on success.
  2205. */
  2206. int proc_douintvec(struct ctl_table *table, int write,
  2207. void __user *buffer, size_t *lenp, loff_t *ppos)
  2208. {
  2209. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2210. do_proc_douintvec_conv, NULL);
  2211. }
  2212. /*
  2213. * Taint values can only be increased
  2214. * This means we can safely use a temporary.
  2215. */
  2216. static int proc_taint(struct ctl_table *table, int write,
  2217. void __user *buffer, size_t *lenp, loff_t *ppos)
  2218. {
  2219. struct ctl_table t;
  2220. unsigned long tmptaint = get_taint();
  2221. int err;
  2222. if (write && !capable(CAP_SYS_ADMIN))
  2223. return -EPERM;
  2224. t = *table;
  2225. t.data = &tmptaint;
  2226. err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
  2227. if (err < 0)
  2228. return err;
  2229. if (write) {
  2230. /*
  2231. * Poor man's atomic or. Not worth adding a primitive
  2232. * to everyone's atomic.h for this
  2233. */
  2234. int i;
  2235. for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
  2236. if ((tmptaint >> i) & 1)
  2237. add_taint(i, LOCKDEP_STILL_OK);
  2238. }
  2239. }
  2240. return err;
  2241. }
  2242. #ifdef CONFIG_PRINTK
  2243. static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
  2244. void __user *buffer, size_t *lenp, loff_t *ppos)
  2245. {
  2246. if (write && !capable(CAP_SYS_ADMIN))
  2247. return -EPERM;
  2248. return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  2249. }
  2250. #endif
  2251. struct do_proc_dointvec_minmax_conv_param {
  2252. int *min;
  2253. int *max;
  2254. };
  2255. static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
  2256. int *valp,
  2257. int write, void *data)
  2258. {
  2259. struct do_proc_dointvec_minmax_conv_param *param = data;
  2260. if (write) {
  2261. int val = *negp ? -*lvalp : *lvalp;
  2262. if ((param->min && *param->min > val) ||
  2263. (param->max && *param->max < val))
  2264. return -EINVAL;
  2265. *valp = val;
  2266. } else {
  2267. int val = *valp;
  2268. if (val < 0) {
  2269. *negp = true;
  2270. *lvalp = -(unsigned long)val;
  2271. } else {
  2272. *negp = false;
  2273. *lvalp = (unsigned long)val;
  2274. }
  2275. }
  2276. return 0;
  2277. }
  2278. /**
  2279. * proc_dointvec_minmax - read a vector of integers with min/max values
  2280. * @table: the sysctl table
  2281. * @write: %TRUE if this is a write to the sysctl file
  2282. * @buffer: the user buffer
  2283. * @lenp: the size of the user buffer
  2284. * @ppos: file position
  2285. *
  2286. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2287. * values from/to the user buffer, treated as an ASCII string.
  2288. *
  2289. * This routine will ensure the values are within the range specified by
  2290. * table->extra1 (min) and table->extra2 (max).
  2291. *
  2292. * Returns 0 on success.
  2293. */
  2294. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2295. void __user *buffer, size_t *lenp, loff_t *ppos)
  2296. {
  2297. struct do_proc_dointvec_minmax_conv_param param = {
  2298. .min = (int *) table->extra1,
  2299. .max = (int *) table->extra2,
  2300. };
  2301. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2302. do_proc_dointvec_minmax_conv, &param);
  2303. }
  2304. static void validate_coredump_safety(void)
  2305. {
  2306. #ifdef CONFIG_COREDUMP
  2307. if (suid_dumpable == SUID_DUMP_ROOT &&
  2308. core_pattern[0] != '/' && core_pattern[0] != '|') {
  2309. printk(KERN_WARNING "Unsafe core_pattern used with "\
  2310. "suid_dumpable=2. Pipe handler or fully qualified "\
  2311. "core dump path required.\n");
  2312. }
  2313. #endif
  2314. }
  2315. static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
  2316. void __user *buffer, size_t *lenp, loff_t *ppos)
  2317. {
  2318. int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  2319. if (!error)
  2320. validate_coredump_safety();
  2321. return error;
  2322. }
  2323. #ifdef CONFIG_COREDUMP
  2324. static int proc_dostring_coredump(struct ctl_table *table, int write,
  2325. void __user *buffer, size_t *lenp, loff_t *ppos)
  2326. {
  2327. int error = proc_dostring(table, write, buffer, lenp, ppos);
  2328. if (!error)
  2329. validate_coredump_safety();
  2330. return error;
  2331. }
  2332. #endif
  2333. static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
  2334. void __user *buffer,
  2335. size_t *lenp, loff_t *ppos,
  2336. unsigned long convmul,
  2337. unsigned long convdiv)
  2338. {
  2339. unsigned long *i, *min, *max;
  2340. int vleft, first = 1, err = 0;
  2341. size_t left;
  2342. char *kbuf = NULL, *p;
  2343. if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
  2344. *lenp = 0;
  2345. return 0;
  2346. }
  2347. i = (unsigned long *) data;
  2348. min = (unsigned long *) table->extra1;
  2349. max = (unsigned long *) table->extra2;
  2350. vleft = table->maxlen / sizeof(unsigned long);
  2351. left = *lenp;
  2352. if (write) {
  2353. if (*ppos) {
  2354. switch (sysctl_writes_strict) {
  2355. case SYSCTL_WRITES_STRICT:
  2356. goto out;
  2357. case SYSCTL_WRITES_WARN:
  2358. warn_sysctl_write(table);
  2359. break;
  2360. default:
  2361. break;
  2362. }
  2363. }
  2364. if (left > PAGE_SIZE - 1)
  2365. left = PAGE_SIZE - 1;
  2366. p = kbuf = memdup_user_nul(buffer, left);
  2367. if (IS_ERR(kbuf))
  2368. return PTR_ERR(kbuf);
  2369. }
  2370. for (; left && vleft--; i++, first = 0) {
  2371. unsigned long val;
  2372. if (write) {
  2373. bool neg;
  2374. left -= proc_skip_spaces(&p);
  2375. err = proc_get_long(&p, &left, &val, &neg,
  2376. proc_wspace_sep,
  2377. sizeof(proc_wspace_sep), NULL);
  2378. if (err)
  2379. break;
  2380. if (neg)
  2381. continue;
  2382. val = convmul * val / convdiv;
  2383. if ((min && val < *min) || (max && val > *max))
  2384. continue;
  2385. *i = val;
  2386. } else {
  2387. val = convdiv * (*i) / convmul;
  2388. if (!first) {
  2389. err = proc_put_char(&buffer, &left, '\t');
  2390. if (err)
  2391. break;
  2392. }
  2393. err = proc_put_long(&buffer, &left, val, false);
  2394. if (err)
  2395. break;
  2396. }
  2397. }
  2398. if (!write && !first && left && !err)
  2399. err = proc_put_char(&buffer, &left, '\n');
  2400. if (write && !err)
  2401. left -= proc_skip_spaces(&p);
  2402. if (write) {
  2403. kfree(kbuf);
  2404. if (first)
  2405. return err ? : -EINVAL;
  2406. }
  2407. *lenp -= left;
  2408. out:
  2409. *ppos += *lenp;
  2410. return err;
  2411. }
  2412. static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
  2413. void __user *buffer,
  2414. size_t *lenp, loff_t *ppos,
  2415. unsigned long convmul,
  2416. unsigned long convdiv)
  2417. {
  2418. return __do_proc_doulongvec_minmax(table->data, table, write,
  2419. buffer, lenp, ppos, convmul, convdiv);
  2420. }
  2421. /**
  2422. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  2423. * @table: the sysctl table
  2424. * @write: %TRUE if this is a write to the sysctl file
  2425. * @buffer: the user buffer
  2426. * @lenp: the size of the user buffer
  2427. * @ppos: file position
  2428. *
  2429. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2430. * values from/to the user buffer, treated as an ASCII string.
  2431. *
  2432. * This routine will ensure the values are within the range specified by
  2433. * table->extra1 (min) and table->extra2 (max).
  2434. *
  2435. * Returns 0 on success.
  2436. */
  2437. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2438. void __user *buffer, size_t *lenp, loff_t *ppos)
  2439. {
  2440. return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
  2441. }
  2442. /**
  2443. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  2444. * @table: the sysctl table
  2445. * @write: %TRUE if this is a write to the sysctl file
  2446. * @buffer: the user buffer
  2447. * @lenp: the size of the user buffer
  2448. * @ppos: file position
  2449. *
  2450. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2451. * values from/to the user buffer, treated as an ASCII string. The values
  2452. * are treated as milliseconds, and converted to jiffies when they are stored.
  2453. *
  2454. * This routine will ensure the values are within the range specified by
  2455. * table->extra1 (min) and table->extra2 (max).
  2456. *
  2457. * Returns 0 on success.
  2458. */
  2459. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2460. void __user *buffer,
  2461. size_t *lenp, loff_t *ppos)
  2462. {
  2463. return do_proc_doulongvec_minmax(table, write, buffer,
  2464. lenp, ppos, HZ, 1000l);
  2465. }
  2466. static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
  2467. int *valp,
  2468. int write, void *data)
  2469. {
  2470. if (write) {
  2471. if (*lvalp > LONG_MAX / HZ)
  2472. return 1;
  2473. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2474. } else {
  2475. int val = *valp;
  2476. unsigned long lval;
  2477. if (val < 0) {
  2478. *negp = true;
  2479. lval = -(unsigned long)val;
  2480. } else {
  2481. *negp = false;
  2482. lval = (unsigned long)val;
  2483. }
  2484. *lvalp = lval / HZ;
  2485. }
  2486. return 0;
  2487. }
  2488. static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
  2489. int *valp,
  2490. int write, void *data)
  2491. {
  2492. if (write) {
  2493. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2494. return 1;
  2495. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2496. } else {
  2497. int val = *valp;
  2498. unsigned long lval;
  2499. if (val < 0) {
  2500. *negp = true;
  2501. lval = -(unsigned long)val;
  2502. } else {
  2503. *negp = false;
  2504. lval = (unsigned long)val;
  2505. }
  2506. *lvalp = jiffies_to_clock_t(lval);
  2507. }
  2508. return 0;
  2509. }
  2510. static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
  2511. int *valp,
  2512. int write, void *data)
  2513. {
  2514. if (write) {
  2515. unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2516. if (jif > INT_MAX)
  2517. return 1;
  2518. *valp = (int)jif;
  2519. } else {
  2520. int val = *valp;
  2521. unsigned long lval;
  2522. if (val < 0) {
  2523. *negp = true;
  2524. lval = -(unsigned long)val;
  2525. } else {
  2526. *negp = false;
  2527. lval = (unsigned long)val;
  2528. }
  2529. *lvalp = jiffies_to_msecs(lval);
  2530. }
  2531. return 0;
  2532. }
  2533. /**
  2534. * proc_dointvec_jiffies - read a vector of integers as seconds
  2535. * @table: the sysctl table
  2536. * @write: %TRUE if this is a write to the sysctl file
  2537. * @buffer: the user buffer
  2538. * @lenp: the size of the user buffer
  2539. * @ppos: file position
  2540. *
  2541. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2542. * values from/to the user buffer, treated as an ASCII string.
  2543. * The values read are assumed to be in seconds, and are converted into
  2544. * jiffies.
  2545. *
  2546. * Returns 0 on success.
  2547. */
  2548. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2549. void __user *buffer, size_t *lenp, loff_t *ppos)
  2550. {
  2551. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2552. do_proc_dointvec_jiffies_conv,NULL);
  2553. }
  2554. /**
  2555. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2556. * @table: the sysctl table
  2557. * @write: %TRUE if this is a write to the sysctl file
  2558. * @buffer: the user buffer
  2559. * @lenp: the size of the user buffer
  2560. * @ppos: pointer to the file position
  2561. *
  2562. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2563. * values from/to the user buffer, treated as an ASCII string.
  2564. * The values read are assumed to be in 1/USER_HZ seconds, and
  2565. * are converted into jiffies.
  2566. *
  2567. * Returns 0 on success.
  2568. */
  2569. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2570. void __user *buffer, size_t *lenp, loff_t *ppos)
  2571. {
  2572. return do_proc_dointvec(table,write,buffer,lenp,ppos,
  2573. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2574. }
  2575. /**
  2576. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2577. * @table: the sysctl table
  2578. * @write: %TRUE if this is a write to the sysctl file
  2579. * @buffer: the user buffer
  2580. * @lenp: the size of the user buffer
  2581. * @ppos: file position
  2582. * @ppos: the current position in the file
  2583. *
  2584. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2585. * values from/to the user buffer, treated as an ASCII string.
  2586. * The values read are assumed to be in 1/1000 seconds, and
  2587. * are converted into jiffies.
  2588. *
  2589. * Returns 0 on success.
  2590. */
  2591. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2592. void __user *buffer, size_t *lenp, loff_t *ppos)
  2593. {
  2594. return do_proc_dointvec(table, write, buffer, lenp, ppos,
  2595. do_proc_dointvec_ms_jiffies_conv, NULL);
  2596. }
  2597. static int proc_do_cad_pid(struct ctl_table *table, int write,
  2598. void __user *buffer, size_t *lenp, loff_t *ppos)
  2599. {
  2600. struct pid *new_pid;
  2601. pid_t tmp;
  2602. int r;
  2603. tmp = pid_vnr(cad_pid);
  2604. r = __do_proc_dointvec(&tmp, table, write, buffer,
  2605. lenp, ppos, NULL, NULL);
  2606. if (r || !write)
  2607. return r;
  2608. new_pid = find_get_pid(tmp);
  2609. if (!new_pid)
  2610. return -ESRCH;
  2611. put_pid(xchg(&cad_pid, new_pid));
  2612. return 0;
  2613. }
  2614. /**
  2615. * proc_do_large_bitmap - read/write from/to a large bitmap
  2616. * @table: the sysctl table
  2617. * @write: %TRUE if this is a write to the sysctl file
  2618. * @buffer: the user buffer
  2619. * @lenp: the size of the user buffer
  2620. * @ppos: file position
  2621. *
  2622. * The bitmap is stored at table->data and the bitmap length (in bits)
  2623. * in table->maxlen.
  2624. *
  2625. * We use a range comma separated format (e.g. 1,3-4,10-10) so that
  2626. * large bitmaps may be represented in a compact manner. Writing into
  2627. * the file will clear the bitmap then update it with the given input.
  2628. *
  2629. * Returns 0 on success.
  2630. */
  2631. int proc_do_large_bitmap(struct ctl_table *table, int write,
  2632. void __user *buffer, size_t *lenp, loff_t *ppos)
  2633. {
  2634. int err = 0;
  2635. bool first = 1;
  2636. size_t left = *lenp;
  2637. unsigned long bitmap_len = table->maxlen;
  2638. unsigned long *bitmap = *(unsigned long **) table->data;
  2639. unsigned long *tmp_bitmap = NULL;
  2640. char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
  2641. if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
  2642. *lenp = 0;
  2643. return 0;
  2644. }
  2645. if (write) {
  2646. char *kbuf, *p;
  2647. if (left > PAGE_SIZE - 1)
  2648. left = PAGE_SIZE - 1;
  2649. p = kbuf = memdup_user_nul(buffer, left);
  2650. if (IS_ERR(kbuf))
  2651. return PTR_ERR(kbuf);
  2652. tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
  2653. GFP_KERNEL);
  2654. if (!tmp_bitmap) {
  2655. kfree(kbuf);
  2656. return -ENOMEM;
  2657. }
  2658. proc_skip_char(&p, &left, '\n');
  2659. while (!err && left) {
  2660. unsigned long val_a, val_b;
  2661. bool neg;
  2662. err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
  2663. sizeof(tr_a), &c);
  2664. if (err)
  2665. break;
  2666. if (val_a >= bitmap_len || neg) {
  2667. err = -EINVAL;
  2668. break;
  2669. }
  2670. val_b = val_a;
  2671. if (left) {
  2672. p++;
  2673. left--;
  2674. }
  2675. if (c == '-') {
  2676. err = proc_get_long(&p, &left, &val_b,
  2677. &neg, tr_b, sizeof(tr_b),
  2678. &c);
  2679. if (err)
  2680. break;
  2681. if (val_b >= bitmap_len || neg ||
  2682. val_a > val_b) {
  2683. err = -EINVAL;
  2684. break;
  2685. }
  2686. if (left) {
  2687. p++;
  2688. left--;
  2689. }
  2690. }
  2691. bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
  2692. first = 0;
  2693. proc_skip_char(&p, &left, '\n');
  2694. }
  2695. kfree(kbuf);
  2696. } else {
  2697. unsigned long bit_a, bit_b = 0;
  2698. while (left) {
  2699. bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
  2700. if (bit_a >= bitmap_len)
  2701. break;
  2702. bit_b = find_next_zero_bit(bitmap, bitmap_len,
  2703. bit_a + 1) - 1;
  2704. if (!first) {
  2705. err = proc_put_char(&buffer, &left, ',');
  2706. if (err)
  2707. break;
  2708. }
  2709. err = proc_put_long(&buffer, &left, bit_a, false);
  2710. if (err)
  2711. break;
  2712. if (bit_a != bit_b) {
  2713. err = proc_put_char(&buffer, &left, '-');
  2714. if (err)
  2715. break;
  2716. err = proc_put_long(&buffer, &left, bit_b, false);
  2717. if (err)
  2718. break;
  2719. }
  2720. first = 0; bit_b++;
  2721. }
  2722. if (!err)
  2723. err = proc_put_char(&buffer, &left, '\n');
  2724. }
  2725. if (!err) {
  2726. if (write) {
  2727. if (*ppos)
  2728. bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
  2729. else
  2730. bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
  2731. }
  2732. kfree(tmp_bitmap);
  2733. *lenp -= left;
  2734. *ppos += *lenp;
  2735. return 0;
  2736. } else {
  2737. kfree(tmp_bitmap);
  2738. return err;
  2739. }
  2740. }
  2741. #else /* CONFIG_PROC_SYSCTL */
  2742. int proc_dostring(struct ctl_table *table, int write,
  2743. void __user *buffer, size_t *lenp, loff_t *ppos)
  2744. {
  2745. return -ENOSYS;
  2746. }
  2747. int proc_dointvec(struct ctl_table *table, int write,
  2748. void __user *buffer, size_t *lenp, loff_t *ppos)
  2749. {
  2750. return -ENOSYS;
  2751. }
  2752. int proc_douintvec(struct ctl_table *table, int write,
  2753. void __user *buffer, size_t *lenp, loff_t *ppos)
  2754. {
  2755. return -ENOSYS;
  2756. }
  2757. int proc_dointvec_minmax(struct ctl_table *table, int write,
  2758. void __user *buffer, size_t *lenp, loff_t *ppos)
  2759. {
  2760. return -ENOSYS;
  2761. }
  2762. int proc_dointvec_jiffies(struct ctl_table *table, int write,
  2763. void __user *buffer, size_t *lenp, loff_t *ppos)
  2764. {
  2765. return -ENOSYS;
  2766. }
  2767. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
  2768. void __user *buffer, size_t *lenp, loff_t *ppos)
  2769. {
  2770. return -ENOSYS;
  2771. }
  2772. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
  2773. void __user *buffer, size_t *lenp, loff_t *ppos)
  2774. {
  2775. return -ENOSYS;
  2776. }
  2777. int proc_doulongvec_minmax(struct ctl_table *table, int write,
  2778. void __user *buffer, size_t *lenp, loff_t *ppos)
  2779. {
  2780. return -ENOSYS;
  2781. }
  2782. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2783. void __user *buffer,
  2784. size_t *lenp, loff_t *ppos)
  2785. {
  2786. return -ENOSYS;
  2787. }
  2788. #endif /* CONFIG_PROC_SYSCTL */
  2789. /*
  2790. * No sense putting this after each symbol definition, twice,
  2791. * exception granted :-)
  2792. */
  2793. EXPORT_SYMBOL(proc_dointvec);
  2794. EXPORT_SYMBOL(proc_douintvec);
  2795. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2796. EXPORT_SYMBOL(proc_dointvec_minmax);
  2797. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2798. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2799. EXPORT_SYMBOL(proc_dostring);
  2800. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2801. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);