sysctl.c 75 KB

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