sysctl.c 75 KB

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