sysctl.c 74 KB

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