sysctl.c 75 KB

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