sysctl.c 75 KB

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