sysctl.c 75 KB

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