sysctl.c 75 KB

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