sysctl.c 74 KB

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