sysctl.c 75 KB

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