sysctl.c 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167
  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/mm.h>
  22. #include <linux/swap.h>
  23. #include <linux/slab.h>
  24. #include <linux/sysctl.h>
  25. #include <linux/proc_fs.h>
  26. #include <linux/security.h>
  27. #include <linux/ctype.h>
  28. #include <linux/utsname.h>
  29. #include <linux/smp_lock.h>
  30. #include <linux/fs.h>
  31. #include <linux/init.h>
  32. #include <linux/kernel.h>
  33. #include <linux/kobject.h>
  34. #include <linux/net.h>
  35. #include <linux/sysrq.h>
  36. #include <linux/highuid.h>
  37. #include <linux/writeback.h>
  38. #include <linux/hugetlb.h>
  39. #include <linux/initrd.h>
  40. #include <linux/key.h>
  41. #include <linux/times.h>
  42. #include <linux/limits.h>
  43. #include <linux/dcache.h>
  44. #include <linux/syscalls.h>
  45. #include <linux/vmstat.h>
  46. #include <linux/nfs_fs.h>
  47. #include <linux/acpi.h>
  48. #include <linux/reboot.h>
  49. #include <linux/ftrace.h>
  50. #include <linux/slow-work.h>
  51. #include <linux/perf_counter.h>
  52. #include <asm/uaccess.h>
  53. #include <asm/processor.h>
  54. #ifdef CONFIG_X86
  55. #include <asm/nmi.h>
  56. #include <asm/stacktrace.h>
  57. #include <asm/io.h>
  58. #endif
  59. static int deprecated_sysctl_warning(struct __sysctl_args *args);
  60. #if defined(CONFIG_SYSCTL)
  61. /* External variables not in a header file. */
  62. extern int C_A_D;
  63. extern int print_fatal_signals;
  64. extern int sysctl_overcommit_memory;
  65. extern int sysctl_overcommit_ratio;
  66. extern int sysctl_panic_on_oom;
  67. extern int sysctl_oom_kill_allocating_task;
  68. extern int sysctl_oom_dump_tasks;
  69. extern int max_threads;
  70. extern int core_uses_pid;
  71. extern int suid_dumpable;
  72. extern char core_pattern[];
  73. extern int pid_max;
  74. extern int min_free_kbytes;
  75. extern int pid_max_min, pid_max_max;
  76. extern int sysctl_drop_caches;
  77. extern int percpu_pagelist_fraction;
  78. extern int compat_log;
  79. extern int latencytop_enabled;
  80. extern int sysctl_nr_open_min, sysctl_nr_open_max;
  81. #ifndef CONFIG_MMU
  82. extern int sysctl_nr_trim_pages;
  83. #endif
  84. #ifdef CONFIG_RCU_TORTURE_TEST
  85. extern int rcutorture_runnable;
  86. #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
  87. /* Constants used for minimum and maximum */
  88. #ifdef CONFIG_DETECT_SOFTLOCKUP
  89. static int sixty = 60;
  90. static int neg_one = -1;
  91. #endif
  92. static int zero;
  93. static int __maybe_unused one = 1;
  94. static int __maybe_unused two = 2;
  95. static unsigned long one_ul = 1;
  96. static int one_hundred = 100;
  97. static int one_thousand = 1000;
  98. /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
  99. static int maxolduid = 65535;
  100. static int minolduid;
  101. static int min_percpu_pagelist_fract = 8;
  102. static int ngroups_max = NGROUPS_MAX;
  103. #ifdef CONFIG_MODULES
  104. extern char modprobe_path[];
  105. #endif
  106. #ifdef CONFIG_CHR_DEV_SG
  107. extern int sg_big_buff;
  108. #endif
  109. #ifdef CONFIG_SPARC
  110. #include <asm/system.h>
  111. #endif
  112. #ifdef CONFIG_SPARC64
  113. extern int sysctl_tsb_ratio;
  114. #endif
  115. #ifdef __hppa__
  116. extern int pwrsw_enabled;
  117. extern int unaligned_enabled;
  118. #endif
  119. #ifdef CONFIG_S390
  120. #ifdef CONFIG_MATHEMU
  121. extern int sysctl_ieee_emulation_warnings;
  122. #endif
  123. extern int sysctl_userprocess_debug;
  124. extern int spin_retry;
  125. #endif
  126. #ifdef CONFIG_BSD_PROCESS_ACCT
  127. extern int acct_parm[];
  128. #endif
  129. #ifdef CONFIG_IA64
  130. extern int no_unaligned_warning;
  131. extern int unaligned_dump_stack;
  132. #endif
  133. #ifdef CONFIG_RT_MUTEXES
  134. extern int max_lock_depth;
  135. #endif
  136. #ifdef CONFIG_PROC_SYSCTL
  137. static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
  138. void __user *buffer, size_t *lenp, loff_t *ppos);
  139. static int proc_taint(struct ctl_table *table, int write, struct file *filp,
  140. void __user *buffer, size_t *lenp, loff_t *ppos);
  141. #endif
  142. static struct ctl_table root_table[];
  143. static struct ctl_table_root sysctl_table_root;
  144. static struct ctl_table_header root_table_header = {
  145. .count = 1,
  146. .ctl_table = root_table,
  147. .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
  148. .root = &sysctl_table_root,
  149. .set = &sysctl_table_root.default_set,
  150. };
  151. static struct ctl_table_root sysctl_table_root = {
  152. .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
  153. .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
  154. };
  155. static struct ctl_table kern_table[];
  156. static struct ctl_table vm_table[];
  157. static struct ctl_table fs_table[];
  158. static struct ctl_table debug_table[];
  159. static struct ctl_table dev_table[];
  160. extern struct ctl_table random_table[];
  161. #ifdef CONFIG_INOTIFY_USER
  162. extern struct ctl_table inotify_table[];
  163. #endif
  164. #ifdef CONFIG_EPOLL
  165. extern struct ctl_table epoll_table[];
  166. #endif
  167. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  168. int sysctl_legacy_va_layout;
  169. #endif
  170. extern int prove_locking;
  171. extern int lock_stat;
  172. /* The default sysctl tables: */
  173. static struct ctl_table root_table[] = {
  174. {
  175. .ctl_name = CTL_KERN,
  176. .procname = "kernel",
  177. .mode = 0555,
  178. .child = kern_table,
  179. },
  180. {
  181. .ctl_name = CTL_VM,
  182. .procname = "vm",
  183. .mode = 0555,
  184. .child = vm_table,
  185. },
  186. {
  187. .ctl_name = CTL_FS,
  188. .procname = "fs",
  189. .mode = 0555,
  190. .child = fs_table,
  191. },
  192. {
  193. .ctl_name = CTL_DEBUG,
  194. .procname = "debug",
  195. .mode = 0555,
  196. .child = debug_table,
  197. },
  198. {
  199. .ctl_name = CTL_DEV,
  200. .procname = "dev",
  201. .mode = 0555,
  202. .child = dev_table,
  203. },
  204. /*
  205. * NOTE: do not add new entries to this table unless you have read
  206. * Documentation/sysctl/ctl_unnumbered.txt
  207. */
  208. { .ctl_name = 0 }
  209. };
  210. #ifdef CONFIG_SCHED_DEBUG
  211. static int min_sched_granularity_ns = 100000; /* 100 usecs */
  212. static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
  213. static int min_wakeup_granularity_ns; /* 0 usecs */
  214. static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
  215. #endif
  216. static struct ctl_table kern_table[] = {
  217. #ifdef CONFIG_SCHED_DEBUG
  218. {
  219. .ctl_name = CTL_UNNUMBERED,
  220. .procname = "sched_min_granularity_ns",
  221. .data = &sysctl_sched_min_granularity,
  222. .maxlen = sizeof(unsigned int),
  223. .mode = 0644,
  224. .proc_handler = &sched_nr_latency_handler,
  225. .strategy = &sysctl_intvec,
  226. .extra1 = &min_sched_granularity_ns,
  227. .extra2 = &max_sched_granularity_ns,
  228. },
  229. {
  230. .ctl_name = CTL_UNNUMBERED,
  231. .procname = "sched_latency_ns",
  232. .data = &sysctl_sched_latency,
  233. .maxlen = sizeof(unsigned int),
  234. .mode = 0644,
  235. .proc_handler = &sched_nr_latency_handler,
  236. .strategy = &sysctl_intvec,
  237. .extra1 = &min_sched_granularity_ns,
  238. .extra2 = &max_sched_granularity_ns,
  239. },
  240. {
  241. .ctl_name = CTL_UNNUMBERED,
  242. .procname = "sched_wakeup_granularity_ns",
  243. .data = &sysctl_sched_wakeup_granularity,
  244. .maxlen = sizeof(unsigned int),
  245. .mode = 0644,
  246. .proc_handler = &proc_dointvec_minmax,
  247. .strategy = &sysctl_intvec,
  248. .extra1 = &min_wakeup_granularity_ns,
  249. .extra2 = &max_wakeup_granularity_ns,
  250. },
  251. {
  252. .ctl_name = CTL_UNNUMBERED,
  253. .procname = "sched_shares_ratelimit",
  254. .data = &sysctl_sched_shares_ratelimit,
  255. .maxlen = sizeof(unsigned int),
  256. .mode = 0644,
  257. .proc_handler = &proc_dointvec,
  258. },
  259. {
  260. .ctl_name = CTL_UNNUMBERED,
  261. .procname = "sched_shares_thresh",
  262. .data = &sysctl_sched_shares_thresh,
  263. .maxlen = sizeof(unsigned int),
  264. .mode = 0644,
  265. .proc_handler = &proc_dointvec_minmax,
  266. .strategy = &sysctl_intvec,
  267. .extra1 = &zero,
  268. },
  269. {
  270. .ctl_name = CTL_UNNUMBERED,
  271. .procname = "sched_child_runs_first",
  272. .data = &sysctl_sched_child_runs_first,
  273. .maxlen = sizeof(unsigned int),
  274. .mode = 0644,
  275. .proc_handler = &proc_dointvec,
  276. },
  277. {
  278. .ctl_name = CTL_UNNUMBERED,
  279. .procname = "sched_features",
  280. .data = &sysctl_sched_features,
  281. .maxlen = sizeof(unsigned int),
  282. .mode = 0644,
  283. .proc_handler = &proc_dointvec,
  284. },
  285. {
  286. .ctl_name = CTL_UNNUMBERED,
  287. .procname = "sched_migration_cost",
  288. .data = &sysctl_sched_migration_cost,
  289. .maxlen = sizeof(unsigned int),
  290. .mode = 0644,
  291. .proc_handler = &proc_dointvec,
  292. },
  293. {
  294. .ctl_name = CTL_UNNUMBERED,
  295. .procname = "sched_nr_migrate",
  296. .data = &sysctl_sched_nr_migrate,
  297. .maxlen = sizeof(unsigned int),
  298. .mode = 0644,
  299. .proc_handler = &proc_dointvec,
  300. },
  301. #endif
  302. {
  303. .ctl_name = CTL_UNNUMBERED,
  304. .procname = "sched_rt_period_us",
  305. .data = &sysctl_sched_rt_period,
  306. .maxlen = sizeof(unsigned int),
  307. .mode = 0644,
  308. .proc_handler = &sched_rt_handler,
  309. },
  310. {
  311. .ctl_name = CTL_UNNUMBERED,
  312. .procname = "sched_rt_runtime_us",
  313. .data = &sysctl_sched_rt_runtime,
  314. .maxlen = sizeof(int),
  315. .mode = 0644,
  316. .proc_handler = &sched_rt_handler,
  317. },
  318. {
  319. .ctl_name = CTL_UNNUMBERED,
  320. .procname = "sched_compat_yield",
  321. .data = &sysctl_sched_compat_yield,
  322. .maxlen = sizeof(unsigned int),
  323. .mode = 0644,
  324. .proc_handler = &proc_dointvec,
  325. },
  326. #ifdef CONFIG_PROVE_LOCKING
  327. {
  328. .ctl_name = CTL_UNNUMBERED,
  329. .procname = "prove_locking",
  330. .data = &prove_locking,
  331. .maxlen = sizeof(int),
  332. .mode = 0644,
  333. .proc_handler = &proc_dointvec,
  334. },
  335. #endif
  336. #ifdef CONFIG_LOCK_STAT
  337. {
  338. .ctl_name = CTL_UNNUMBERED,
  339. .procname = "lock_stat",
  340. .data = &lock_stat,
  341. .maxlen = sizeof(int),
  342. .mode = 0644,
  343. .proc_handler = &proc_dointvec,
  344. },
  345. #endif
  346. {
  347. .ctl_name = KERN_PANIC,
  348. .procname = "panic",
  349. .data = &panic_timeout,
  350. .maxlen = sizeof(int),
  351. .mode = 0644,
  352. .proc_handler = &proc_dointvec,
  353. },
  354. {
  355. .ctl_name = KERN_CORE_USES_PID,
  356. .procname = "core_uses_pid",
  357. .data = &core_uses_pid,
  358. .maxlen = sizeof(int),
  359. .mode = 0644,
  360. .proc_handler = &proc_dointvec,
  361. },
  362. {
  363. .ctl_name = KERN_CORE_PATTERN,
  364. .procname = "core_pattern",
  365. .data = core_pattern,
  366. .maxlen = CORENAME_MAX_SIZE,
  367. .mode = 0644,
  368. .proc_handler = &proc_dostring,
  369. .strategy = &sysctl_string,
  370. },
  371. #ifdef CONFIG_PROC_SYSCTL
  372. {
  373. .procname = "tainted",
  374. .maxlen = sizeof(long),
  375. .mode = 0644,
  376. .proc_handler = &proc_taint,
  377. },
  378. #endif
  379. #ifdef CONFIG_LATENCYTOP
  380. {
  381. .procname = "latencytop",
  382. .data = &latencytop_enabled,
  383. .maxlen = sizeof(int),
  384. .mode = 0644,
  385. .proc_handler = &proc_dointvec,
  386. },
  387. #endif
  388. #ifdef CONFIG_BLK_DEV_INITRD
  389. {
  390. .ctl_name = KERN_REALROOTDEV,
  391. .procname = "real-root-dev",
  392. .data = &real_root_dev,
  393. .maxlen = sizeof(int),
  394. .mode = 0644,
  395. .proc_handler = &proc_dointvec,
  396. },
  397. #endif
  398. {
  399. .ctl_name = CTL_UNNUMBERED,
  400. .procname = "print-fatal-signals",
  401. .data = &print_fatal_signals,
  402. .maxlen = sizeof(int),
  403. .mode = 0644,
  404. .proc_handler = &proc_dointvec,
  405. },
  406. #ifdef CONFIG_SPARC
  407. {
  408. .ctl_name = KERN_SPARC_REBOOT,
  409. .procname = "reboot-cmd",
  410. .data = reboot_command,
  411. .maxlen = 256,
  412. .mode = 0644,
  413. .proc_handler = &proc_dostring,
  414. .strategy = &sysctl_string,
  415. },
  416. {
  417. .ctl_name = KERN_SPARC_STOP_A,
  418. .procname = "stop-a",
  419. .data = &stop_a_enabled,
  420. .maxlen = sizeof (int),
  421. .mode = 0644,
  422. .proc_handler = &proc_dointvec,
  423. },
  424. {
  425. .ctl_name = KERN_SPARC_SCONS_PWROFF,
  426. .procname = "scons-poweroff",
  427. .data = &scons_pwroff,
  428. .maxlen = sizeof (int),
  429. .mode = 0644,
  430. .proc_handler = &proc_dointvec,
  431. },
  432. #endif
  433. #ifdef CONFIG_SPARC64
  434. {
  435. .ctl_name = CTL_UNNUMBERED,
  436. .procname = "tsb-ratio",
  437. .data = &sysctl_tsb_ratio,
  438. .maxlen = sizeof (int),
  439. .mode = 0644,
  440. .proc_handler = &proc_dointvec,
  441. },
  442. #endif
  443. #ifdef __hppa__
  444. {
  445. .ctl_name = KERN_HPPA_PWRSW,
  446. .procname = "soft-power",
  447. .data = &pwrsw_enabled,
  448. .maxlen = sizeof (int),
  449. .mode = 0644,
  450. .proc_handler = &proc_dointvec,
  451. },
  452. {
  453. .ctl_name = KERN_HPPA_UNALIGNED,
  454. .procname = "unaligned-trap",
  455. .data = &unaligned_enabled,
  456. .maxlen = sizeof (int),
  457. .mode = 0644,
  458. .proc_handler = &proc_dointvec,
  459. },
  460. #endif
  461. {
  462. .ctl_name = KERN_CTLALTDEL,
  463. .procname = "ctrl-alt-del",
  464. .data = &C_A_D,
  465. .maxlen = sizeof(int),
  466. .mode = 0644,
  467. .proc_handler = &proc_dointvec,
  468. },
  469. #ifdef CONFIG_FUNCTION_TRACER
  470. {
  471. .ctl_name = CTL_UNNUMBERED,
  472. .procname = "ftrace_enabled",
  473. .data = &ftrace_enabled,
  474. .maxlen = sizeof(int),
  475. .mode = 0644,
  476. .proc_handler = &ftrace_enable_sysctl,
  477. },
  478. #endif
  479. #ifdef CONFIG_STACK_TRACER
  480. {
  481. .ctl_name = CTL_UNNUMBERED,
  482. .procname = "stack_tracer_enabled",
  483. .data = &stack_tracer_enabled,
  484. .maxlen = sizeof(int),
  485. .mode = 0644,
  486. .proc_handler = &stack_trace_sysctl,
  487. },
  488. #endif
  489. #ifdef CONFIG_TRACING
  490. {
  491. .ctl_name = CTL_UNNUMBERED,
  492. .procname = "ftrace_dump_on_oops",
  493. .data = &ftrace_dump_on_oops,
  494. .maxlen = sizeof(int),
  495. .mode = 0644,
  496. .proc_handler = &proc_dointvec,
  497. },
  498. #endif
  499. #ifdef CONFIG_MODULES
  500. {
  501. .ctl_name = KERN_MODPROBE,
  502. .procname = "modprobe",
  503. .data = &modprobe_path,
  504. .maxlen = KMOD_PATH_LEN,
  505. .mode = 0644,
  506. .proc_handler = &proc_dostring,
  507. .strategy = &sysctl_string,
  508. },
  509. #endif
  510. #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
  511. {
  512. .ctl_name = KERN_HOTPLUG,
  513. .procname = "hotplug",
  514. .data = &uevent_helper,
  515. .maxlen = UEVENT_HELPER_PATH_LEN,
  516. .mode = 0644,
  517. .proc_handler = &proc_dostring,
  518. .strategy = &sysctl_string,
  519. },
  520. #endif
  521. #ifdef CONFIG_CHR_DEV_SG
  522. {
  523. .ctl_name = KERN_SG_BIG_BUFF,
  524. .procname = "sg-big-buff",
  525. .data = &sg_big_buff,
  526. .maxlen = sizeof (int),
  527. .mode = 0444,
  528. .proc_handler = &proc_dointvec,
  529. },
  530. #endif
  531. #ifdef CONFIG_BSD_PROCESS_ACCT
  532. {
  533. .ctl_name = KERN_ACCT,
  534. .procname = "acct",
  535. .data = &acct_parm,
  536. .maxlen = 3*sizeof(int),
  537. .mode = 0644,
  538. .proc_handler = &proc_dointvec,
  539. },
  540. #endif
  541. #ifdef CONFIG_MAGIC_SYSRQ
  542. {
  543. .ctl_name = KERN_SYSRQ,
  544. .procname = "sysrq",
  545. .data = &__sysrq_enabled,
  546. .maxlen = sizeof (int),
  547. .mode = 0644,
  548. .proc_handler = &proc_dointvec,
  549. },
  550. #endif
  551. #ifdef CONFIG_PROC_SYSCTL
  552. {
  553. .procname = "cad_pid",
  554. .data = NULL,
  555. .maxlen = sizeof (int),
  556. .mode = 0600,
  557. .proc_handler = &proc_do_cad_pid,
  558. },
  559. #endif
  560. {
  561. .ctl_name = KERN_MAX_THREADS,
  562. .procname = "threads-max",
  563. .data = &max_threads,
  564. .maxlen = sizeof(int),
  565. .mode = 0644,
  566. .proc_handler = &proc_dointvec,
  567. },
  568. {
  569. .ctl_name = KERN_RANDOM,
  570. .procname = "random",
  571. .mode = 0555,
  572. .child = random_table,
  573. },
  574. {
  575. .ctl_name = KERN_OVERFLOWUID,
  576. .procname = "overflowuid",
  577. .data = &overflowuid,
  578. .maxlen = sizeof(int),
  579. .mode = 0644,
  580. .proc_handler = &proc_dointvec_minmax,
  581. .strategy = &sysctl_intvec,
  582. .extra1 = &minolduid,
  583. .extra2 = &maxolduid,
  584. },
  585. {
  586. .ctl_name = KERN_OVERFLOWGID,
  587. .procname = "overflowgid",
  588. .data = &overflowgid,
  589. .maxlen = sizeof(int),
  590. .mode = 0644,
  591. .proc_handler = &proc_dointvec_minmax,
  592. .strategy = &sysctl_intvec,
  593. .extra1 = &minolduid,
  594. .extra2 = &maxolduid,
  595. },
  596. #ifdef CONFIG_S390
  597. #ifdef CONFIG_MATHEMU
  598. {
  599. .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
  600. .procname = "ieee_emulation_warnings",
  601. .data = &sysctl_ieee_emulation_warnings,
  602. .maxlen = sizeof(int),
  603. .mode = 0644,
  604. .proc_handler = &proc_dointvec,
  605. },
  606. #endif
  607. {
  608. .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
  609. .procname = "userprocess_debug",
  610. .data = &sysctl_userprocess_debug,
  611. .maxlen = sizeof(int),
  612. .mode = 0644,
  613. .proc_handler = &proc_dointvec,
  614. },
  615. #endif
  616. {
  617. .ctl_name = KERN_PIDMAX,
  618. .procname = "pid_max",
  619. .data = &pid_max,
  620. .maxlen = sizeof (int),
  621. .mode = 0644,
  622. .proc_handler = &proc_dointvec_minmax,
  623. .strategy = sysctl_intvec,
  624. .extra1 = &pid_max_min,
  625. .extra2 = &pid_max_max,
  626. },
  627. {
  628. .ctl_name = KERN_PANIC_ON_OOPS,
  629. .procname = "panic_on_oops",
  630. .data = &panic_on_oops,
  631. .maxlen = sizeof(int),
  632. .mode = 0644,
  633. .proc_handler = &proc_dointvec,
  634. },
  635. #if defined CONFIG_PRINTK
  636. {
  637. .ctl_name = KERN_PRINTK,
  638. .procname = "printk",
  639. .data = &console_loglevel,
  640. .maxlen = 4*sizeof(int),
  641. .mode = 0644,
  642. .proc_handler = &proc_dointvec,
  643. },
  644. {
  645. .ctl_name = KERN_PRINTK_RATELIMIT,
  646. .procname = "printk_ratelimit",
  647. .data = &printk_ratelimit_state.interval,
  648. .maxlen = sizeof(int),
  649. .mode = 0644,
  650. .proc_handler = &proc_dointvec_jiffies,
  651. .strategy = &sysctl_jiffies,
  652. },
  653. {
  654. .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
  655. .procname = "printk_ratelimit_burst",
  656. .data = &printk_ratelimit_state.burst,
  657. .maxlen = sizeof(int),
  658. .mode = 0644,
  659. .proc_handler = &proc_dointvec,
  660. },
  661. #endif
  662. {
  663. .ctl_name = KERN_NGROUPS_MAX,
  664. .procname = "ngroups_max",
  665. .data = &ngroups_max,
  666. .maxlen = sizeof (int),
  667. .mode = 0444,
  668. .proc_handler = &proc_dointvec,
  669. },
  670. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
  671. {
  672. .ctl_name = KERN_UNKNOWN_NMI_PANIC,
  673. .procname = "unknown_nmi_panic",
  674. .data = &unknown_nmi_panic,
  675. .maxlen = sizeof (int),
  676. .mode = 0644,
  677. .proc_handler = &proc_dointvec,
  678. },
  679. {
  680. .procname = "nmi_watchdog",
  681. .data = &nmi_watchdog_enabled,
  682. .maxlen = sizeof (int),
  683. .mode = 0644,
  684. .proc_handler = &proc_nmi_enabled,
  685. },
  686. #endif
  687. #if defined(CONFIG_X86)
  688. {
  689. .ctl_name = KERN_PANIC_ON_NMI,
  690. .procname = "panic_on_unrecovered_nmi",
  691. .data = &panic_on_unrecovered_nmi,
  692. .maxlen = sizeof(int),
  693. .mode = 0644,
  694. .proc_handler = &proc_dointvec,
  695. },
  696. {
  697. .ctl_name = KERN_BOOTLOADER_TYPE,
  698. .procname = "bootloader_type",
  699. .data = &bootloader_type,
  700. .maxlen = sizeof (int),
  701. .mode = 0444,
  702. .proc_handler = &proc_dointvec,
  703. },
  704. {
  705. .ctl_name = CTL_UNNUMBERED,
  706. .procname = "kstack_depth_to_print",
  707. .data = &kstack_depth_to_print,
  708. .maxlen = sizeof(int),
  709. .mode = 0644,
  710. .proc_handler = &proc_dointvec,
  711. },
  712. {
  713. .ctl_name = CTL_UNNUMBERED,
  714. .procname = "io_delay_type",
  715. .data = &io_delay_type,
  716. .maxlen = sizeof(int),
  717. .mode = 0644,
  718. .proc_handler = &proc_dointvec,
  719. },
  720. #endif
  721. #if defined(CONFIG_MMU)
  722. {
  723. .ctl_name = KERN_RANDOMIZE,
  724. .procname = "randomize_va_space",
  725. .data = &randomize_va_space,
  726. .maxlen = sizeof(int),
  727. .mode = 0644,
  728. .proc_handler = &proc_dointvec,
  729. },
  730. #endif
  731. #if defined(CONFIG_S390) && defined(CONFIG_SMP)
  732. {
  733. .ctl_name = KERN_SPIN_RETRY,
  734. .procname = "spin_retry",
  735. .data = &spin_retry,
  736. .maxlen = sizeof (int),
  737. .mode = 0644,
  738. .proc_handler = &proc_dointvec,
  739. },
  740. #endif
  741. #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
  742. {
  743. .procname = "acpi_video_flags",
  744. .data = &acpi_realmode_flags,
  745. .maxlen = sizeof (unsigned long),
  746. .mode = 0644,
  747. .proc_handler = &proc_doulongvec_minmax,
  748. },
  749. #endif
  750. #ifdef CONFIG_IA64
  751. {
  752. .ctl_name = KERN_IA64_UNALIGNED,
  753. .procname = "ignore-unaligned-usertrap",
  754. .data = &no_unaligned_warning,
  755. .maxlen = sizeof (int),
  756. .mode = 0644,
  757. .proc_handler = &proc_dointvec,
  758. },
  759. {
  760. .ctl_name = CTL_UNNUMBERED,
  761. .procname = "unaligned-dump-stack",
  762. .data = &unaligned_dump_stack,
  763. .maxlen = sizeof (int),
  764. .mode = 0644,
  765. .proc_handler = &proc_dointvec,
  766. },
  767. #endif
  768. #ifdef CONFIG_DETECT_SOFTLOCKUP
  769. {
  770. .ctl_name = CTL_UNNUMBERED,
  771. .procname = "softlockup_panic",
  772. .data = &softlockup_panic,
  773. .maxlen = sizeof(int),
  774. .mode = 0644,
  775. .proc_handler = &proc_dointvec_minmax,
  776. .strategy = &sysctl_intvec,
  777. .extra1 = &zero,
  778. .extra2 = &one,
  779. },
  780. {
  781. .ctl_name = CTL_UNNUMBERED,
  782. .procname = "softlockup_thresh",
  783. .data = &softlockup_thresh,
  784. .maxlen = sizeof(int),
  785. .mode = 0644,
  786. .proc_handler = &proc_dosoftlockup_thresh,
  787. .strategy = &sysctl_intvec,
  788. .extra1 = &neg_one,
  789. .extra2 = &sixty,
  790. },
  791. #endif
  792. #ifdef CONFIG_DETECT_HUNG_TASK
  793. {
  794. .ctl_name = CTL_UNNUMBERED,
  795. .procname = "hung_task_panic",
  796. .data = &sysctl_hung_task_panic,
  797. .maxlen = sizeof(int),
  798. .mode = 0644,
  799. .proc_handler = &proc_dointvec_minmax,
  800. .strategy = &sysctl_intvec,
  801. .extra1 = &zero,
  802. .extra2 = &one,
  803. },
  804. {
  805. .ctl_name = CTL_UNNUMBERED,
  806. .procname = "hung_task_check_count",
  807. .data = &sysctl_hung_task_check_count,
  808. .maxlen = sizeof(unsigned long),
  809. .mode = 0644,
  810. .proc_handler = &proc_doulongvec_minmax,
  811. .strategy = &sysctl_intvec,
  812. },
  813. {
  814. .ctl_name = CTL_UNNUMBERED,
  815. .procname = "hung_task_timeout_secs",
  816. .data = &sysctl_hung_task_timeout_secs,
  817. .maxlen = sizeof(unsigned long),
  818. .mode = 0644,
  819. .proc_handler = &proc_dohung_task_timeout_secs,
  820. .strategy = &sysctl_intvec,
  821. },
  822. {
  823. .ctl_name = CTL_UNNUMBERED,
  824. .procname = "hung_task_warnings",
  825. .data = &sysctl_hung_task_warnings,
  826. .maxlen = sizeof(unsigned long),
  827. .mode = 0644,
  828. .proc_handler = &proc_doulongvec_minmax,
  829. .strategy = &sysctl_intvec,
  830. },
  831. #endif
  832. #ifdef CONFIG_COMPAT
  833. {
  834. .ctl_name = KERN_COMPAT_LOG,
  835. .procname = "compat-log",
  836. .data = &compat_log,
  837. .maxlen = sizeof (int),
  838. .mode = 0644,
  839. .proc_handler = &proc_dointvec,
  840. },
  841. #endif
  842. #ifdef CONFIG_RT_MUTEXES
  843. {
  844. .ctl_name = KERN_MAX_LOCK_DEPTH,
  845. .procname = "max_lock_depth",
  846. .data = &max_lock_depth,
  847. .maxlen = sizeof(int),
  848. .mode = 0644,
  849. .proc_handler = &proc_dointvec,
  850. },
  851. #endif
  852. {
  853. .ctl_name = CTL_UNNUMBERED,
  854. .procname = "poweroff_cmd",
  855. .data = &poweroff_cmd,
  856. .maxlen = POWEROFF_CMD_PATH_LEN,
  857. .mode = 0644,
  858. .proc_handler = &proc_dostring,
  859. .strategy = &sysctl_string,
  860. },
  861. #ifdef CONFIG_KEYS
  862. {
  863. .ctl_name = CTL_UNNUMBERED,
  864. .procname = "keys",
  865. .mode = 0555,
  866. .child = key_sysctls,
  867. },
  868. #endif
  869. #ifdef CONFIG_RCU_TORTURE_TEST
  870. {
  871. .ctl_name = CTL_UNNUMBERED,
  872. .procname = "rcutorture_runnable",
  873. .data = &rcutorture_runnable,
  874. .maxlen = sizeof(int),
  875. .mode = 0644,
  876. .proc_handler = &proc_dointvec,
  877. },
  878. #endif
  879. #ifdef CONFIG_SLOW_WORK
  880. {
  881. .ctl_name = CTL_UNNUMBERED,
  882. .procname = "slow-work",
  883. .mode = 0555,
  884. .child = slow_work_sysctls,
  885. },
  886. #endif
  887. #ifdef CONFIG_PERF_COUNTERS
  888. {
  889. .ctl_name = CTL_UNNUMBERED,
  890. .procname = "perf_counter_privileged",
  891. .data = &sysctl_perf_counter_priv,
  892. .maxlen = sizeof(sysctl_perf_counter_priv),
  893. .mode = 0644,
  894. .proc_handler = &proc_dointvec,
  895. },
  896. {
  897. .ctl_name = CTL_UNNUMBERED,
  898. .procname = "perf_counter_mlock_kb",
  899. .data = &sysctl_perf_counter_mlock,
  900. .maxlen = sizeof(sysctl_perf_counter_mlock),
  901. .mode = 0644,
  902. .proc_handler = &proc_dointvec,
  903. },
  904. #endif
  905. /*
  906. * NOTE: do not add new entries to this table unless you have read
  907. * Documentation/sysctl/ctl_unnumbered.txt
  908. */
  909. { .ctl_name = 0 }
  910. };
  911. static struct ctl_table vm_table[] = {
  912. {
  913. .ctl_name = VM_OVERCOMMIT_MEMORY,
  914. .procname = "overcommit_memory",
  915. .data = &sysctl_overcommit_memory,
  916. .maxlen = sizeof(sysctl_overcommit_memory),
  917. .mode = 0644,
  918. .proc_handler = &proc_dointvec,
  919. },
  920. {
  921. .ctl_name = VM_PANIC_ON_OOM,
  922. .procname = "panic_on_oom",
  923. .data = &sysctl_panic_on_oom,
  924. .maxlen = sizeof(sysctl_panic_on_oom),
  925. .mode = 0644,
  926. .proc_handler = &proc_dointvec,
  927. },
  928. {
  929. .ctl_name = CTL_UNNUMBERED,
  930. .procname = "oom_kill_allocating_task",
  931. .data = &sysctl_oom_kill_allocating_task,
  932. .maxlen = sizeof(sysctl_oom_kill_allocating_task),
  933. .mode = 0644,
  934. .proc_handler = &proc_dointvec,
  935. },
  936. {
  937. .ctl_name = CTL_UNNUMBERED,
  938. .procname = "oom_dump_tasks",
  939. .data = &sysctl_oom_dump_tasks,
  940. .maxlen = sizeof(sysctl_oom_dump_tasks),
  941. .mode = 0644,
  942. .proc_handler = &proc_dointvec,
  943. },
  944. {
  945. .ctl_name = VM_OVERCOMMIT_RATIO,
  946. .procname = "overcommit_ratio",
  947. .data = &sysctl_overcommit_ratio,
  948. .maxlen = sizeof(sysctl_overcommit_ratio),
  949. .mode = 0644,
  950. .proc_handler = &proc_dointvec,
  951. },
  952. {
  953. .ctl_name = VM_PAGE_CLUSTER,
  954. .procname = "page-cluster",
  955. .data = &page_cluster,
  956. .maxlen = sizeof(int),
  957. .mode = 0644,
  958. .proc_handler = &proc_dointvec,
  959. },
  960. {
  961. .ctl_name = VM_DIRTY_BACKGROUND,
  962. .procname = "dirty_background_ratio",
  963. .data = &dirty_background_ratio,
  964. .maxlen = sizeof(dirty_background_ratio),
  965. .mode = 0644,
  966. .proc_handler = &dirty_background_ratio_handler,
  967. .strategy = &sysctl_intvec,
  968. .extra1 = &zero,
  969. .extra2 = &one_hundred,
  970. },
  971. {
  972. .ctl_name = CTL_UNNUMBERED,
  973. .procname = "dirty_background_bytes",
  974. .data = &dirty_background_bytes,
  975. .maxlen = sizeof(dirty_background_bytes),
  976. .mode = 0644,
  977. .proc_handler = &dirty_background_bytes_handler,
  978. .strategy = &sysctl_intvec,
  979. .extra1 = &one_ul,
  980. },
  981. {
  982. .ctl_name = VM_DIRTY_RATIO,
  983. .procname = "dirty_ratio",
  984. .data = &vm_dirty_ratio,
  985. .maxlen = sizeof(vm_dirty_ratio),
  986. .mode = 0644,
  987. .proc_handler = &dirty_ratio_handler,
  988. .strategy = &sysctl_intvec,
  989. .extra1 = &zero,
  990. .extra2 = &one_hundred,
  991. },
  992. {
  993. .ctl_name = CTL_UNNUMBERED,
  994. .procname = "dirty_bytes",
  995. .data = &vm_dirty_bytes,
  996. .maxlen = sizeof(vm_dirty_bytes),
  997. .mode = 0644,
  998. .proc_handler = &dirty_bytes_handler,
  999. .strategy = &sysctl_intvec,
  1000. .extra1 = &one_ul,
  1001. },
  1002. {
  1003. .procname = "dirty_writeback_centisecs",
  1004. .data = &dirty_writeback_interval,
  1005. .maxlen = sizeof(dirty_writeback_interval),
  1006. .mode = 0644,
  1007. .proc_handler = &dirty_writeback_centisecs_handler,
  1008. },
  1009. {
  1010. .procname = "dirty_expire_centisecs",
  1011. .data = &dirty_expire_interval,
  1012. .maxlen = sizeof(dirty_expire_interval),
  1013. .mode = 0644,
  1014. .proc_handler = &proc_dointvec,
  1015. },
  1016. {
  1017. .ctl_name = VM_NR_PDFLUSH_THREADS,
  1018. .procname = "nr_pdflush_threads",
  1019. .data = &nr_pdflush_threads,
  1020. .maxlen = sizeof nr_pdflush_threads,
  1021. .mode = 0444 /* read-only*/,
  1022. .proc_handler = &proc_dointvec,
  1023. },
  1024. {
  1025. .ctl_name = CTL_UNNUMBERED,
  1026. .procname = "nr_pdflush_threads_min",
  1027. .data = &nr_pdflush_threads_min,
  1028. .maxlen = sizeof nr_pdflush_threads_min,
  1029. .mode = 0644 /* read-write */,
  1030. .proc_handler = &proc_dointvec_minmax,
  1031. .strategy = &sysctl_intvec,
  1032. .extra1 = &one,
  1033. .extra2 = &nr_pdflush_threads_max,
  1034. },
  1035. {
  1036. .ctl_name = CTL_UNNUMBERED,
  1037. .procname = "nr_pdflush_threads_max",
  1038. .data = &nr_pdflush_threads_max,
  1039. .maxlen = sizeof nr_pdflush_threads_max,
  1040. .mode = 0644 /* read-write */,
  1041. .proc_handler = &proc_dointvec_minmax,
  1042. .strategy = &sysctl_intvec,
  1043. .extra1 = &nr_pdflush_threads_min,
  1044. .extra2 = &one_thousand,
  1045. },
  1046. {
  1047. .ctl_name = VM_SWAPPINESS,
  1048. .procname = "swappiness",
  1049. .data = &vm_swappiness,
  1050. .maxlen = sizeof(vm_swappiness),
  1051. .mode = 0644,
  1052. .proc_handler = &proc_dointvec_minmax,
  1053. .strategy = &sysctl_intvec,
  1054. .extra1 = &zero,
  1055. .extra2 = &one_hundred,
  1056. },
  1057. #ifdef CONFIG_HUGETLB_PAGE
  1058. {
  1059. .procname = "nr_hugepages",
  1060. .data = NULL,
  1061. .maxlen = sizeof(unsigned long),
  1062. .mode = 0644,
  1063. .proc_handler = &hugetlb_sysctl_handler,
  1064. .extra1 = (void *)&hugetlb_zero,
  1065. .extra2 = (void *)&hugetlb_infinity,
  1066. },
  1067. {
  1068. .ctl_name = VM_HUGETLB_GROUP,
  1069. .procname = "hugetlb_shm_group",
  1070. .data = &sysctl_hugetlb_shm_group,
  1071. .maxlen = sizeof(gid_t),
  1072. .mode = 0644,
  1073. .proc_handler = &proc_dointvec,
  1074. },
  1075. {
  1076. .ctl_name = CTL_UNNUMBERED,
  1077. .procname = "hugepages_treat_as_movable",
  1078. .data = &hugepages_treat_as_movable,
  1079. .maxlen = sizeof(int),
  1080. .mode = 0644,
  1081. .proc_handler = &hugetlb_treat_movable_handler,
  1082. },
  1083. {
  1084. .ctl_name = CTL_UNNUMBERED,
  1085. .procname = "nr_overcommit_hugepages",
  1086. .data = NULL,
  1087. .maxlen = sizeof(unsigned long),
  1088. .mode = 0644,
  1089. .proc_handler = &hugetlb_overcommit_handler,
  1090. .extra1 = (void *)&hugetlb_zero,
  1091. .extra2 = (void *)&hugetlb_infinity,
  1092. },
  1093. #endif
  1094. {
  1095. .ctl_name = VM_LOWMEM_RESERVE_RATIO,
  1096. .procname = "lowmem_reserve_ratio",
  1097. .data = &sysctl_lowmem_reserve_ratio,
  1098. .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
  1099. .mode = 0644,
  1100. .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
  1101. .strategy = &sysctl_intvec,
  1102. },
  1103. {
  1104. .ctl_name = VM_DROP_PAGECACHE,
  1105. .procname = "drop_caches",
  1106. .data = &sysctl_drop_caches,
  1107. .maxlen = sizeof(int),
  1108. .mode = 0644,
  1109. .proc_handler = drop_caches_sysctl_handler,
  1110. .strategy = &sysctl_intvec,
  1111. },
  1112. {
  1113. .ctl_name = VM_MIN_FREE_KBYTES,
  1114. .procname = "min_free_kbytes",
  1115. .data = &min_free_kbytes,
  1116. .maxlen = sizeof(min_free_kbytes),
  1117. .mode = 0644,
  1118. .proc_handler = &min_free_kbytes_sysctl_handler,
  1119. .strategy = &sysctl_intvec,
  1120. .extra1 = &zero,
  1121. },
  1122. {
  1123. .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
  1124. .procname = "percpu_pagelist_fraction",
  1125. .data = &percpu_pagelist_fraction,
  1126. .maxlen = sizeof(percpu_pagelist_fraction),
  1127. .mode = 0644,
  1128. .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
  1129. .strategy = &sysctl_intvec,
  1130. .extra1 = &min_percpu_pagelist_fract,
  1131. },
  1132. #ifdef CONFIG_MMU
  1133. {
  1134. .ctl_name = VM_MAX_MAP_COUNT,
  1135. .procname = "max_map_count",
  1136. .data = &sysctl_max_map_count,
  1137. .maxlen = sizeof(sysctl_max_map_count),
  1138. .mode = 0644,
  1139. .proc_handler = &proc_dointvec
  1140. },
  1141. #else
  1142. {
  1143. .ctl_name = CTL_UNNUMBERED,
  1144. .procname = "nr_trim_pages",
  1145. .data = &sysctl_nr_trim_pages,
  1146. .maxlen = sizeof(sysctl_nr_trim_pages),
  1147. .mode = 0644,
  1148. .proc_handler = &proc_dointvec_minmax,
  1149. .strategy = &sysctl_intvec,
  1150. .extra1 = &zero,
  1151. },
  1152. #endif
  1153. {
  1154. .ctl_name = VM_LAPTOP_MODE,
  1155. .procname = "laptop_mode",
  1156. .data = &laptop_mode,
  1157. .maxlen = sizeof(laptop_mode),
  1158. .mode = 0644,
  1159. .proc_handler = &proc_dointvec_jiffies,
  1160. .strategy = &sysctl_jiffies,
  1161. },
  1162. {
  1163. .ctl_name = VM_BLOCK_DUMP,
  1164. .procname = "block_dump",
  1165. .data = &block_dump,
  1166. .maxlen = sizeof(block_dump),
  1167. .mode = 0644,
  1168. .proc_handler = &proc_dointvec,
  1169. .strategy = &sysctl_intvec,
  1170. .extra1 = &zero,
  1171. },
  1172. {
  1173. .ctl_name = VM_VFS_CACHE_PRESSURE,
  1174. .procname = "vfs_cache_pressure",
  1175. .data = &sysctl_vfs_cache_pressure,
  1176. .maxlen = sizeof(sysctl_vfs_cache_pressure),
  1177. .mode = 0644,
  1178. .proc_handler = &proc_dointvec,
  1179. .strategy = &sysctl_intvec,
  1180. .extra1 = &zero,
  1181. },
  1182. #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
  1183. {
  1184. .ctl_name = VM_LEGACY_VA_LAYOUT,
  1185. .procname = "legacy_va_layout",
  1186. .data = &sysctl_legacy_va_layout,
  1187. .maxlen = sizeof(sysctl_legacy_va_layout),
  1188. .mode = 0644,
  1189. .proc_handler = &proc_dointvec,
  1190. .strategy = &sysctl_intvec,
  1191. .extra1 = &zero,
  1192. },
  1193. #endif
  1194. #ifdef CONFIG_NUMA
  1195. {
  1196. .ctl_name = VM_ZONE_RECLAIM_MODE,
  1197. .procname = "zone_reclaim_mode",
  1198. .data = &zone_reclaim_mode,
  1199. .maxlen = sizeof(zone_reclaim_mode),
  1200. .mode = 0644,
  1201. .proc_handler = &proc_dointvec,
  1202. .strategy = &sysctl_intvec,
  1203. .extra1 = &zero,
  1204. },
  1205. {
  1206. .ctl_name = VM_MIN_UNMAPPED,
  1207. .procname = "min_unmapped_ratio",
  1208. .data = &sysctl_min_unmapped_ratio,
  1209. .maxlen = sizeof(sysctl_min_unmapped_ratio),
  1210. .mode = 0644,
  1211. .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
  1212. .strategy = &sysctl_intvec,
  1213. .extra1 = &zero,
  1214. .extra2 = &one_hundred,
  1215. },
  1216. {
  1217. .ctl_name = VM_MIN_SLAB,
  1218. .procname = "min_slab_ratio",
  1219. .data = &sysctl_min_slab_ratio,
  1220. .maxlen = sizeof(sysctl_min_slab_ratio),
  1221. .mode = 0644,
  1222. .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
  1223. .strategy = &sysctl_intvec,
  1224. .extra1 = &zero,
  1225. .extra2 = &one_hundred,
  1226. },
  1227. #endif
  1228. #ifdef CONFIG_SMP
  1229. {
  1230. .ctl_name = CTL_UNNUMBERED,
  1231. .procname = "stat_interval",
  1232. .data = &sysctl_stat_interval,
  1233. .maxlen = sizeof(sysctl_stat_interval),
  1234. .mode = 0644,
  1235. .proc_handler = &proc_dointvec_jiffies,
  1236. .strategy = &sysctl_jiffies,
  1237. },
  1238. #endif
  1239. #ifdef CONFIG_SECURITY
  1240. {
  1241. .ctl_name = CTL_UNNUMBERED,
  1242. .procname = "mmap_min_addr",
  1243. .data = &mmap_min_addr,
  1244. .maxlen = sizeof(unsigned long),
  1245. .mode = 0644,
  1246. .proc_handler = &proc_doulongvec_minmax,
  1247. },
  1248. #endif
  1249. #ifdef CONFIG_NUMA
  1250. {
  1251. .ctl_name = CTL_UNNUMBERED,
  1252. .procname = "numa_zonelist_order",
  1253. .data = &numa_zonelist_order,
  1254. .maxlen = NUMA_ZONELIST_ORDER_LEN,
  1255. .mode = 0644,
  1256. .proc_handler = &numa_zonelist_order_handler,
  1257. .strategy = &sysctl_string,
  1258. },
  1259. #endif
  1260. #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
  1261. (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
  1262. {
  1263. .ctl_name = VM_VDSO_ENABLED,
  1264. .procname = "vdso_enabled",
  1265. .data = &vdso_enabled,
  1266. .maxlen = sizeof(vdso_enabled),
  1267. .mode = 0644,
  1268. .proc_handler = &proc_dointvec,
  1269. .strategy = &sysctl_intvec,
  1270. .extra1 = &zero,
  1271. },
  1272. #endif
  1273. #ifdef CONFIG_HIGHMEM
  1274. {
  1275. .ctl_name = CTL_UNNUMBERED,
  1276. .procname = "highmem_is_dirtyable",
  1277. .data = &vm_highmem_is_dirtyable,
  1278. .maxlen = sizeof(vm_highmem_is_dirtyable),
  1279. .mode = 0644,
  1280. .proc_handler = &proc_dointvec_minmax,
  1281. .strategy = &sysctl_intvec,
  1282. .extra1 = &zero,
  1283. .extra2 = &one,
  1284. },
  1285. #endif
  1286. #ifdef CONFIG_UNEVICTABLE_LRU
  1287. {
  1288. .ctl_name = CTL_UNNUMBERED,
  1289. .procname = "scan_unevictable_pages",
  1290. .data = &scan_unevictable_pages,
  1291. .maxlen = sizeof(scan_unevictable_pages),
  1292. .mode = 0644,
  1293. .proc_handler = &scan_unevictable_handler,
  1294. },
  1295. #endif
  1296. /*
  1297. * NOTE: do not add new entries to this table unless you have read
  1298. * Documentation/sysctl/ctl_unnumbered.txt
  1299. */
  1300. { .ctl_name = 0 }
  1301. };
  1302. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1303. static struct ctl_table binfmt_misc_table[] = {
  1304. { .ctl_name = 0 }
  1305. };
  1306. #endif
  1307. static struct ctl_table fs_table[] = {
  1308. {
  1309. .ctl_name = FS_NRINODE,
  1310. .procname = "inode-nr",
  1311. .data = &inodes_stat,
  1312. .maxlen = 2*sizeof(int),
  1313. .mode = 0444,
  1314. .proc_handler = &proc_dointvec,
  1315. },
  1316. {
  1317. .ctl_name = FS_STATINODE,
  1318. .procname = "inode-state",
  1319. .data = &inodes_stat,
  1320. .maxlen = 7*sizeof(int),
  1321. .mode = 0444,
  1322. .proc_handler = &proc_dointvec,
  1323. },
  1324. {
  1325. .procname = "file-nr",
  1326. .data = &files_stat,
  1327. .maxlen = 3*sizeof(int),
  1328. .mode = 0444,
  1329. .proc_handler = &proc_nr_files,
  1330. },
  1331. {
  1332. .ctl_name = FS_MAXFILE,
  1333. .procname = "file-max",
  1334. .data = &files_stat.max_files,
  1335. .maxlen = sizeof(int),
  1336. .mode = 0644,
  1337. .proc_handler = &proc_dointvec,
  1338. },
  1339. {
  1340. .ctl_name = CTL_UNNUMBERED,
  1341. .procname = "nr_open",
  1342. .data = &sysctl_nr_open,
  1343. .maxlen = sizeof(int),
  1344. .mode = 0644,
  1345. .proc_handler = &proc_dointvec_minmax,
  1346. .extra1 = &sysctl_nr_open_min,
  1347. .extra2 = &sysctl_nr_open_max,
  1348. },
  1349. {
  1350. .ctl_name = FS_DENTRY,
  1351. .procname = "dentry-state",
  1352. .data = &dentry_stat,
  1353. .maxlen = 6*sizeof(int),
  1354. .mode = 0444,
  1355. .proc_handler = &proc_dointvec,
  1356. },
  1357. {
  1358. .ctl_name = FS_OVERFLOWUID,
  1359. .procname = "overflowuid",
  1360. .data = &fs_overflowuid,
  1361. .maxlen = sizeof(int),
  1362. .mode = 0644,
  1363. .proc_handler = &proc_dointvec_minmax,
  1364. .strategy = &sysctl_intvec,
  1365. .extra1 = &minolduid,
  1366. .extra2 = &maxolduid,
  1367. },
  1368. {
  1369. .ctl_name = FS_OVERFLOWGID,
  1370. .procname = "overflowgid",
  1371. .data = &fs_overflowgid,
  1372. .maxlen = sizeof(int),
  1373. .mode = 0644,
  1374. .proc_handler = &proc_dointvec_minmax,
  1375. .strategy = &sysctl_intvec,
  1376. .extra1 = &minolduid,
  1377. .extra2 = &maxolduid,
  1378. },
  1379. #ifdef CONFIG_FILE_LOCKING
  1380. {
  1381. .ctl_name = FS_LEASES,
  1382. .procname = "leases-enable",
  1383. .data = &leases_enable,
  1384. .maxlen = sizeof(int),
  1385. .mode = 0644,
  1386. .proc_handler = &proc_dointvec,
  1387. },
  1388. #endif
  1389. #ifdef CONFIG_DNOTIFY
  1390. {
  1391. .ctl_name = FS_DIR_NOTIFY,
  1392. .procname = "dir-notify-enable",
  1393. .data = &dir_notify_enable,
  1394. .maxlen = sizeof(int),
  1395. .mode = 0644,
  1396. .proc_handler = &proc_dointvec,
  1397. },
  1398. #endif
  1399. #ifdef CONFIG_MMU
  1400. #ifdef CONFIG_FILE_LOCKING
  1401. {
  1402. .ctl_name = FS_LEASE_TIME,
  1403. .procname = "lease-break-time",
  1404. .data = &lease_break_time,
  1405. .maxlen = sizeof(int),
  1406. .mode = 0644,
  1407. .proc_handler = &proc_dointvec,
  1408. },
  1409. #endif
  1410. #ifdef CONFIG_AIO
  1411. {
  1412. .procname = "aio-nr",
  1413. .data = &aio_nr,
  1414. .maxlen = sizeof(aio_nr),
  1415. .mode = 0444,
  1416. .proc_handler = &proc_doulongvec_minmax,
  1417. },
  1418. {
  1419. .procname = "aio-max-nr",
  1420. .data = &aio_max_nr,
  1421. .maxlen = sizeof(aio_max_nr),
  1422. .mode = 0644,
  1423. .proc_handler = &proc_doulongvec_minmax,
  1424. },
  1425. #endif /* CONFIG_AIO */
  1426. #ifdef CONFIG_INOTIFY_USER
  1427. {
  1428. .ctl_name = FS_INOTIFY,
  1429. .procname = "inotify",
  1430. .mode = 0555,
  1431. .child = inotify_table,
  1432. },
  1433. #endif
  1434. #ifdef CONFIG_EPOLL
  1435. {
  1436. .procname = "epoll",
  1437. .mode = 0555,
  1438. .child = epoll_table,
  1439. },
  1440. #endif
  1441. #endif
  1442. {
  1443. .ctl_name = KERN_SETUID_DUMPABLE,
  1444. .procname = "suid_dumpable",
  1445. .data = &suid_dumpable,
  1446. .maxlen = sizeof(int),
  1447. .mode = 0644,
  1448. .proc_handler = &proc_dointvec_minmax,
  1449. .strategy = &sysctl_intvec,
  1450. .extra1 = &zero,
  1451. .extra2 = &two,
  1452. },
  1453. #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
  1454. {
  1455. .ctl_name = CTL_UNNUMBERED,
  1456. .procname = "binfmt_misc",
  1457. .mode = 0555,
  1458. .child = binfmt_misc_table,
  1459. },
  1460. #endif
  1461. /*
  1462. * NOTE: do not add new entries to this table unless you have read
  1463. * Documentation/sysctl/ctl_unnumbered.txt
  1464. */
  1465. { .ctl_name = 0 }
  1466. };
  1467. static struct ctl_table debug_table[] = {
  1468. #if defined(CONFIG_X86) || defined(CONFIG_PPC)
  1469. {
  1470. .ctl_name = CTL_UNNUMBERED,
  1471. .procname = "exception-trace",
  1472. .data = &show_unhandled_signals,
  1473. .maxlen = sizeof(int),
  1474. .mode = 0644,
  1475. .proc_handler = proc_dointvec
  1476. },
  1477. #endif
  1478. { .ctl_name = 0 }
  1479. };
  1480. static struct ctl_table dev_table[] = {
  1481. { .ctl_name = 0 }
  1482. };
  1483. static DEFINE_SPINLOCK(sysctl_lock);
  1484. /* called under sysctl_lock */
  1485. static int use_table(struct ctl_table_header *p)
  1486. {
  1487. if (unlikely(p->unregistering))
  1488. return 0;
  1489. p->used++;
  1490. return 1;
  1491. }
  1492. /* called under sysctl_lock */
  1493. static void unuse_table(struct ctl_table_header *p)
  1494. {
  1495. if (!--p->used)
  1496. if (unlikely(p->unregistering))
  1497. complete(p->unregistering);
  1498. }
  1499. /* called under sysctl_lock, will reacquire if has to wait */
  1500. static void start_unregistering(struct ctl_table_header *p)
  1501. {
  1502. /*
  1503. * if p->used is 0, nobody will ever touch that entry again;
  1504. * we'll eliminate all paths to it before dropping sysctl_lock
  1505. */
  1506. if (unlikely(p->used)) {
  1507. struct completion wait;
  1508. init_completion(&wait);
  1509. p->unregistering = &wait;
  1510. spin_unlock(&sysctl_lock);
  1511. wait_for_completion(&wait);
  1512. spin_lock(&sysctl_lock);
  1513. } else {
  1514. /* anything non-NULL; we'll never dereference it */
  1515. p->unregistering = ERR_PTR(-EINVAL);
  1516. }
  1517. /*
  1518. * do not remove from the list until nobody holds it; walking the
  1519. * list in do_sysctl() relies on that.
  1520. */
  1521. list_del_init(&p->ctl_entry);
  1522. }
  1523. void sysctl_head_get(struct ctl_table_header *head)
  1524. {
  1525. spin_lock(&sysctl_lock);
  1526. head->count++;
  1527. spin_unlock(&sysctl_lock);
  1528. }
  1529. void sysctl_head_put(struct ctl_table_header *head)
  1530. {
  1531. spin_lock(&sysctl_lock);
  1532. if (!--head->count)
  1533. kfree(head);
  1534. spin_unlock(&sysctl_lock);
  1535. }
  1536. struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
  1537. {
  1538. if (!head)
  1539. BUG();
  1540. spin_lock(&sysctl_lock);
  1541. if (!use_table(head))
  1542. head = ERR_PTR(-ENOENT);
  1543. spin_unlock(&sysctl_lock);
  1544. return head;
  1545. }
  1546. void sysctl_head_finish(struct ctl_table_header *head)
  1547. {
  1548. if (!head)
  1549. return;
  1550. spin_lock(&sysctl_lock);
  1551. unuse_table(head);
  1552. spin_unlock(&sysctl_lock);
  1553. }
  1554. static struct ctl_table_set *
  1555. lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
  1556. {
  1557. struct ctl_table_set *set = &root->default_set;
  1558. if (root->lookup)
  1559. set = root->lookup(root, namespaces);
  1560. return set;
  1561. }
  1562. static struct list_head *
  1563. lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
  1564. {
  1565. struct ctl_table_set *set = lookup_header_set(root, namespaces);
  1566. return &set->list;
  1567. }
  1568. struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
  1569. struct ctl_table_header *prev)
  1570. {
  1571. struct ctl_table_root *root;
  1572. struct list_head *header_list;
  1573. struct ctl_table_header *head;
  1574. struct list_head *tmp;
  1575. spin_lock(&sysctl_lock);
  1576. if (prev) {
  1577. head = prev;
  1578. tmp = &prev->ctl_entry;
  1579. unuse_table(prev);
  1580. goto next;
  1581. }
  1582. tmp = &root_table_header.ctl_entry;
  1583. for (;;) {
  1584. head = list_entry(tmp, struct ctl_table_header, ctl_entry);
  1585. if (!use_table(head))
  1586. goto next;
  1587. spin_unlock(&sysctl_lock);
  1588. return head;
  1589. next:
  1590. root = head->root;
  1591. tmp = tmp->next;
  1592. header_list = lookup_header_list(root, namespaces);
  1593. if (tmp != header_list)
  1594. continue;
  1595. do {
  1596. root = list_entry(root->root_list.next,
  1597. struct ctl_table_root, root_list);
  1598. if (root == &sysctl_table_root)
  1599. goto out;
  1600. header_list = lookup_header_list(root, namespaces);
  1601. } while (list_empty(header_list));
  1602. tmp = header_list->next;
  1603. }
  1604. out:
  1605. spin_unlock(&sysctl_lock);
  1606. return NULL;
  1607. }
  1608. struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
  1609. {
  1610. return __sysctl_head_next(current->nsproxy, prev);
  1611. }
  1612. void register_sysctl_root(struct ctl_table_root *root)
  1613. {
  1614. spin_lock(&sysctl_lock);
  1615. list_add_tail(&root->root_list, &sysctl_table_root.root_list);
  1616. spin_unlock(&sysctl_lock);
  1617. }
  1618. #ifdef CONFIG_SYSCTL_SYSCALL
  1619. /* Perform the actual read/write of a sysctl table entry. */
  1620. static int do_sysctl_strategy(struct ctl_table_root *root,
  1621. struct ctl_table *table,
  1622. void __user *oldval, size_t __user *oldlenp,
  1623. void __user *newval, size_t newlen)
  1624. {
  1625. int op = 0, rc;
  1626. if (oldval)
  1627. op |= MAY_READ;
  1628. if (newval)
  1629. op |= MAY_WRITE;
  1630. if (sysctl_perm(root, table, op))
  1631. return -EPERM;
  1632. if (table->strategy) {
  1633. rc = table->strategy(table, oldval, oldlenp, newval, newlen);
  1634. if (rc < 0)
  1635. return rc;
  1636. if (rc > 0)
  1637. return 0;
  1638. }
  1639. /* If there is no strategy routine, or if the strategy returns
  1640. * zero, proceed with automatic r/w */
  1641. if (table->data && table->maxlen) {
  1642. rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
  1643. if (rc < 0)
  1644. return rc;
  1645. }
  1646. return 0;
  1647. }
  1648. static int parse_table(int __user *name, int nlen,
  1649. void __user *oldval, size_t __user *oldlenp,
  1650. void __user *newval, size_t newlen,
  1651. struct ctl_table_root *root,
  1652. struct ctl_table *table)
  1653. {
  1654. int n;
  1655. repeat:
  1656. if (!nlen)
  1657. return -ENOTDIR;
  1658. if (get_user(n, name))
  1659. return -EFAULT;
  1660. for ( ; table->ctl_name || table->procname; table++) {
  1661. if (!table->ctl_name)
  1662. continue;
  1663. if (n == table->ctl_name) {
  1664. int error;
  1665. if (table->child) {
  1666. if (sysctl_perm(root, table, MAY_EXEC))
  1667. return -EPERM;
  1668. name++;
  1669. nlen--;
  1670. table = table->child;
  1671. goto repeat;
  1672. }
  1673. error = do_sysctl_strategy(root, table,
  1674. oldval, oldlenp,
  1675. newval, newlen);
  1676. return error;
  1677. }
  1678. }
  1679. return -ENOTDIR;
  1680. }
  1681. int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
  1682. void __user *newval, size_t newlen)
  1683. {
  1684. struct ctl_table_header *head;
  1685. int error = -ENOTDIR;
  1686. if (nlen <= 0 || nlen >= CTL_MAXNAME)
  1687. return -ENOTDIR;
  1688. if (oldval) {
  1689. int old_len;
  1690. if (!oldlenp || get_user(old_len, oldlenp))
  1691. return -EFAULT;
  1692. }
  1693. for (head = sysctl_head_next(NULL); head;
  1694. head = sysctl_head_next(head)) {
  1695. error = parse_table(name, nlen, oldval, oldlenp,
  1696. newval, newlen,
  1697. head->root, head->ctl_table);
  1698. if (error != -ENOTDIR) {
  1699. sysctl_head_finish(head);
  1700. break;
  1701. }
  1702. }
  1703. return error;
  1704. }
  1705. SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
  1706. {
  1707. struct __sysctl_args tmp;
  1708. int error;
  1709. if (copy_from_user(&tmp, args, sizeof(tmp)))
  1710. return -EFAULT;
  1711. error = deprecated_sysctl_warning(&tmp);
  1712. if (error)
  1713. goto out;
  1714. lock_kernel();
  1715. error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
  1716. tmp.newval, tmp.newlen);
  1717. unlock_kernel();
  1718. out:
  1719. return error;
  1720. }
  1721. #endif /* CONFIG_SYSCTL_SYSCALL */
  1722. /*
  1723. * sysctl_perm does NOT grant the superuser all rights automatically, because
  1724. * some sysctl variables are readonly even to root.
  1725. */
  1726. static int test_perm(int mode, int op)
  1727. {
  1728. if (!current_euid())
  1729. mode >>= 6;
  1730. else if (in_egroup_p(0))
  1731. mode >>= 3;
  1732. if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
  1733. return 0;
  1734. return -EACCES;
  1735. }
  1736. int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
  1737. {
  1738. int error;
  1739. int mode;
  1740. error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
  1741. if (error)
  1742. return error;
  1743. if (root->permissions)
  1744. mode = root->permissions(root, current->nsproxy, table);
  1745. else
  1746. mode = table->mode;
  1747. return test_perm(mode, op);
  1748. }
  1749. static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
  1750. {
  1751. for (; table->ctl_name || table->procname; table++) {
  1752. table->parent = parent;
  1753. if (table->child)
  1754. sysctl_set_parent(table, table->child);
  1755. }
  1756. }
  1757. static __init int sysctl_init(void)
  1758. {
  1759. sysctl_set_parent(NULL, root_table);
  1760. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1761. {
  1762. int err;
  1763. err = sysctl_check_table(current->nsproxy, root_table);
  1764. }
  1765. #endif
  1766. return 0;
  1767. }
  1768. core_initcall(sysctl_init);
  1769. static struct ctl_table *is_branch_in(struct ctl_table *branch,
  1770. struct ctl_table *table)
  1771. {
  1772. struct ctl_table *p;
  1773. const char *s = branch->procname;
  1774. /* branch should have named subdirectory as its first element */
  1775. if (!s || !branch->child)
  1776. return NULL;
  1777. /* ... and nothing else */
  1778. if (branch[1].procname || branch[1].ctl_name)
  1779. return NULL;
  1780. /* table should contain subdirectory with the same name */
  1781. for (p = table; p->procname || p->ctl_name; p++) {
  1782. if (!p->child)
  1783. continue;
  1784. if (p->procname && strcmp(p->procname, s) == 0)
  1785. return p;
  1786. }
  1787. return NULL;
  1788. }
  1789. /* see if attaching q to p would be an improvement */
  1790. static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
  1791. {
  1792. struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
  1793. struct ctl_table *next;
  1794. int is_better = 0;
  1795. int not_in_parent = !p->attached_by;
  1796. while ((next = is_branch_in(by, to)) != NULL) {
  1797. if (by == q->attached_by)
  1798. is_better = 1;
  1799. if (to == p->attached_by)
  1800. not_in_parent = 1;
  1801. by = by->child;
  1802. to = next->child;
  1803. }
  1804. if (is_better && not_in_parent) {
  1805. q->attached_by = by;
  1806. q->attached_to = to;
  1807. q->parent = p;
  1808. }
  1809. }
  1810. /**
  1811. * __register_sysctl_paths - register a sysctl hierarchy
  1812. * @root: List of sysctl headers to register on
  1813. * @namespaces: Data to compute which lists of sysctl entries are visible
  1814. * @path: The path to the directory the sysctl table is in.
  1815. * @table: the top-level table structure
  1816. *
  1817. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1818. * array. A completely 0 filled entry terminates the table.
  1819. *
  1820. * The members of the &struct ctl_table structure are used as follows:
  1821. *
  1822. * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
  1823. * must be unique within that level of sysctl
  1824. *
  1825. * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
  1826. * enter a sysctl file
  1827. *
  1828. * data - a pointer to data for use by proc_handler
  1829. *
  1830. * maxlen - the maximum size in bytes of the data
  1831. *
  1832. * mode - the file permissions for the /proc/sys file, and for sysctl(2)
  1833. *
  1834. * child - a pointer to the child sysctl table if this entry is a directory, or
  1835. * %NULL.
  1836. *
  1837. * proc_handler - the text handler routine (described below)
  1838. *
  1839. * strategy - the strategy routine (described below)
  1840. *
  1841. * de - for internal use by the sysctl routines
  1842. *
  1843. * extra1, extra2 - extra pointers usable by the proc handler routines
  1844. *
  1845. * Leaf nodes in the sysctl tree will be represented by a single file
  1846. * under /proc; non-leaf nodes will be represented by directories.
  1847. *
  1848. * sysctl(2) can automatically manage read and write requests through
  1849. * the sysctl table. The data and maxlen fields of the ctl_table
  1850. * struct enable minimal validation of the values being written to be
  1851. * performed, and the mode field allows minimal authentication.
  1852. *
  1853. * More sophisticated management can be enabled by the provision of a
  1854. * strategy routine with the table entry. This will be called before
  1855. * any automatic read or write of the data is performed.
  1856. *
  1857. * The strategy routine may return
  1858. *
  1859. * < 0 - Error occurred (error is passed to user process)
  1860. *
  1861. * 0 - OK - proceed with automatic read or write.
  1862. *
  1863. * > 0 - OK - read or write has been done by the strategy routine, so
  1864. * return immediately.
  1865. *
  1866. * There must be a proc_handler routine for any terminal nodes
  1867. * mirrored under /proc/sys (non-terminals are handled by a built-in
  1868. * directory handler). Several default handlers are available to
  1869. * cover common cases -
  1870. *
  1871. * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
  1872. * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
  1873. * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
  1874. *
  1875. * It is the handler's job to read the input buffer from user memory
  1876. * and process it. The handler should return 0 on success.
  1877. *
  1878. * This routine returns %NULL on a failure to register, and a pointer
  1879. * to the table header on success.
  1880. */
  1881. struct ctl_table_header *__register_sysctl_paths(
  1882. struct ctl_table_root *root,
  1883. struct nsproxy *namespaces,
  1884. const struct ctl_path *path, struct ctl_table *table)
  1885. {
  1886. struct ctl_table_header *header;
  1887. struct ctl_table *new, **prevp;
  1888. unsigned int n, npath;
  1889. struct ctl_table_set *set;
  1890. /* Count the path components */
  1891. for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
  1892. ;
  1893. /*
  1894. * For each path component, allocate a 2-element ctl_table array.
  1895. * The first array element will be filled with the sysctl entry
  1896. * for this, the second will be the sentinel (ctl_name == 0).
  1897. *
  1898. * We allocate everything in one go so that we don't have to
  1899. * worry about freeing additional memory in unregister_sysctl_table.
  1900. */
  1901. header = kzalloc(sizeof(struct ctl_table_header) +
  1902. (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
  1903. if (!header)
  1904. return NULL;
  1905. new = (struct ctl_table *) (header + 1);
  1906. /* Now connect the dots */
  1907. prevp = &header->ctl_table;
  1908. for (n = 0; n < npath; ++n, ++path) {
  1909. /* Copy the procname */
  1910. new->procname = path->procname;
  1911. new->ctl_name = path->ctl_name;
  1912. new->mode = 0555;
  1913. *prevp = new;
  1914. prevp = &new->child;
  1915. new += 2;
  1916. }
  1917. *prevp = table;
  1918. header->ctl_table_arg = table;
  1919. INIT_LIST_HEAD(&header->ctl_entry);
  1920. header->used = 0;
  1921. header->unregistering = NULL;
  1922. header->root = root;
  1923. sysctl_set_parent(NULL, header->ctl_table);
  1924. header->count = 1;
  1925. #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
  1926. if (sysctl_check_table(namespaces, header->ctl_table)) {
  1927. kfree(header);
  1928. return NULL;
  1929. }
  1930. #endif
  1931. spin_lock(&sysctl_lock);
  1932. header->set = lookup_header_set(root, namespaces);
  1933. header->attached_by = header->ctl_table;
  1934. header->attached_to = root_table;
  1935. header->parent = &root_table_header;
  1936. for (set = header->set; set; set = set->parent) {
  1937. struct ctl_table_header *p;
  1938. list_for_each_entry(p, &set->list, ctl_entry) {
  1939. if (p->unregistering)
  1940. continue;
  1941. try_attach(p, header);
  1942. }
  1943. }
  1944. header->parent->count++;
  1945. list_add_tail(&header->ctl_entry, &header->set->list);
  1946. spin_unlock(&sysctl_lock);
  1947. return header;
  1948. }
  1949. /**
  1950. * register_sysctl_table_path - register a sysctl table hierarchy
  1951. * @path: The path to the directory the sysctl table is in.
  1952. * @table: the top-level table structure
  1953. *
  1954. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1955. * array. A completely 0 filled entry terminates the table.
  1956. *
  1957. * See __register_sysctl_paths for more details.
  1958. */
  1959. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  1960. struct ctl_table *table)
  1961. {
  1962. return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
  1963. path, table);
  1964. }
  1965. /**
  1966. * register_sysctl_table - register a sysctl table hierarchy
  1967. * @table: the top-level table structure
  1968. *
  1969. * Register a sysctl table hierarchy. @table should be a filled in ctl_table
  1970. * array. A completely 0 filled entry terminates the table.
  1971. *
  1972. * See register_sysctl_paths for more details.
  1973. */
  1974. struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
  1975. {
  1976. static const struct ctl_path null_path[] = { {} };
  1977. return register_sysctl_paths(null_path, table);
  1978. }
  1979. /**
  1980. * unregister_sysctl_table - unregister a sysctl table hierarchy
  1981. * @header: the header returned from register_sysctl_table
  1982. *
  1983. * Unregisters the sysctl table and all children. proc entries may not
  1984. * actually be removed until they are no longer used by anyone.
  1985. */
  1986. void unregister_sysctl_table(struct ctl_table_header * header)
  1987. {
  1988. might_sleep();
  1989. if (header == NULL)
  1990. return;
  1991. spin_lock(&sysctl_lock);
  1992. start_unregistering(header);
  1993. if (!--header->parent->count) {
  1994. WARN_ON(1);
  1995. kfree(header->parent);
  1996. }
  1997. if (!--header->count)
  1998. kfree(header);
  1999. spin_unlock(&sysctl_lock);
  2000. }
  2001. int sysctl_is_seen(struct ctl_table_header *p)
  2002. {
  2003. struct ctl_table_set *set = p->set;
  2004. int res;
  2005. spin_lock(&sysctl_lock);
  2006. if (p->unregistering)
  2007. res = 0;
  2008. else if (!set->is_seen)
  2009. res = 1;
  2010. else
  2011. res = set->is_seen(set);
  2012. spin_unlock(&sysctl_lock);
  2013. return res;
  2014. }
  2015. void setup_sysctl_set(struct ctl_table_set *p,
  2016. struct ctl_table_set *parent,
  2017. int (*is_seen)(struct ctl_table_set *))
  2018. {
  2019. INIT_LIST_HEAD(&p->list);
  2020. p->parent = parent ? parent : &sysctl_table_root.default_set;
  2021. p->is_seen = is_seen;
  2022. }
  2023. #else /* !CONFIG_SYSCTL */
  2024. struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
  2025. {
  2026. return NULL;
  2027. }
  2028. struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  2029. struct ctl_table *table)
  2030. {
  2031. return NULL;
  2032. }
  2033. void unregister_sysctl_table(struct ctl_table_header * table)
  2034. {
  2035. }
  2036. void setup_sysctl_set(struct ctl_table_set *p,
  2037. struct ctl_table_set *parent,
  2038. int (*is_seen)(struct ctl_table_set *))
  2039. {
  2040. }
  2041. void sysctl_head_put(struct ctl_table_header *head)
  2042. {
  2043. }
  2044. #endif /* CONFIG_SYSCTL */
  2045. /*
  2046. * /proc/sys support
  2047. */
  2048. #ifdef CONFIG_PROC_SYSCTL
  2049. static int _proc_do_string(void* data, int maxlen, int write,
  2050. struct file *filp, void __user *buffer,
  2051. size_t *lenp, loff_t *ppos)
  2052. {
  2053. size_t len;
  2054. char __user *p;
  2055. char c;
  2056. if (!data || !maxlen || !*lenp) {
  2057. *lenp = 0;
  2058. return 0;
  2059. }
  2060. if (write) {
  2061. len = 0;
  2062. p = buffer;
  2063. while (len < *lenp) {
  2064. if (get_user(c, p++))
  2065. return -EFAULT;
  2066. if (c == 0 || c == '\n')
  2067. break;
  2068. len++;
  2069. }
  2070. if (len >= maxlen)
  2071. len = maxlen-1;
  2072. if(copy_from_user(data, buffer, len))
  2073. return -EFAULT;
  2074. ((char *) data)[len] = 0;
  2075. *ppos += *lenp;
  2076. } else {
  2077. len = strlen(data);
  2078. if (len > maxlen)
  2079. len = maxlen;
  2080. if (*ppos > len) {
  2081. *lenp = 0;
  2082. return 0;
  2083. }
  2084. data += *ppos;
  2085. len -= *ppos;
  2086. if (len > *lenp)
  2087. len = *lenp;
  2088. if (len)
  2089. if(copy_to_user(buffer, data, len))
  2090. return -EFAULT;
  2091. if (len < *lenp) {
  2092. if(put_user('\n', ((char __user *) buffer) + len))
  2093. return -EFAULT;
  2094. len++;
  2095. }
  2096. *lenp = len;
  2097. *ppos += len;
  2098. }
  2099. return 0;
  2100. }
  2101. /**
  2102. * proc_dostring - read a string sysctl
  2103. * @table: the sysctl table
  2104. * @write: %TRUE if this is a write to the sysctl file
  2105. * @filp: the file structure
  2106. * @buffer: the user buffer
  2107. * @lenp: the size of the user buffer
  2108. * @ppos: file position
  2109. *
  2110. * Reads/writes a string from/to the user buffer. If the kernel
  2111. * buffer provided is not large enough to hold the string, the
  2112. * string is truncated. The copied string is %NULL-terminated.
  2113. * If the string is being read by the user process, it is copied
  2114. * and a newline '\n' is added. It is truncated if the buffer is
  2115. * not large enough.
  2116. *
  2117. * Returns 0 on success.
  2118. */
  2119. int proc_dostring(struct ctl_table *table, int write, struct file *filp,
  2120. void __user *buffer, size_t *lenp, loff_t *ppos)
  2121. {
  2122. return _proc_do_string(table->data, table->maxlen, write, filp,
  2123. buffer, lenp, ppos);
  2124. }
  2125. static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
  2126. int *valp,
  2127. int write, void *data)
  2128. {
  2129. if (write) {
  2130. *valp = *negp ? -*lvalp : *lvalp;
  2131. } else {
  2132. int val = *valp;
  2133. if (val < 0) {
  2134. *negp = -1;
  2135. *lvalp = (unsigned long)-val;
  2136. } else {
  2137. *negp = 0;
  2138. *lvalp = (unsigned long)val;
  2139. }
  2140. }
  2141. return 0;
  2142. }
  2143. static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
  2144. int write, struct file *filp, void __user *buffer,
  2145. size_t *lenp, loff_t *ppos,
  2146. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  2147. int write, void *data),
  2148. void *data)
  2149. {
  2150. #define TMPBUFLEN 21
  2151. int *i, vleft, first=1, neg, val;
  2152. unsigned long lval;
  2153. size_t left, len;
  2154. char buf[TMPBUFLEN], *p;
  2155. char __user *s = buffer;
  2156. if (!tbl_data || !table->maxlen || !*lenp ||
  2157. (*ppos && !write)) {
  2158. *lenp = 0;
  2159. return 0;
  2160. }
  2161. i = (int *) tbl_data;
  2162. vleft = table->maxlen / sizeof(*i);
  2163. left = *lenp;
  2164. if (!conv)
  2165. conv = do_proc_dointvec_conv;
  2166. for (; left && vleft--; i++, first=0) {
  2167. if (write) {
  2168. while (left) {
  2169. char c;
  2170. if (get_user(c, s))
  2171. return -EFAULT;
  2172. if (!isspace(c))
  2173. break;
  2174. left--;
  2175. s++;
  2176. }
  2177. if (!left)
  2178. break;
  2179. neg = 0;
  2180. len = left;
  2181. if (len > sizeof(buf) - 1)
  2182. len = sizeof(buf) - 1;
  2183. if (copy_from_user(buf, s, len))
  2184. return -EFAULT;
  2185. buf[len] = 0;
  2186. p = buf;
  2187. if (*p == '-' && left > 1) {
  2188. neg = 1;
  2189. p++;
  2190. }
  2191. if (*p < '0' || *p > '9')
  2192. break;
  2193. lval = simple_strtoul(p, &p, 0);
  2194. len = p-buf;
  2195. if ((len < left) && *p && !isspace(*p))
  2196. break;
  2197. if (neg)
  2198. val = -val;
  2199. s += len;
  2200. left -= len;
  2201. if (conv(&neg, &lval, i, 1, data))
  2202. break;
  2203. } else {
  2204. p = buf;
  2205. if (!first)
  2206. *p++ = '\t';
  2207. if (conv(&neg, &lval, i, 0, data))
  2208. break;
  2209. sprintf(p, "%s%lu", neg ? "-" : "", lval);
  2210. len = strlen(buf);
  2211. if (len > left)
  2212. len = left;
  2213. if(copy_to_user(s, buf, len))
  2214. return -EFAULT;
  2215. left -= len;
  2216. s += len;
  2217. }
  2218. }
  2219. if (!write && !first && left) {
  2220. if(put_user('\n', s))
  2221. return -EFAULT;
  2222. left--, s++;
  2223. }
  2224. if (write) {
  2225. while (left) {
  2226. char c;
  2227. if (get_user(c, s++))
  2228. return -EFAULT;
  2229. if (!isspace(c))
  2230. break;
  2231. left--;
  2232. }
  2233. }
  2234. if (write && first)
  2235. return -EINVAL;
  2236. *lenp -= left;
  2237. *ppos += *lenp;
  2238. return 0;
  2239. #undef TMPBUFLEN
  2240. }
  2241. static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
  2242. void __user *buffer, size_t *lenp, loff_t *ppos,
  2243. int (*conv)(int *negp, unsigned long *lvalp, int *valp,
  2244. int write, void *data),
  2245. void *data)
  2246. {
  2247. return __do_proc_dointvec(table->data, table, write, filp,
  2248. buffer, lenp, ppos, conv, data);
  2249. }
  2250. /**
  2251. * proc_dointvec - read a vector of integers
  2252. * @table: the sysctl table
  2253. * @write: %TRUE if this is a write to the sysctl file
  2254. * @filp: the file structure
  2255. * @buffer: the user buffer
  2256. * @lenp: the size of the user buffer
  2257. * @ppos: file position
  2258. *
  2259. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2260. * values from/to the user buffer, treated as an ASCII string.
  2261. *
  2262. * Returns 0 on success.
  2263. */
  2264. int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
  2265. void __user *buffer, size_t *lenp, loff_t *ppos)
  2266. {
  2267. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2268. NULL,NULL);
  2269. }
  2270. /*
  2271. * Taint values can only be increased
  2272. * This means we can safely use a temporary.
  2273. */
  2274. static int proc_taint(struct ctl_table *table, int write, struct file *filp,
  2275. void __user *buffer, size_t *lenp, loff_t *ppos)
  2276. {
  2277. struct ctl_table t;
  2278. unsigned long tmptaint = get_taint();
  2279. int err;
  2280. if (write && !capable(CAP_SYS_ADMIN))
  2281. return -EPERM;
  2282. t = *table;
  2283. t.data = &tmptaint;
  2284. err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
  2285. if (err < 0)
  2286. return err;
  2287. if (write) {
  2288. /*
  2289. * Poor man's atomic or. Not worth adding a primitive
  2290. * to everyone's atomic.h for this
  2291. */
  2292. int i;
  2293. for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
  2294. if ((tmptaint >> i) & 1)
  2295. add_taint(i);
  2296. }
  2297. }
  2298. return err;
  2299. }
  2300. struct do_proc_dointvec_minmax_conv_param {
  2301. int *min;
  2302. int *max;
  2303. };
  2304. static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
  2305. int *valp,
  2306. int write, void *data)
  2307. {
  2308. struct do_proc_dointvec_minmax_conv_param *param = data;
  2309. if (write) {
  2310. int val = *negp ? -*lvalp : *lvalp;
  2311. if ((param->min && *param->min > val) ||
  2312. (param->max && *param->max < val))
  2313. return -EINVAL;
  2314. *valp = val;
  2315. } else {
  2316. int val = *valp;
  2317. if (val < 0) {
  2318. *negp = -1;
  2319. *lvalp = (unsigned long)-val;
  2320. } else {
  2321. *negp = 0;
  2322. *lvalp = (unsigned long)val;
  2323. }
  2324. }
  2325. return 0;
  2326. }
  2327. /**
  2328. * proc_dointvec_minmax - read a vector of integers with min/max values
  2329. * @table: the sysctl table
  2330. * @write: %TRUE if this is a write to the sysctl file
  2331. * @filp: the file structure
  2332. * @buffer: the user buffer
  2333. * @lenp: the size of the user buffer
  2334. * @ppos: file position
  2335. *
  2336. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2337. * values from/to the user buffer, treated as an ASCII string.
  2338. *
  2339. * This routine will ensure the values are within the range specified by
  2340. * table->extra1 (min) and table->extra2 (max).
  2341. *
  2342. * Returns 0 on success.
  2343. */
  2344. int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
  2345. void __user *buffer, size_t *lenp, loff_t *ppos)
  2346. {
  2347. struct do_proc_dointvec_minmax_conv_param param = {
  2348. .min = (int *) table->extra1,
  2349. .max = (int *) table->extra2,
  2350. };
  2351. return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
  2352. do_proc_dointvec_minmax_conv, &param);
  2353. }
  2354. static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
  2355. struct file *filp,
  2356. void __user *buffer,
  2357. size_t *lenp, loff_t *ppos,
  2358. unsigned long convmul,
  2359. unsigned long convdiv)
  2360. {
  2361. #define TMPBUFLEN 21
  2362. unsigned long *i, *min, *max, val;
  2363. int vleft, first=1, neg;
  2364. size_t len, left;
  2365. char buf[TMPBUFLEN], *p;
  2366. char __user *s = buffer;
  2367. if (!data || !table->maxlen || !*lenp ||
  2368. (*ppos && !write)) {
  2369. *lenp = 0;
  2370. return 0;
  2371. }
  2372. i = (unsigned long *) data;
  2373. min = (unsigned long *) table->extra1;
  2374. max = (unsigned long *) table->extra2;
  2375. vleft = table->maxlen / sizeof(unsigned long);
  2376. left = *lenp;
  2377. for (; left && vleft--; i++, min++, max++, first=0) {
  2378. if (write) {
  2379. while (left) {
  2380. char c;
  2381. if (get_user(c, s))
  2382. return -EFAULT;
  2383. if (!isspace(c))
  2384. break;
  2385. left--;
  2386. s++;
  2387. }
  2388. if (!left)
  2389. break;
  2390. neg = 0;
  2391. len = left;
  2392. if (len > TMPBUFLEN-1)
  2393. len = TMPBUFLEN-1;
  2394. if (copy_from_user(buf, s, len))
  2395. return -EFAULT;
  2396. buf[len] = 0;
  2397. p = buf;
  2398. if (*p == '-' && left > 1) {
  2399. neg = 1;
  2400. p++;
  2401. }
  2402. if (*p < '0' || *p > '9')
  2403. break;
  2404. val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
  2405. len = p-buf;
  2406. if ((len < left) && *p && !isspace(*p))
  2407. break;
  2408. if (neg)
  2409. val = -val;
  2410. s += len;
  2411. left -= len;
  2412. if(neg)
  2413. continue;
  2414. if ((min && val < *min) || (max && val > *max))
  2415. continue;
  2416. *i = val;
  2417. } else {
  2418. p = buf;
  2419. if (!first)
  2420. *p++ = '\t';
  2421. sprintf(p, "%lu", convdiv * (*i) / convmul);
  2422. len = strlen(buf);
  2423. if (len > left)
  2424. len = left;
  2425. if(copy_to_user(s, buf, len))
  2426. return -EFAULT;
  2427. left -= len;
  2428. s += len;
  2429. }
  2430. }
  2431. if (!write && !first && left) {
  2432. if(put_user('\n', s))
  2433. return -EFAULT;
  2434. left--, s++;
  2435. }
  2436. if (write) {
  2437. while (left) {
  2438. char c;
  2439. if (get_user(c, s++))
  2440. return -EFAULT;
  2441. if (!isspace(c))
  2442. break;
  2443. left--;
  2444. }
  2445. }
  2446. if (write && first)
  2447. return -EINVAL;
  2448. *lenp -= left;
  2449. *ppos += *lenp;
  2450. return 0;
  2451. #undef TMPBUFLEN
  2452. }
  2453. static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
  2454. struct file *filp,
  2455. void __user *buffer,
  2456. size_t *lenp, loff_t *ppos,
  2457. unsigned long convmul,
  2458. unsigned long convdiv)
  2459. {
  2460. return __do_proc_doulongvec_minmax(table->data, table, write,
  2461. filp, buffer, lenp, ppos, convmul, convdiv);
  2462. }
  2463. /**
  2464. * proc_doulongvec_minmax - read a vector of long integers with min/max values
  2465. * @table: the sysctl table
  2466. * @write: %TRUE if this is a write to the sysctl file
  2467. * @filp: the file structure
  2468. * @buffer: the user buffer
  2469. * @lenp: the size of the user buffer
  2470. * @ppos: file position
  2471. *
  2472. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2473. * values from/to the user buffer, treated as an ASCII string.
  2474. *
  2475. * This routine will ensure the values are within the range specified by
  2476. * table->extra1 (min) and table->extra2 (max).
  2477. *
  2478. * Returns 0 on success.
  2479. */
  2480. int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
  2481. void __user *buffer, size_t *lenp, loff_t *ppos)
  2482. {
  2483. return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
  2484. }
  2485. /**
  2486. * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
  2487. * @table: the sysctl table
  2488. * @write: %TRUE if this is a write to the sysctl file
  2489. * @filp: the file structure
  2490. * @buffer: the user buffer
  2491. * @lenp: the size of the user buffer
  2492. * @ppos: file position
  2493. *
  2494. * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
  2495. * values from/to the user buffer, treated as an ASCII string. The values
  2496. * are treated as milliseconds, and converted to jiffies when they are stored.
  2497. *
  2498. * This routine will ensure the values are within the range specified by
  2499. * table->extra1 (min) and table->extra2 (max).
  2500. *
  2501. * Returns 0 on success.
  2502. */
  2503. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2504. struct file *filp,
  2505. void __user *buffer,
  2506. size_t *lenp, loff_t *ppos)
  2507. {
  2508. return do_proc_doulongvec_minmax(table, write, filp, buffer,
  2509. lenp, ppos, HZ, 1000l);
  2510. }
  2511. static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
  2512. int *valp,
  2513. int write, void *data)
  2514. {
  2515. if (write) {
  2516. if (*lvalp > LONG_MAX / HZ)
  2517. return 1;
  2518. *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
  2519. } else {
  2520. int val = *valp;
  2521. unsigned long lval;
  2522. if (val < 0) {
  2523. *negp = -1;
  2524. lval = (unsigned long)-val;
  2525. } else {
  2526. *negp = 0;
  2527. lval = (unsigned long)val;
  2528. }
  2529. *lvalp = lval / HZ;
  2530. }
  2531. return 0;
  2532. }
  2533. static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
  2534. int *valp,
  2535. int write, void *data)
  2536. {
  2537. if (write) {
  2538. if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
  2539. return 1;
  2540. *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
  2541. } else {
  2542. int val = *valp;
  2543. unsigned long lval;
  2544. if (val < 0) {
  2545. *negp = -1;
  2546. lval = (unsigned long)-val;
  2547. } else {
  2548. *negp = 0;
  2549. lval = (unsigned long)val;
  2550. }
  2551. *lvalp = jiffies_to_clock_t(lval);
  2552. }
  2553. return 0;
  2554. }
  2555. static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
  2556. int *valp,
  2557. int write, void *data)
  2558. {
  2559. if (write) {
  2560. *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
  2561. } else {
  2562. int val = *valp;
  2563. unsigned long lval;
  2564. if (val < 0) {
  2565. *negp = -1;
  2566. lval = (unsigned long)-val;
  2567. } else {
  2568. *negp = 0;
  2569. lval = (unsigned long)val;
  2570. }
  2571. *lvalp = jiffies_to_msecs(lval);
  2572. }
  2573. return 0;
  2574. }
  2575. /**
  2576. * proc_dointvec_jiffies - read a vector of integers as seconds
  2577. * @table: the sysctl table
  2578. * @write: %TRUE if this is a write to the sysctl file
  2579. * @filp: the file structure
  2580. * @buffer: the user buffer
  2581. * @lenp: the size of the user buffer
  2582. * @ppos: file position
  2583. *
  2584. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2585. * values from/to the user buffer, treated as an ASCII string.
  2586. * The values read are assumed to be in seconds, and are converted into
  2587. * jiffies.
  2588. *
  2589. * Returns 0 on success.
  2590. */
  2591. int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
  2592. void __user *buffer, size_t *lenp, loff_t *ppos)
  2593. {
  2594. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2595. do_proc_dointvec_jiffies_conv,NULL);
  2596. }
  2597. /**
  2598. * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
  2599. * @table: the sysctl table
  2600. * @write: %TRUE if this is a write to the sysctl file
  2601. * @filp: the file structure
  2602. * @buffer: the user buffer
  2603. * @lenp: the size of the user buffer
  2604. * @ppos: pointer to the file position
  2605. *
  2606. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2607. * values from/to the user buffer, treated as an ASCII string.
  2608. * The values read are assumed to be in 1/USER_HZ seconds, and
  2609. * are converted into jiffies.
  2610. *
  2611. * Returns 0 on success.
  2612. */
  2613. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
  2614. void __user *buffer, size_t *lenp, loff_t *ppos)
  2615. {
  2616. return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
  2617. do_proc_dointvec_userhz_jiffies_conv,NULL);
  2618. }
  2619. /**
  2620. * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
  2621. * @table: the sysctl table
  2622. * @write: %TRUE if this is a write to the sysctl file
  2623. * @filp: the file structure
  2624. * @buffer: the user buffer
  2625. * @lenp: the size of the user buffer
  2626. * @ppos: file position
  2627. * @ppos: the current position in the file
  2628. *
  2629. * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
  2630. * values from/to the user buffer, treated as an ASCII string.
  2631. * The values read are assumed to be in 1/1000 seconds, and
  2632. * are converted into jiffies.
  2633. *
  2634. * Returns 0 on success.
  2635. */
  2636. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
  2637. void __user *buffer, size_t *lenp, loff_t *ppos)
  2638. {
  2639. return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
  2640. do_proc_dointvec_ms_jiffies_conv, NULL);
  2641. }
  2642. static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
  2643. void __user *buffer, size_t *lenp, loff_t *ppos)
  2644. {
  2645. struct pid *new_pid;
  2646. pid_t tmp;
  2647. int r;
  2648. tmp = pid_vnr(cad_pid);
  2649. r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
  2650. lenp, ppos, NULL, NULL);
  2651. if (r || !write)
  2652. return r;
  2653. new_pid = find_get_pid(tmp);
  2654. if (!new_pid)
  2655. return -ESRCH;
  2656. put_pid(xchg(&cad_pid, new_pid));
  2657. return 0;
  2658. }
  2659. #else /* CONFIG_PROC_FS */
  2660. int proc_dostring(struct ctl_table *table, int write, struct file *filp,
  2661. void __user *buffer, size_t *lenp, loff_t *ppos)
  2662. {
  2663. return -ENOSYS;
  2664. }
  2665. int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
  2666. void __user *buffer, size_t *lenp, loff_t *ppos)
  2667. {
  2668. return -ENOSYS;
  2669. }
  2670. int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
  2671. void __user *buffer, size_t *lenp, loff_t *ppos)
  2672. {
  2673. return -ENOSYS;
  2674. }
  2675. int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
  2676. void __user *buffer, size_t *lenp, loff_t *ppos)
  2677. {
  2678. return -ENOSYS;
  2679. }
  2680. int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
  2681. void __user *buffer, size_t *lenp, loff_t *ppos)
  2682. {
  2683. return -ENOSYS;
  2684. }
  2685. int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
  2686. void __user *buffer, size_t *lenp, loff_t *ppos)
  2687. {
  2688. return -ENOSYS;
  2689. }
  2690. int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
  2691. void __user *buffer, size_t *lenp, loff_t *ppos)
  2692. {
  2693. return -ENOSYS;
  2694. }
  2695. int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
  2696. struct file *filp,
  2697. void __user *buffer,
  2698. size_t *lenp, loff_t *ppos)
  2699. {
  2700. return -ENOSYS;
  2701. }
  2702. #endif /* CONFIG_PROC_FS */
  2703. #ifdef CONFIG_SYSCTL_SYSCALL
  2704. /*
  2705. * General sysctl support routines
  2706. */
  2707. /* The generic sysctl data routine (used if no strategy routine supplied) */
  2708. int sysctl_data(struct ctl_table *table,
  2709. void __user *oldval, size_t __user *oldlenp,
  2710. void __user *newval, size_t newlen)
  2711. {
  2712. size_t len;
  2713. /* Get out of I don't have a variable */
  2714. if (!table->data || !table->maxlen)
  2715. return -ENOTDIR;
  2716. if (oldval && oldlenp) {
  2717. if (get_user(len, oldlenp))
  2718. return -EFAULT;
  2719. if (len) {
  2720. if (len > table->maxlen)
  2721. len = table->maxlen;
  2722. if (copy_to_user(oldval, table->data, len))
  2723. return -EFAULT;
  2724. if (put_user(len, oldlenp))
  2725. return -EFAULT;
  2726. }
  2727. }
  2728. if (newval && newlen) {
  2729. if (newlen > table->maxlen)
  2730. newlen = table->maxlen;
  2731. if (copy_from_user(table->data, newval, newlen))
  2732. return -EFAULT;
  2733. }
  2734. return 1;
  2735. }
  2736. /* The generic string strategy routine: */
  2737. int sysctl_string(struct ctl_table *table,
  2738. void __user *oldval, size_t __user *oldlenp,
  2739. void __user *newval, size_t newlen)
  2740. {
  2741. if (!table->data || !table->maxlen)
  2742. return -ENOTDIR;
  2743. if (oldval && oldlenp) {
  2744. size_t bufsize;
  2745. if (get_user(bufsize, oldlenp))
  2746. return -EFAULT;
  2747. if (bufsize) {
  2748. size_t len = strlen(table->data), copied;
  2749. /* This shouldn't trigger for a well-formed sysctl */
  2750. if (len > table->maxlen)
  2751. len = table->maxlen;
  2752. /* Copy up to a max of bufsize-1 bytes of the string */
  2753. copied = (len >= bufsize) ? bufsize - 1 : len;
  2754. if (copy_to_user(oldval, table->data, copied) ||
  2755. put_user(0, (char __user *)(oldval + copied)))
  2756. return -EFAULT;
  2757. if (put_user(len, oldlenp))
  2758. return -EFAULT;
  2759. }
  2760. }
  2761. if (newval && newlen) {
  2762. size_t len = newlen;
  2763. if (len > table->maxlen)
  2764. len = table->maxlen;
  2765. if(copy_from_user(table->data, newval, len))
  2766. return -EFAULT;
  2767. if (len == table->maxlen)
  2768. len--;
  2769. ((char *) table->data)[len] = 0;
  2770. }
  2771. return 1;
  2772. }
  2773. /*
  2774. * This function makes sure that all of the integers in the vector
  2775. * are between the minimum and maximum values given in the arrays
  2776. * table->extra1 and table->extra2, respectively.
  2777. */
  2778. int sysctl_intvec(struct ctl_table *table,
  2779. void __user *oldval, size_t __user *oldlenp,
  2780. void __user *newval, size_t newlen)
  2781. {
  2782. if (newval && newlen) {
  2783. int __user *vec = (int __user *) newval;
  2784. int *min = (int *) table->extra1;
  2785. int *max = (int *) table->extra2;
  2786. size_t length;
  2787. int i;
  2788. if (newlen % sizeof(int) != 0)
  2789. return -EINVAL;
  2790. if (!table->extra1 && !table->extra2)
  2791. return 0;
  2792. if (newlen > table->maxlen)
  2793. newlen = table->maxlen;
  2794. length = newlen / sizeof(int);
  2795. for (i = 0; i < length; i++) {
  2796. int value;
  2797. if (get_user(value, vec + i))
  2798. return -EFAULT;
  2799. if (min && value < min[i])
  2800. return -EINVAL;
  2801. if (max && value > max[i])
  2802. return -EINVAL;
  2803. }
  2804. }
  2805. return 0;
  2806. }
  2807. /* Strategy function to convert jiffies to seconds */
  2808. int sysctl_jiffies(struct ctl_table *table,
  2809. void __user *oldval, size_t __user *oldlenp,
  2810. void __user *newval, size_t newlen)
  2811. {
  2812. if (oldval && oldlenp) {
  2813. size_t olen;
  2814. if (get_user(olen, oldlenp))
  2815. return -EFAULT;
  2816. if (olen) {
  2817. int val;
  2818. if (olen < sizeof(int))
  2819. return -EINVAL;
  2820. val = *(int *)(table->data) / HZ;
  2821. if (put_user(val, (int __user *)oldval))
  2822. return -EFAULT;
  2823. if (put_user(sizeof(int), oldlenp))
  2824. return -EFAULT;
  2825. }
  2826. }
  2827. if (newval && newlen) {
  2828. int new;
  2829. if (newlen != sizeof(int))
  2830. return -EINVAL;
  2831. if (get_user(new, (int __user *)newval))
  2832. return -EFAULT;
  2833. *(int *)(table->data) = new*HZ;
  2834. }
  2835. return 1;
  2836. }
  2837. /* Strategy function to convert jiffies to seconds */
  2838. int sysctl_ms_jiffies(struct ctl_table *table,
  2839. void __user *oldval, size_t __user *oldlenp,
  2840. void __user *newval, size_t newlen)
  2841. {
  2842. if (oldval && oldlenp) {
  2843. size_t olen;
  2844. if (get_user(olen, oldlenp))
  2845. return -EFAULT;
  2846. if (olen) {
  2847. int val;
  2848. if (olen < sizeof(int))
  2849. return -EINVAL;
  2850. val = jiffies_to_msecs(*(int *)(table->data));
  2851. if (put_user(val, (int __user *)oldval))
  2852. return -EFAULT;
  2853. if (put_user(sizeof(int), oldlenp))
  2854. return -EFAULT;
  2855. }
  2856. }
  2857. if (newval && newlen) {
  2858. int new;
  2859. if (newlen != sizeof(int))
  2860. return -EINVAL;
  2861. if (get_user(new, (int __user *)newval))
  2862. return -EFAULT;
  2863. *(int *)(table->data) = msecs_to_jiffies(new);
  2864. }
  2865. return 1;
  2866. }
  2867. #else /* CONFIG_SYSCTL_SYSCALL */
  2868. SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
  2869. {
  2870. struct __sysctl_args tmp;
  2871. int error;
  2872. if (copy_from_user(&tmp, args, sizeof(tmp)))
  2873. return -EFAULT;
  2874. error = deprecated_sysctl_warning(&tmp);
  2875. /* If no error reading the parameters then just -ENOSYS ... */
  2876. if (!error)
  2877. error = -ENOSYS;
  2878. return error;
  2879. }
  2880. int sysctl_data(struct ctl_table *table,
  2881. void __user *oldval, size_t __user *oldlenp,
  2882. void __user *newval, size_t newlen)
  2883. {
  2884. return -ENOSYS;
  2885. }
  2886. int sysctl_string(struct ctl_table *table,
  2887. void __user *oldval, size_t __user *oldlenp,
  2888. void __user *newval, size_t newlen)
  2889. {
  2890. return -ENOSYS;
  2891. }
  2892. int sysctl_intvec(struct ctl_table *table,
  2893. void __user *oldval, size_t __user *oldlenp,
  2894. void __user *newval, size_t newlen)
  2895. {
  2896. return -ENOSYS;
  2897. }
  2898. int sysctl_jiffies(struct ctl_table *table,
  2899. void __user *oldval, size_t __user *oldlenp,
  2900. void __user *newval, size_t newlen)
  2901. {
  2902. return -ENOSYS;
  2903. }
  2904. int sysctl_ms_jiffies(struct ctl_table *table,
  2905. void __user *oldval, size_t __user *oldlenp,
  2906. void __user *newval, size_t newlen)
  2907. {
  2908. return -ENOSYS;
  2909. }
  2910. #endif /* CONFIG_SYSCTL_SYSCALL */
  2911. static int deprecated_sysctl_warning(struct __sysctl_args *args)
  2912. {
  2913. static int msg_count;
  2914. int name[CTL_MAXNAME];
  2915. int i;
  2916. /* Check args->nlen. */
  2917. if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
  2918. return -ENOTDIR;
  2919. /* Read in the sysctl name for better debug message logging */
  2920. for (i = 0; i < args->nlen; i++)
  2921. if (get_user(name[i], args->name + i))
  2922. return -EFAULT;
  2923. /* Ignore accesses to kernel.version */
  2924. if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
  2925. return 0;
  2926. if (msg_count < 5) {
  2927. msg_count++;
  2928. printk(KERN_INFO
  2929. "warning: process `%s' used the deprecated sysctl "
  2930. "system call with ", current->comm);
  2931. for (i = 0; i < args->nlen; i++)
  2932. printk("%d.", name[i]);
  2933. printk("\n");
  2934. }
  2935. return 0;
  2936. }
  2937. /*
  2938. * No sense putting this after each symbol definition, twice,
  2939. * exception granted :-)
  2940. */
  2941. EXPORT_SYMBOL(proc_dointvec);
  2942. EXPORT_SYMBOL(proc_dointvec_jiffies);
  2943. EXPORT_SYMBOL(proc_dointvec_minmax);
  2944. EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
  2945. EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
  2946. EXPORT_SYMBOL(proc_dostring);
  2947. EXPORT_SYMBOL(proc_doulongvec_minmax);
  2948. EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
  2949. EXPORT_SYMBOL(register_sysctl_table);
  2950. EXPORT_SYMBOL(register_sysctl_paths);
  2951. EXPORT_SYMBOL(sysctl_intvec);
  2952. EXPORT_SYMBOL(sysctl_jiffies);
  2953. EXPORT_SYMBOL(sysctl_ms_jiffies);
  2954. EXPORT_SYMBOL(sysctl_string);
  2955. EXPORT_SYMBOL(sysctl_data);
  2956. EXPORT_SYMBOL(unregister_sysctl_table);