sysctl.c 75 KB

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