sysctl.c 75 KB

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