Advertisement
Guest User

Untitled

a guest
Aug 12th, 2015
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.67 KB | None | 0 0
  1. From f21b5d48ee6a548f8c2ff6221b6ba9f28b08c7d1 Mon Sep 17 00:00:00 2001
  2. From: Andrew Perepechko <panda@cloudlinux.com>
  3. Date: Tue, 30 Dec 2014 20:18:24 +0300
  4. Subject: [PATCH 02/10] initial lve commit
  5.  
  6. ---
  7. fs/fs_struct.c | 1 +
  8. fs/namespace.c | 1 +
  9. include/linux/nsproxy.h | 1 +
  10. include/linux/ve.h | 2 ++
  11. kernel/bc/beancounter.c | 2 ++
  12. kernel/cgroup.c | 2 +-
  13. kernel/nsproxy.c | 17 +++++++++++++++++
  14. kernel/pid.c | 1 +
  15. 8 files changed, 26 insertions(+), 1 deletion(-)
  16.  
  17. diff --git a/fs/fs_struct.c b/fs/fs_struct.c
  18. index 339934e..296406b 100644
  19. --- a/fs/fs_struct.c
  20. +++ b/fs/fs_struct.c
  21. @@ -90,6 +90,7 @@ void free_fs_struct(struct fs_struct *fs)
  22. path_put(&fs->pwd);
  23. kmem_cache_free(fs_cachep, fs);
  24. }
  25. +EXPORT_SYMBOL(free_fs_struct);
  26.  
  27. void exit_fs(struct task_struct *tsk)
  28. {
  29. diff --git a/fs/namespace.c b/fs/namespace.c
  30. index aff3577..942ba23 100644
  31. --- a/fs/namespace.c
  32. +++ b/fs/namespace.c
  33. @@ -2769,6 +2769,7 @@ void put_mnt_ns(struct mnt_namespace *ns)
  34. namespace_unlock();
  35. free_mnt_ns(ns);
  36. }
  37. +EXPORT_SYMBOL(put_mnt_ns);
  38.  
  39. struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
  40. {
  41. diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
  42. index 9d529ab..380e750 100644
  43. --- a/include/linux/nsproxy.h
  44. +++ b/include/linux/nsproxy.h
  45. @@ -62,6 +62,7 @@ static inline struct nsproxy *task_nsproxy(struct task_struct *tsk)
  46. return rcu_dereference(tsk->nsproxy);
  47. }
  48.  
  49. +struct nsproxy *duplicate_nsproxy(struct nsproxy *nsproxy);
  50. int copy_namespaces(unsigned long flags, struct task_struct *tsk, int force_admin);
  51. void exit_task_namespaces(struct task_struct *tsk);
  52. void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
  53. diff --git a/include/linux/ve.h b/include/linux/ve.h
  54. index 6637dd5..3474540 100644
  55. --- a/include/linux/ve.h
  56. +++ b/include/linux/ve.h
  57. @@ -130,6 +130,8 @@ struct ve_struct {
  58. #if IS_ENABLED(CONFIG_DEVTMPFS)
  59. struct path devtmpfs_root;
  60. #endif
  61. +
  62. + void *lve;
  63. };
  64.  
  65. #define VE_MEMINFO_DEFAULT 1 /* default behaviour */
  66. diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
  67. index 417e2c0..362cf4e 100644
  68. --- a/kernel/bc/beancounter.c
  69. +++ b/kernel/bc/beancounter.c
  70. @@ -400,6 +400,7 @@ struct user_beancounter *get_beancounter_by_name(const char *name, int create)
  71. cgroup_kernel_close(cg);
  72. return ub;
  73. }
  74. +EXPORT_SYMBOL(get_beancounter_by_name);
  75.  
  76. struct user_beancounter *get_beancounter_byuid(uid_t uid, int create)
  77. {
  78. @@ -408,6 +409,7 @@ struct user_beancounter *get_beancounter_byuid(uid_t uid, int create)
  79. snprintf(name, sizeof(name), "%u", uid);
  80. return get_beancounter_by_name(name, create);
  81. }
  82. +EXPORT_SYMBOL(get_beancounter_byuid);
  83.  
  84. uid_t ub_legacy_id(struct user_beancounter *ub)
  85. {
  86. diff --git a/kernel/cgroup.c b/kernel/cgroup.c
  87. index ce08ef9..dda4b79 100644
  88. --- a/kernel/cgroup.c
  89. +++ b/kernel/cgroup.c
  90. @@ -5158,7 +5158,7 @@ void __css_put(struct cgroup_subsys_state *css)
  91. if (v == 0)
  92. queue_work(cgroup_destroy_wq, &css->dput_work);
  93. }
  94. -EXPORT_SYMBOL_GPL(__css_put);
  95. +EXPORT_SYMBOL(__css_put);
  96.  
  97. /*
  98. * Notify userspace when a cgroup is released, by running the
  99. diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
  100. index 875cb82..71dc279 100644
  101. --- a/kernel/nsproxy.c
  102. +++ b/kernel/nsproxy.c
  103. @@ -26,6 +26,8 @@
  104. #include <linux/file.h>
  105. #include <linux/syscalls.h>
  106.  
  107. +#include "../fs/mount.h"
  108. +
  109. static struct kmem_cache *nsproxy_cachep;
  110.  
  111. struct nsproxy init_nsproxy = {
  112. @@ -59,6 +61,21 @@ static inline struct nsproxy *create_nsproxy(void)
  113. return nsproxy;
  114. }
  115.  
  116. +struct nsproxy *duplicate_nsproxy(struct nsproxy *nsproxy)
  117. +{
  118. + struct nsproxy *ns = create_nsproxy();
  119. + if (ns) {
  120. + *ns = *nsproxy;
  121. + atomic_set(&ns->count, 1);
  122. + get_uts_ns(ns->uts_ns);
  123. + get_ipc_ns(ns->ipc_ns);
  124. + get_mnt_ns(ns->mnt_ns);
  125. + get_pid_ns(ns->pid_ns);
  126. + get_net(ns->net_ns);
  127. + }
  128. + return ns;
  129. +}
  130. +
  131. /*
  132. * Create new nsproxy and all of its the associated namespaces.
  133. * Return the newly created nsproxy. Do not attach this to the task,
  134. diff --git a/kernel/pid.c b/kernel/pid.c
  135. index 2e11ac4..fe178dd 100644
  136. --- a/kernel/pid.c
  137. +++ b/kernel/pid.c
  138. @@ -495,6 +495,7 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
  139. {
  140. return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
  141. }
  142. +EXPORT_SYMBOL(find_task_by_vpid);
  143.  
  144. struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
  145. {
  146. --
  147. 1.9.1
  148.  
  149. From 45c6976de863b8b746e3fe2353d800037cdfc97d Mon Sep 17 00:00:00 2001
  150. From: root <root@localhost.localdomain>
  151. Date: Sun, 28 Dec 2014 17:31:27 -0500
  152. Subject: [PATCH 03/10] CL7: remove unnecessary export
  153.  
  154. ---
  155. fs/fs_struct.c | 1 -
  156. fs/namespace.c | 1 -
  157. kernel/bc/beancounter.c | 2 --
  158. kernel/pid.c | 1 -
  159. 4 files changed, 5 deletions(-)
  160.  
  161. diff --git a/fs/fs_struct.c b/fs/fs_struct.c
  162. index 296406b..339934e 100644
  163. --- a/fs/fs_struct.c
  164. +++ b/fs/fs_struct.c
  165. @@ -90,7 +90,6 @@ void free_fs_struct(struct fs_struct *fs)
  166. path_put(&fs->pwd);
  167. kmem_cache_free(fs_cachep, fs);
  168. }
  169. -EXPORT_SYMBOL(free_fs_struct);
  170.  
  171. void exit_fs(struct task_struct *tsk)
  172. {
  173. diff --git a/fs/namespace.c b/fs/namespace.c
  174. index 942ba23..aff3577 100644
  175. --- a/fs/namespace.c
  176. +++ b/fs/namespace.c
  177. @@ -2769,7 +2769,6 @@ void put_mnt_ns(struct mnt_namespace *ns)
  178. namespace_unlock();
  179. free_mnt_ns(ns);
  180. }
  181. -EXPORT_SYMBOL(put_mnt_ns);
  182.  
  183. struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
  184. {
  185. diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
  186. index 362cf4e..417e2c0 100644
  187. --- a/kernel/bc/beancounter.c
  188. +++ b/kernel/bc/beancounter.c
  189. @@ -400,7 +400,6 @@ struct user_beancounter *get_beancounter_by_name(const char *name, int create)
  190. cgroup_kernel_close(cg);
  191. return ub;
  192. }
  193. -EXPORT_SYMBOL(get_beancounter_by_name);
  194.  
  195. struct user_beancounter *get_beancounter_byuid(uid_t uid, int create)
  196. {
  197. @@ -409,7 +408,6 @@ struct user_beancounter *get_beancounter_byuid(uid_t uid, int create)
  198. snprintf(name, sizeof(name), "%u", uid);
  199. return get_beancounter_by_name(name, create);
  200. }
  201. -EXPORT_SYMBOL(get_beancounter_byuid);
  202.  
  203. uid_t ub_legacy_id(struct user_beancounter *ub)
  204. {
  205. diff --git a/kernel/pid.c b/kernel/pid.c
  206. index fe178dd..2e11ac4 100644
  207. --- a/kernel/pid.c
  208. +++ b/kernel/pid.c
  209. @@ -495,7 +495,6 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
  210. {
  211. return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
  212. }
  213. -EXPORT_SYMBOL(find_task_by_vpid);
  214.  
  215. struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
  216. {
  217. --
  218. 1.9.1
  219.  
  220. From 6c97e5018c74b81a2fa79f7e5dd1d3ce73251044 Mon Sep 17 00:00:00 2001
  221. From: root <root@localhost.localdomain>
  222. Date: Mon, 29 Dec 2014 17:11:14 -0500
  223. Subject: [PATCH 04/10] CL7: drop GPL license
  224.  
  225. ---
  226. kernel/lockdep.c | 24 ++++++++++++------------
  227. kernel/rcupdate.c | 26 +++++++++++++-------------
  228. kernel/rcutree.c | 2 +-
  229. 3 files changed, 26 insertions(+), 26 deletions(-)
  230.  
  231. diff --git a/kernel/lockdep.c b/kernel/lockdep.c
  232. index c3de86d..919f121 100644
  233. --- a/kernel/lockdep.c
  234. +++ b/kernel/lockdep.c
  235. @@ -2998,7 +2998,7 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
  236. EXPORT_SYMBOL(lockdep_init_map);
  237.  
  238. struct lock_class_key __lockdep_no_validate__;
  239. -EXPORT_SYMBOL_GPL(__lockdep_no_validate__);
  240. +EXPORT_SYMBOL(__lockdep_no_validate__);
  241.  
  242. static int
  243. print_lock_nested_lock_not_held(struct task_struct *curr,
  244. @@ -3578,7 +3578,7 @@ void lock_set_class(struct lockdep_map *lock, const char *name,
  245. current->lockdep_recursion = 0;
  246. raw_local_irq_restore(flags);
  247. }
  248. -EXPORT_SYMBOL_GPL(lock_set_class);
  249. +EXPORT_SYMBOL(lock_set_class);
  250.  
  251. /*
  252. * We are not always called with irqs disabled - do that here,
  253. @@ -3603,7 +3603,7 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
  254. current->lockdep_recursion = 0;
  255. raw_local_irq_restore(flags);
  256. }
  257. -EXPORT_SYMBOL_GPL(lock_acquire);
  258. +EXPORT_SYMBOL(lock_acquire);
  259.  
  260. void lock_release(struct lockdep_map *lock, int nested,
  261. unsigned long ip)
  262. @@ -3621,7 +3621,7 @@ void lock_release(struct lockdep_map *lock, int nested,
  263. current->lockdep_recursion = 0;
  264. raw_local_irq_restore(flags);
  265. }
  266. -EXPORT_SYMBOL_GPL(lock_release);
  267. +EXPORT_SYMBOL(lock_release);
  268.  
  269. int lock_is_held(struct lockdep_map *lock)
  270. {
  271. @@ -3641,7 +3641,7 @@ int lock_is_held(struct lockdep_map *lock)
  272.  
  273. return ret;
  274. }
  275. -EXPORT_SYMBOL_GPL(lock_is_held);
  276. +EXPORT_SYMBOL(lock_is_held);
  277.  
  278. void lockdep_set_current_reclaim_state(gfp_t gfp_mask)
  279. {
  280. @@ -3814,7 +3814,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
  281. current->lockdep_recursion = 0;
  282. raw_local_irq_restore(flags);
  283. }
  284. -EXPORT_SYMBOL_GPL(lock_contended);
  285. +EXPORT_SYMBOL(lock_contended);
  286.  
  287. void lock_acquired(struct lockdep_map *lock, unsigned long ip)
  288. {
  289. @@ -3833,7 +3833,7 @@ void lock_acquired(struct lockdep_map *lock, unsigned long ip)
  290. current->lockdep_recursion = 0;
  291. raw_local_irq_restore(flags);
  292. }
  293. -EXPORT_SYMBOL_GPL(lock_acquired);
  294. +EXPORT_SYMBOL(lock_acquired);
  295. #endif
  296.  
  297. /*
  298. @@ -4088,7 +4088,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
  299. }
  300. local_irq_restore(flags);
  301. }
  302. -EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
  303. +EXPORT_SYMBOL(debug_check_no_locks_freed);
  304.  
  305. static void print_held_locks_bug(void)
  306. {
  307. @@ -4113,7 +4113,7 @@ void debug_check_no_locks_held(void)
  308. if (unlikely(current->lockdep_depth > 0))
  309. print_held_locks_bug();
  310. }
  311. -EXPORT_SYMBOL_GPL(debug_check_no_locks_held);
  312. +EXPORT_SYMBOL(debug_check_no_locks_held);
  313.  
  314. void debug_show_all_locks(void)
  315. {
  316. @@ -4171,7 +4171,7 @@ retry:
  317. if (unlock)
  318. read_unlock(&tasklist_lock);
  319. }
  320. -EXPORT_SYMBOL_GPL(debug_show_all_locks);
  321. +EXPORT_SYMBOL(debug_show_all_locks);
  322.  
  323. /*
  324. * Careful: only use this function if you are sure that
  325. @@ -4185,7 +4185,7 @@ void debug_show_held_locks(struct task_struct *task)
  326. }
  327. lockdep_print_held_locks(task);
  328. }
  329. -EXPORT_SYMBOL_GPL(debug_show_held_locks);
  330. +EXPORT_SYMBOL(debug_show_held_locks);
  331.  
  332. void lockdep_sys_exit(void)
  333. {
  334. @@ -4254,4 +4254,4 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)
  335. printk("\nstack backtrace:\n");
  336. dump_stack();
  337. }
  338. -EXPORT_SYMBOL_GPL(lockdep_rcu_suspicious);
  339. +EXPORT_SYMBOL(lockdep_rcu_suspicious);
  340. diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
  341. index 48ab703..3fab23e 100644
  342. --- a/kernel/rcupdate.c
  343. +++ b/kernel/rcupdate.c
  344. @@ -67,7 +67,7 @@ void __rcu_read_lock(void)
  345. current->rcu_read_lock_nesting++;
  346. barrier(); /* critical section after entry code. */
  347. }
  348. -EXPORT_SYMBOL_GPL(__rcu_read_lock);
  349. +EXPORT_SYMBOL(__rcu_read_lock);
  350.  
  351. /*
  352. * Preemptible RCU implementation for rcu_read_unlock().
  353. @@ -102,7 +102,7 @@ void __rcu_read_unlock(void)
  354. }
  355. #endif /* #ifdef CONFIG_PROVE_LOCKING */
  356. }
  357. -EXPORT_SYMBOL_GPL(__rcu_read_unlock);
  358. +EXPORT_SYMBOL(__rcu_read_unlock);
  359.  
  360. /*
  361. * Check for a task exiting while in a preemptible-RCU read-side
  362. @@ -134,17 +134,17 @@ void exit_rcu(void)
  363. static struct lock_class_key rcu_lock_key;
  364. struct lockdep_map rcu_lock_map =
  365. STATIC_LOCKDEP_MAP_INIT("rcu_read_lock", &rcu_lock_key);
  366. -EXPORT_SYMBOL_GPL(rcu_lock_map);
  367. +EXPORT_SYMBOL(rcu_lock_map);
  368.  
  369. static struct lock_class_key rcu_bh_lock_key;
  370. struct lockdep_map rcu_bh_lock_map =
  371. STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_bh", &rcu_bh_lock_key);
  372. -EXPORT_SYMBOL_GPL(rcu_bh_lock_map);
  373. +EXPORT_SYMBOL(rcu_bh_lock_map);
  374.  
  375. static struct lock_class_key rcu_sched_lock_key;
  376. struct lockdep_map rcu_sched_lock_map =
  377. STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_sched", &rcu_sched_lock_key);
  378. -EXPORT_SYMBOL_GPL(rcu_sched_lock_map);
  379. +EXPORT_SYMBOL(rcu_sched_lock_map);
  380. #endif
  381.  
  382. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  383. @@ -154,7 +154,7 @@ int debug_lockdep_rcu_enabled(void)
  384. return rcu_scheduler_active && debug_locks &&
  385. current->lockdep_recursion == 0;
  386. }
  387. -EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled);
  388. +EXPORT_SYMBOL(debug_lockdep_rcu_enabled);
  389.  
  390. /**
  391. * rcu_read_lock_bh_held() - might we be in RCU-bh read-side critical section?
  392. @@ -181,7 +181,7 @@ int rcu_read_lock_bh_held(void)
  393. return 0;
  394. return in_softirq() || irqs_disabled();
  395. }
  396. -EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held);
  397. +EXPORT_SYMBOL(rcu_read_lock_bh_held);
  398.  
  399. #endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
  400.  
  401. @@ -214,7 +214,7 @@ void wait_rcu_gp(call_rcu_func_t crf)
  402. wait_for_completion(&rcu.completion);
  403. destroy_rcu_head_on_stack(&rcu.head);
  404. }
  405. -EXPORT_SYMBOL_GPL(wait_rcu_gp);
  406. +EXPORT_SYMBOL(wait_rcu_gp);
  407.  
  408. #ifdef CONFIG_PROVE_RCU
  409. /*
  410. @@ -224,7 +224,7 @@ int rcu_my_thread_group_empty(void)
  411. {
  412. return thread_group_empty(current);
  413. }
  414. -EXPORT_SYMBOL_GPL(rcu_my_thread_group_empty);
  415. +EXPORT_SYMBOL(rcu_my_thread_group_empty);
  416. #endif /* #ifdef CONFIG_PROVE_RCU */
  417.  
  418. #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
  419. @@ -375,7 +375,7 @@ void init_rcu_head_on_stack(struct rcu_head *head)
  420. {
  421. debug_object_init_on_stack(head, &rcuhead_debug_descr);
  422. }
  423. -EXPORT_SYMBOL_GPL(init_rcu_head_on_stack);
  424. +EXPORT_SYMBOL(init_rcu_head_on_stack);
  425.  
  426. /**
  427. * destroy_rcu_head_on_stack() - destroy on-stack rcu_head for debugobjects
  428. @@ -392,7 +392,7 @@ void destroy_rcu_head_on_stack(struct rcu_head *head)
  429. {
  430. debug_object_free(head, &rcuhead_debug_descr);
  431. }
  432. -EXPORT_SYMBOL_GPL(destroy_rcu_head_on_stack);
  433. +EXPORT_SYMBOL(destroy_rcu_head_on_stack);
  434.  
  435. struct debug_obj_descr rcuhead_debug_descr = {
  436. .name = "rcu_head",
  437. @@ -400,7 +400,7 @@ struct debug_obj_descr rcuhead_debug_descr = {
  438. .fixup_activate = rcuhead_fixup_activate,
  439. .fixup_free = rcuhead_fixup_free,
  440. };
  441. -EXPORT_SYMBOL_GPL(rcuhead_debug_descr);
  442. +EXPORT_SYMBOL(rcuhead_debug_descr);
  443. #endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
  444.  
  445. #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) || defined(CONFIG_RCU_TRACE)
  446. @@ -410,7 +410,7 @@ void do_trace_rcu_torture_read(char *rcutorturename, struct rcu_head *rhp,
  447. {
  448. trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c);
  449. }
  450. -EXPORT_SYMBOL_GPL(do_trace_rcu_torture_read);
  451. +EXPORT_SYMBOL(do_trace_rcu_torture_read);
  452. #else
  453. #define do_trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
  454. do { } while (0)
  455. diff --git a/kernel/rcutree.c b/kernel/rcutree.c
  456. index 3538001..6d70ad5 100644
  457. --- a/kernel/rcutree.c
  458. +++ b/kernel/rcutree.c
  459. @@ -725,7 +725,7 @@ bool rcu_lockdep_current_cpu_online(void)
  460. preempt_enable();
  461. return ret;
  462. }
  463. -EXPORT_SYMBOL_GPL(rcu_lockdep_current_cpu_online);
  464. +EXPORT_SYMBOL(rcu_lockdep_current_cpu_online);
  465.  
  466. #endif /* #if defined(CONFIG_PROVE_RCU) && defined(CONFIG_HOTPLUG_CPU) */
  467.  
  468. --
  469. 1.9.1
  470.  
  471. From 9408c483e21c848af4029861721f7c43acf597f3 Mon Sep 17 00:00:00 2001
  472. From: Andrew Perepechko <panda@cloudlinux.com>
  473. Date: Thu, 22 Jan 2015 14:16:27 +0300
  474. Subject: [PATCH 06/10] the patch fixes double I/O accounting for iolimits
  475.  
  476. ---
  477. mm/page-writeback.c | 2 +-
  478. 1 file changed, 1 insertion(+), 1 deletion(-)
  479.  
  480. diff --git a/mm/page-writeback.c b/mm/page-writeback.c
  481. index 0ae8d31..b0f33bf 100644
  482. --- a/mm/page-writeback.c
  483. +++ b/mm/page-writeback.c
  484. @@ -2039,7 +2039,7 @@ void account_page_dirtied(struct page *page, struct address_space *mapping)
  485. __inc_zone_page_state(page, NR_DIRTIED);
  486. __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE);
  487. __inc_bdi_stat(mapping->backing_dev_info, BDI_DIRTIED);
  488. - task_io_account_write(PAGE_CACHE_SIZE);
  489. + task_io_account_dirty(PAGE_CACHE_SIZE);
  490. current->nr_dirtied++;
  491. this_cpu_inc(bdp_ratelimits);
  492. }
  493. --
  494. 1.9.1
  495.  
  496. From 3fd6eaf48887c3eb504178b428e5968e2facdcac Mon Sep 17 00:00:00 2001
  497. From: Andrew Perepechko <panda@cloudlinux.com>
  498. Date: Thu, 29 Jan 2015 16:55:17 +0300
  499. Subject: [PATCH 07/10] VIRTINFO_EXEC support
  500.  
  501. ---
  502. fs/exec.c | 4 ++++
  503. include/linux/virtinfo.h | 1 +
  504. 2 files changed, 5 insertions(+)
  505.  
  506. diff --git a/fs/exec.c b/fs/exec.c
  507. index bb06152..2de8157 100644
  508. --- a/fs/exec.c
  509. +++ b/fs/exec.c
  510. @@ -858,6 +858,10 @@ static int exec_mmap(struct linux_binprm *bprm)
  511. struct task_struct *tsk;
  512. struct mm_struct *old_mm, *active_mm, *mm;
  513.  
  514. + if (virtinfo_notifier_call(VITYPE_GENERAL, VIRTINFO_EXEC,
  515. + bprm) & NOTIFY_FAIL)
  516. + return -EPERM;
  517. +
  518. /* Notify parent that we're no longer interested in the old VM */
  519. tsk = current;
  520. old_mm = current->mm;
  521. diff --git a/include/linux/virtinfo.h b/include/linux/virtinfo.h
  522. index e8cb94c..52c1051 100644
  523. --- a/include/linux/virtinfo.h
  524. +++ b/include/linux/virtinfo.h
  525. @@ -63,6 +63,7 @@ int meminfo_proc_show_ub(struct seq_file *m, void *v,
  526. #define VIRTINFO_SYSINFO 2
  527. #define VIRTINFO_VMSTAT 3
  528. #define VIRTINFO_OOMKILL 4
  529. +#define VIRTINFO_EXEC 5
  530.  
  531. #define VIRTINFO_IO_ACCOUNT 0
  532. #define VIRTINFO_IO_PREPARE 1
  533. --
  534. 1.9.1
  535.  
  536. From ab53a38a812bee656ac1982d35a26e3f91f93107 Mon Sep 17 00:00:00 2001
  537. From: Andrew Perepechko <panda@cloudlinux.com>
  538. Date: Thu, 29 Jan 2015 22:48:38 +0300
  539. Subject: [PATCH 08/10] set ubc_ioprio to 0
  540.  
  541. ubc_ioprio=1 breaks enter-on-exec functionality
  542. by ub_attach_task -> ub_blkio_cgroup_attach_task ->
  543. cgroup_kernel_open(blkio_cgroup_root...) = -EACCES.
  544.  
  545. We also do not need blkio functionality, as we
  546. implement our own I/O throttling.
  547. ---
  548. kernel/bc/beancounter.c | 2 +-
  549. 1 file changed, 1 insertion(+), 1 deletion(-)
  550.  
  551. diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
  552. index 417e2c0..18ccbf8 100644
  553. --- a/kernel/bc/beancounter.c
  554. +++ b/kernel/bc/beancounter.c
  555. @@ -81,7 +81,7 @@ const char *ub_rnames[] = {
  556.  
  557. unsigned int ub_dcache_threshold __read_mostly = 4 * 1024; /* ~7Mb per container */
  558.  
  559. -static int ubc_ioprio = 1;
  560. +static int ubc_ioprio = 0;
  561.  
  562. /* default maximum perpcu resources precharge */
  563. int ub_resource_precharge[UB_RESOURCES] = {
  564. --
  565. 1.9.1
  566.  
  567. From 8e07d85e02dcda67174f054f1a2018b2e7a354a0 Mon Sep 17 00:00:00 2001
  568. From: Alexey Lyashkov <alexey_lyashkov@xyratex.com>
  569. Date: Thu, 22 Jan 2015 16:10:57 -0500
  570. Subject: [PATCH 09/10] Hide proc directories from user
  571.  
  572. The commit combines next commits from CL6:
  573. 1. 5b746e8 Hide proc directories from user
  574. 2. 80fdaee /proc/cpuinfo should be visible to everyone
  575. 3. dd66bde Root can see all proc elements in all cases inspite off
  576. proc_super_gid value
  577. 4. 8ffdd6c add proc_can_see_other_uid to sysctl tree.
  578. 5. a84b463 add fs.proc_can_see_other_uid and super gid
  579.  
  580. Signed-off-by: Vladimir Meshkov <vmeshkov@cloudlinux.com>
  581. ---
  582. fs/proc/base.c | 19 ++++++++++++++++-
  583. fs/proc/generic.c | 56 +++++++++++++++++++++++++++++++++++++++++++------
  584. include/linux/proc_fs.h | 1 +
  585. kernel/sysctl.c | 17 +++++++++++++++
  586. 4 files changed, 86 insertions(+), 7 deletions(-)
  587.  
  588. diff --git a/fs/proc/base.c b/fs/proc/base.c
  589. index cc5b876..7d946ac 100644
  590. --- a/fs/proc/base.c
  591. +++ b/fs/proc/base.c
  592. @@ -2951,6 +2951,9 @@ out:
  593. return result;
  594. }
  595.  
  596. +int proc_can_see_other_uid = 1;
  597. +gid_t proc_super_gid = 0;
  598. +
  599. /*
  600. * Find the first task with tgid >= tgid
  601. *
  602. @@ -2962,6 +2965,9 @@ struct tgid_iter {
  603. static struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter iter)
  604. {
  605. struct pid *pid;
  606. + kgid_t proc_super_kgid;
  607. + kuid_t cur_euid;
  608. + kuid_t tsk_euid;
  609.  
  610. if (iter.task)
  611. put_task_struct(iter.task);
  612. @@ -2970,8 +2976,19 @@ retry:
  613. iter.task = NULL;
  614. pid = find_ge_pid(iter.tgid, ns);
  615. if (pid) {
  616. - iter.tgid = pid_nr_ns(pid, ns);
  617. + proc_super_kgid = make_kgid(current_user_ns(), proc_super_gid);
  618. iter.task = pid_task(pid, PIDTYPE_PID);
  619. + cur_euid = current_euid();
  620. + if (iter.task != NULL) {
  621. + tsk_euid = task_euid(iter.task);
  622. + if (!proc_can_see_other_uid && !capable(CAP_SYS_RESOURCE) &&
  623. + !(proc_super_gid && in_group_p(proc_super_kgid)) &&
  624. + !uid_eq(cur_euid, tsk_euid))
  625. + iter.task = NULL;
  626. + }
  627. +
  628. + iter.tgid = pid_nr_ns(pid, ns);
  629. +
  630. /* What we to know is if the pid we have find is the
  631. * pid of a thread_group_leader. Testing for task
  632. * being a thread_group_leader is the obvious thing
  633. diff --git a/fs/proc/generic.c b/fs/proc/generic.c
  634. index e6c3eae..46d5ecd 100644
  635. --- a/fs/proc/generic.c
  636. +++ b/fs/proc/generic.c
  637. @@ -27,6 +27,8 @@
  638.  
  639. #include "internal.h"
  640.  
  641. +static kgid_t proc_super_kgid;
  642. +
  643. DEFINE_SPINLOCK(proc_subdir_lock);
  644.  
  645. static int proc_match(unsigned int len, const char *name, struct proc_dir_entry *de)
  646. @@ -204,6 +206,41 @@ static const struct dentry_operations proc_dentry_operations =
  647. .d_delete = proc_delete_dentry,
  648. };
  649.  
  650. +static char *names_white_list[] = {"version", "stat", "uptime",
  651. +"loadavg", "filesystems", "stat", "cmdline", "meminfo", "mounts", "tcp",
  652. +"tcp6", "udp", "udp6", "assocs", "raw", "raw6", "unix", "dev",
  653. +"net", "cpuinfo" //access to /proc/net/tcp, tcp6, udp, udp6, assocs, raw, raw6, unix
  654. +};
  655. +static int names_white_list_sizes[ARRAY_SIZE(names_white_list)];
  656. +static int is_white_list_initialized = 0;
  657. +
  658. +static int proc_check_access(const char *name, int namelen)
  659. +{
  660. + int i;
  661. +
  662. + if (!is_white_list_initialized) {
  663. + for (i = 0; i < ARRAY_SIZE(names_white_list); i++)
  664. + names_white_list_sizes[i] = strlen(names_white_list[i]);
  665. + is_white_list_initialized = 1;
  666. + }
  667. +
  668. + for (i = 0; i < ARRAY_SIZE(names_white_list); i++) {
  669. + if (namelen != names_white_list_sizes[i])
  670. + continue;
  671. + if (memcmp(name, names_white_list[i], namelen))
  672. + continue;
  673. + return 1;
  674. + }
  675. +
  676. + return 0;
  677. +}
  678. +
  679. +extern gid_t proc_super_gid;
  680. +#define PDE_IS_NOT_ACCESSIBLY(de) (!in_group_p(proc_super_kgid) \
  681. + && !de->access \
  682. + && !capable(CAP_SYS_RESOURCE))
  683. +#define PDE_IS_ACCESSIBLY(de) (!PDE_IS_NOT_ACCESSIBLY(de))
  684. +
  685. /*
  686. * Don't create negative dentries here, return -ENOENT by hand
  687. * instead.
  688. @@ -221,6 +258,9 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
  689. if (in_container && !(de->mode & S_ISVTX))
  690. continue;
  691. if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
  692. + proc_super_kgid = make_kgid(current_user_ns(), proc_super_gid);
  693. + if (de && PDE_IS_NOT_ACCESSIBLY(de))
  694. + return NULL;
  695. pde_get(de);
  696. spin_unlock(&proc_subdir_lock);
  697. inode = proc_get_inode(dir->i_sb, de);
  698. @@ -259,6 +299,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
  699. int ret = 0;
  700. bool in_container = proc_in_container(filp->f_path.dentry->d_sb);
  701.  
  702. + proc_super_kgid = make_kgid(current_user_ns(), proc_super_gid);
  703. ino = inode->i_ino;
  704. i = filp->f_pos;
  705. switch (i) {
  706. @@ -304,13 +345,15 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
  707.  
  708. /* filldir passes info to user space */
  709. pde_get(de);
  710. - spin_unlock(&proc_subdir_lock);
  711. - if (filldir(dirent, de->name, de->namelen, filp->f_pos,
  712. - de->low_ino, de->mode >> 12) < 0) {
  713. - pde_put(de);
  714. - goto out;
  715. + if (PDE_IS_ACCESSIBLY(de)) {
  716. + spin_unlock(&proc_subdir_lock);
  717. + if (filldir(dirent, de->name, de->namelen, filp->f_pos,
  718. + de->low_ino, de->mode >> 12) < 0) {
  719. + pde_put(de);
  720. + goto out;
  721. + }
  722. + spin_lock(&proc_subdir_lock);
  723. }
  724. - spin_lock(&proc_subdir_lock);
  725. filp->f_pos++;
  726. next = de->next;
  727. pde_put(de);
  728. @@ -426,6 +469,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
  729. atomic_set(&ent->count, 1);
  730. spin_lock_init(&ent->pde_unload_lock);
  731. INIT_LIST_HEAD(&ent->pde_openers);
  732. + ent->access = proc_check_access(name, len);
  733. out:
  734. return ent;
  735. }
  736. diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
  737. index 3ad9873..74d3410 100644
  738. --- a/include/linux/proc_fs.h
  739. +++ b/include/linux/proc_fs.h
  740. @@ -25,6 +25,7 @@ struct proc_dir_entry {
  741. struct list_head pde_openers; /* who did ->open, but not ->release */
  742. spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
  743. u8 namelen;
  744. + int access;
  745. char name[];
  746. };
  747.  
  748. diff --git a/kernel/sysctl.c b/kernel/sysctl.c
  749. index e7e1dce..80d3349 100644
  750. --- a/kernel/sysctl.c
  751. +++ b/kernel/sysctl.c
  752. @@ -1521,6 +1521,9 @@ static struct ctl_table binfmt_misc_table[] = {
  753. };
  754. #endif
  755.  
  756. +extern int proc_can_see_other_uid; /* fs/procfs/ */
  757. +extern gid_t proc_super_gid;
  758. +
  759. static struct ctl_table fs_table[] = {
  760. {
  761. .procname = "relatime_interval",
  762. @@ -1699,6 +1702,20 @@ static struct ctl_table fs_table[] = {
  763. .proc_handler = &pipe_proc_fn,
  764. .extra1 = &pipe_min_size,
  765. },
  766. + {
  767. + .procname = "proc_can_see_other_uid",
  768. + .mode = 0600,
  769. + .data = &proc_can_see_other_uid,
  770. + .maxlen = sizeof(proc_can_see_other_uid),
  771. + .proc_handler = &proc_dointvec,
  772. + },
  773. + {
  774. + .procname = "proc_super_gid",
  775. + .mode = 0600,
  776. + .data = &proc_super_gid,
  777. + .maxlen = sizeof(proc_super_gid),
  778. + .proc_handler = &proc_dointvec,
  779. + },
  780. { }
  781. };
  782.  
  783. --
  784. 1.9.1
  785.  
  786. From 0000a05e09b6ff583650fb70c7b685f801050f81 Mon Sep 17 00:00:00 2001
  787. From: Sergey Cherementsev <cherementsev@cloudlinux.com>
  788. Date: Thu, 29 Jan 2015 09:12:31 -0500
  789. Subject: [PATCH 10/10] Symlink owner handler
  790.  
  791. The patch has been ported from CL6, commit e3488488
  792.  
  793. Signed-off-by: Vladimir Meshkov <vmeshkov@cloudlinux.com>
  794. ---
  795. fs/Kconfig | 25 +++++++++++++++++++++++++
  796. fs/namei.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
  797. kernel/sysctl.c | 21 +++++++++++++++++++++
  798. 3 files changed, 95 insertions(+)
  799.  
  800. diff --git a/fs/Kconfig b/fs/Kconfig
  801. index eaf7c12..38281e2 100644
  802. --- a/fs/Kconfig
  803. +++ b/fs/Kconfig
  804. @@ -4,6 +4,31 @@
  805.  
  806. menu "File systems"
  807.  
  808. +config SYMLINKOWN
  809. + bool
  810. + default y
  811. + help
  812. + Apache's SymlinksIfOwnerMatch option has an inherent race condition
  813. + that prevents it from being used as a security feature. As Apache
  814. + verifies the symlink by performing a stat() against the target of
  815. + the symlink before it is followed, an attacker can setup a symlink
  816. + to point to a same-owned file, then replace the symlink with one
  817. + that targets another user's file just after Apache "validates" the
  818. + symlink -- a classic TOCTOU race. If you say Y here, a complete,
  819. + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
  820. + will be in place for the group you specify. If the sysctl option
  821. + is enabled, a sysctl option with name "enforce_symlinksifowner" is
  822. + created.
  823. +
  824. +config SYMLINKOWN_GID
  825. + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
  826. + depends on SYMLINKOWN
  827. + default 1006
  828. + help
  829. + Setting this GID determines what group kernel-enforced
  830. + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
  831. + is enabled, a sysctl option with name "symlinkown_gid" is created.
  832. +
  833. # Use unaligned word dcache accesses
  834. config DCACHE_WORD_ACCESS
  835. bool
  836. diff --git a/fs/namei.c b/fs/namei.c
  837. index 5b01462..07336b2 100644
  838. --- a/fs/namei.c
  839. +++ b/fs/namei.c
  840. @@ -130,6 +130,9 @@ void final_putname(struct filename *name)
  841.  
  842. #define EMBEDDED_NAME_MAX (PATH_MAX - sizeof(struct filename))
  843.  
  844. +static int
  845. +handle_symlink_owner(const struct path *link, const struct inode *target);
  846. +
  847. static struct filename *
  848. getname_flags(const char __user *filename, int flags, int *empty)
  849. {
  850. @@ -880,6 +883,10 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
  851. put_link(nd, link, *p);
  852. }
  853.  
  854. + if (!error && !(nd->flags & LOOKUP_PARENT) &&
  855. + handle_symlink_owner(link, nd->path.dentry->d_inode))
  856. + error = -EACCES;
  857. +
  858. return error;
  859.  
  860. out_put_nd_path:
  861. @@ -1771,6 +1778,48 @@ static inline unsigned long hash_name(const char *name, unsigned int *hashp)
  862.  
  863. #endif
  864.  
  865. +#ifdef CONFIG_SYMLINKOWN
  866. +int enable_symlinkown = 1;
  867. +gid_t symlinkown_gid = CONFIG_SYMLINKOWN_GID;
  868. +#endif
  869. +
  870. +static int
  871. +handle_symlink_owner(const struct path *link, const struct inode *target)
  872. +{
  873. +#ifdef CONFIG_SYMLINKOWN
  874. + const struct inode *link_inode = link->dentry->d_inode;
  875. + const struct cred *cred;
  876. + kgid_t symlinkown_kgid = make_kgid(current_user_ns(), symlinkown_gid);
  877. + int ngroups;
  878. +
  879. + if (enable_symlinkown && target && link_inode &&
  880. + uid_valid(link_inode->i_uid) &&
  881. + !uid_eq(link_inode->i_uid, target->i_uid)) {
  882. + if (enable_symlinkown == 1) {
  883. + if (in_group_p(symlinkown_kgid))
  884. + goto eacces;
  885. + } else {
  886. + cred = current_cred();
  887. + ngroups = cred->group_info->ngroups;
  888. + if (ngroups && gid_gt(GROUP_AT(cred->group_info,
  889. + ngroups - 1), symlinkown_kgid))
  890. + goto eacces;
  891. + if (gid_gt(cred->fsgid, symlinkown_kgid))
  892. + goto eacces;
  893. + }
  894. + return 0;
  895. +eacces:
  896. + if (printk_ratelimit())
  897. + printk(KERN_DEBUG "access denied %p uid %u target uid %u!\n",
  898. + link->dentry,
  899. + from_kuid(current_user_ns(), link_inode->i_uid),
  900. + from_kuid(current_user_ns(), target->i_uid));
  901. + return -EACCES;
  902. + }
  903. +#endif
  904. + return 0;
  905. +}
  906. +
  907. /*
  908. * Name resolution.
  909. * This is the basic name resolution function, turning a pathname into
  910. diff --git a/kernel/sysctl.c b/kernel/sysctl.c
  911. index 80d3349..9c2eb34 100644
  912. --- a/kernel/sysctl.c
  913. +++ b/kernel/sysctl.c
  914. @@ -188,6 +188,11 @@ static int proc_dostring_coredump(struct ctl_table *table, int write,
  915. void __user *buffer, size_t *lenp, loff_t *ppos);
  916. #endif
  917.  
  918. +#ifdef CONFIG_SYMLINKOWN
  919. +extern int enable_symlinkown;
  920. +extern gid_t symlinkown_gid;
  921. +#endif
  922. +
  923. #ifdef CONFIG_MAGIC_SYSRQ
  924. /* Note: sysrq code uses it's own private copy */
  925. static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
  926. @@ -1716,6 +1721,22 @@ static struct ctl_table fs_table[] = {
  927. .maxlen = sizeof(proc_super_gid),
  928. .proc_handler = &proc_dointvec,
  929. },
  930. +#ifdef CONFIG_SYMLINKOWN
  931. + {
  932. + .procname = "enforce_symlinksifowner",
  933. + .mode = 0600,
  934. + .data = &enable_symlinkown,
  935. + .maxlen = sizeof(enable_symlinkown),
  936. + .proc_handler = &proc_dointvec,
  937. + },
  938. + {
  939. + .procname = "symlinkown_gid",
  940. + .mode = 0600,
  941. + .data = &symlinkown_gid,
  942. + .maxlen = sizeof(symlinkown_gid),
  943. + .proc_handler = &proc_dointvec,
  944. + },
  945. +#endif
  946. { }
  947. };
  948.  
  949. --
  950. 1.9.1
  951.  
  952. diff --git a/fs/proc/generic.c b/fs/proc/generic.c
  953. index 46d5ecd..b14ac43 100644
  954. --- a/fs/proc/generic.c
  955. +++ b/fs/proc/generic.c
  956. @@ -259,8 +259,10 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
  957. continue;
  958. if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
  959. proc_super_kgid = make_kgid(current_user_ns(), proc_super_gid);
  960. - if (de && PDE_IS_NOT_ACCESSIBLY(de))
  961. + if (de && PDE_IS_NOT_ACCESSIBLY(de)) {
  962. + spin_unlock(&proc_subdir_lock);
  963. return NULL;
  964. + }
  965. pde_get(de);
  966. spin_unlock(&proc_subdir_lock);
  967. inode = proc_get_inode(dir->i_sb, de);
  968. From 66bf59df7e5bbd73ade2d85d1909be68469af8b9 Mon Sep 17 00:00:00 2001
  969. From: Andrew Perepechko <panda@cloudlinux.com>
  970. Date: Fri, 20 Mar 2015 21:38:26 +0300
  971. Subject: [PATCH 12/12] IOPS accounting support for noop and as
  972.  
  973. ---
  974. block/cfq-iosched.c | 3 +++
  975. block/deadline-iosched.c | 3 +++
  976. block/noop-iosched.c | 2 ++
  977. 3 files changed, 8 insertions(+)
  978.  
  979. diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
  980. index c410752..2fe3e75 100644
  981. --- a/block/cfq-iosched.c
  982. +++ b/block/cfq-iosched.c
  983. @@ -14,6 +14,7 @@
  984. #include <linux/rbtree.h>
  985. #include <linux/ioprio.h>
  986. #include <linux/blktrace_api.h>
  987. +#include <linux/virtinfo.h>
  988. #include "blk.h"
  989. #include "blk-cgroup.h"
  990.  
  991. @@ -3923,6 +3924,8 @@ static void cfq_insert_request(struct request_queue *q, struct request *rq)
  992. cfqg_stats_update_io_add(RQ_CFQG(rq), cfqd->serving_group,
  993. rq->cmd_flags);
  994. cfq_rq_enqueued(cfqd, cfqq, rq);
  995. +
  996. + virtinfo_notifier_call_irq(VITYPE_IO, VIRTINFO_IO_OP_ACCOUNT, NULL);
  997. }
  998.  
  999. /*
  1000. diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
  1001. index 20614a3..9543233 100644
  1002. --- a/block/deadline-iosched.c
  1003. +++ b/block/deadline-iosched.c
  1004. @@ -13,6 +13,7 @@
  1005. #include <linux/init.h>
  1006. #include <linux/compiler.h>
  1007. #include <linux/rbtree.h>
  1008. +#include <linux/virtinfo.h>
  1009.  
  1010. /*
  1011. * See Documentation/block/deadline-iosched.txt
  1012. @@ -108,6 +109,8 @@ deadline_add_request(struct request_queue *q, struct request *rq)
  1013. */
  1014. rq_set_fifo_time(rq, jiffies + dd->fifo_expire[data_dir]);
  1015. list_add_tail(&rq->queuelist, &dd->fifo_list[data_dir]);
  1016. +
  1017. + virtinfo_notifier_call_irq(VITYPE_IO, VIRTINFO_IO_OP_ACCOUNT, NULL);
  1018. }
  1019.  
  1020. /*
  1021. diff --git a/block/noop-iosched.c b/block/noop-iosched.c
  1022. index 3de89d4..6f14f83 100644
  1023. --- a/block/noop-iosched.c
  1024. +++ b/block/noop-iosched.c
  1025. @@ -7,6 +7,7 @@
  1026. #include <linux/module.h>
  1027. #include <linux/slab.h>
  1028. #include <linux/init.h>
  1029. +#include <linux/virtinfo.h>
  1030.  
  1031. struct noop_data {
  1032. struct list_head queue;
  1033. @@ -37,6 +38,7 @@ static void noop_add_request(struct request_queue *q, struct request *rq)
  1034. struct noop_data *nd = q->elevator->elevator_data;
  1035.  
  1036. list_add_tail(&rq->queuelist, &nd->queue);
  1037. + virtinfo_notifier_call_irq(VITYPE_IO, VIRTINFO_IO_OP_ACCOUNT, NULL);
  1038. }
  1039.  
  1040. static struct request *
  1041. --
  1042. 1.9.1
  1043.  
  1044. From be2f57f5a7eaf6fd003146120623d07ea10b7b3b Mon Sep 17 00:00:00 2001
  1045. From: Andrew Perepechko <panda@cloudlinux.com>
  1046. Date: Mon, 18 May 2015 22:06:58 +0300
  1047. Subject: [PATCH] properly charge and uncharge shmem
  1048.  
  1049. Currently, shmem_lock immediately and
  1050. unconditionally uncharges what it has
  1051. just charged for a lock request.
  1052.  
  1053. This, indeed, causes a double uncharge
  1054. with something like the following:
  1055.  
  1056. shmid = shmget(12345, 8192, IPC_CREAT | 0666);
  1057. rc = shmctl(shmid, SHM_LOCK, NULL);
  1058. shmctl(shmid, IPC_RMID, 0);
  1059.  
  1060. with the following in the kernel log:
  1061.  
  1062. [ 455.815025] Uncharging too much 2 h 0, res lockedpages ub 0
  1063.  
  1064. Signed-off-by: Andrew Perepechko <panda@cloudlinux.com>
  1065. ---
  1066. mm/shmem.c | 4 +++-
  1067. 1 file changed, 3 insertions(+), 1 deletion(-)
  1068.  
  1069. diff --git a/mm/shmem.c b/mm/shmem.c
  1070. index 41925dc..e21ce51 100644
  1071. --- a/mm/shmem.c
  1072. +++ b/mm/shmem.c
  1073. @@ -1359,11 +1359,13 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user)
  1074. mapping_set_unevictable(file->f_mapping);
  1075. }
  1076. if (!lock && (info->flags & VM_LOCKED) && user) {
  1077. + ub_lockedshm_uncharge(info, inode->i_size);
  1078. user_shm_unlock(inode->i_size, user);
  1079. info->flags &= ~VM_LOCKED;
  1080. mapping_clear_unevictable(file->f_mapping);
  1081. }
  1082. - retval = 0;
  1083. + spin_unlock(&info->lock);
  1084. + return 0;
  1085.  
  1086. out_nomem:
  1087. ub_lockedshm_uncharge(info, inode->i_size);
  1088. --
  1089. 1.9.1
  1090.  
  1091. kpatch-description: kernel: splice: lack of generic write checks
  1092. kpatch-kernel: kernel-3.10.0-123.20.1.el7
  1093. kpatch-cve: CVE-2014-7822
  1094. kpatch-cvss: 4.6
  1095. kpatch-cve-url: https://access.redhat.com/security/cve/CVE-2014-7822
  1096.  
  1097. diff -upr linux-3.10.0-123.13.2.el7/fs/splice.c linux-3.10.0-123.20.1.el7/fs/splice.c
  1098. --- linux-3.10.0-123.13.2.el7/fs/splice.c 2014-12-13 03:14:08.000000000 +0300
  1099. +++ linux-3.10.0-123.20.1.el7/fs/splice.c 2015-01-21 17:00:38.000000000 +0300
  1100. @@ -1098,6 +1098,7 @@ static long do_splice_from(struct pipe_i
  1101. {
  1102. ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
  1103. loff_t *, size_t, unsigned int);
  1104. + struct inode *inode = out->f_mapping->host;
  1105. int ret;
  1106.  
  1107. if (unlikely(!(out->f_mode & FMODE_WRITE)))
  1108. @@ -1110,6 +1111,10 @@ static long do_splice_from(struct pipe_i
  1109. if (unlikely(ret < 0))
  1110. return ret;
  1111.  
  1112. + ret = generic_write_checks(out, ppos, &len, S_ISBLK(inode->i_mode));
  1113. + if (ret)
  1114. + return ret;
  1115. +
  1116. if (out->f_op && out->f_op->splice_write)
  1117. splice_write = out->f_op->splice_write;
  1118. else
  1119. diff --git a/include/bc/sock_orphan.h b/include/bc/sock_orphan.h
  1120. index a737d9e..a8904ea 100644
  1121. --- a/include/bc/sock_orphan.h
  1122. +++ b/include/bc/sock_orphan.h
  1123. @@ -41,13 +41,15 @@ static inline int ub_get_orphan_count(struct sock *sk)
  1124.  
  1125. static inline int ub_too_many_orphans(struct sock *sk, int count)
  1126. {
  1127. + struct net *net = sock_net(sk);
  1128. +
  1129. #ifdef CONFIG_BEANCOUNTERS
  1130. if (__ub_too_many_orphans(sk, count))
  1131. return 1;
  1132. #endif
  1133. return (ub_get_orphan_count(sk) > sysctl_tcp_max_orphans ||
  1134. (sk->sk_wmem_queued > SOCK_MIN_SNDBUF &&
  1135. - atomic_long_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]));
  1136. + atomic_long_read(&tcp_memory_allocated) > net->ipv4.sysctl_tcp_mem[2]));
  1137. }
  1138.  
  1139. struct inet_timewait_sock;
  1140. From 6eb2ae1c79b37c91f65a80273bda153faec34253 Mon Sep 17 00:00:00 2001
  1141. From: Dmitry Monakhov <dmonakhov@openvz.org>
  1142. Date: Tue, 9 Jun 2015 12:59:39 +0400
  1143. Subject: [PATCH] pfcache: fix path refcounting hazzard
  1144.  
  1145. peer's path management was broken during porting from rhel6 to rhel7
  1146.  
  1147. - open_mapping_peer no longer responsible for path drop on error.
  1148. - fix refcounting during race peer_open/peer_close
  1149.  
  1150. #TESTCASE:
  1151. VEID=101
  1152. mkdir /tmp/pfcache
  1153. mount -ttmpfs none /tmp/pfcache
  1154. vzctl create $VEID
  1155. vzctl mount $VEID
  1156. dd if=/dev/zero of=/vz/root/$VEID/bin/f1 bs=4k count=1
  1157. cp /vz/root/$VEID/bin/f1 /pfcache/1c/eaf73df40e531df3bfb26b4fb7cd95fb7bff1d
  1158. vzctl umount $VEID
  1159. mount /vz/root/$VEID -oremount,balloon_ino=12,pfcache_csum,pfcache=/tmp/pfcache
  1160. stat /vz/root/$VEID/bin/f1 | echo FAIL
  1161. vzctl umount $VEID
  1162. umount /tmp/pfcache || echo FAIL
  1163.  
  1164. Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
  1165. Acked-by: Andrew Vagin <avagin@odin.com>
  1166. Reported-by: Oleksiy Shchukin <oshchukin@cloudlinux.com>
  1167. ---
  1168. fs/ext4/pfcache.c | 2 +-
  1169. mm/memory.c | 7 +------
  1170. 2 files changed, 2 insertions(+), 7 deletions(-)
  1171.  
  1172. diff --git a/fs/ext4/pfcache.c b/fs/ext4/pfcache.c
  1173. index 2789508..b75c26d 100644
  1174. --- a/fs/ext4/pfcache.c
  1175. +++ b/fs/ext4/pfcache.c
  1176. @@ -77,6 +77,7 @@ int ext4_open_pfcache(struct inode *inode)
  1177. ret = open_mapping_peer(inode->i_mapping, &path, &init_cred);
  1178. if (!ret)
  1179. percpu_counter_inc(&EXT4_SB(inode->i_sb)->s_pfcache_peers);
  1180. + path_put(&path);
  1181. return ret;
  1182. }
  1183.  
  1184. @@ -193,7 +194,6 @@ int ext4_relink_pfcache(struct super_block *sb, char *new_root, bool new_sb)
  1185. }
  1186.  
  1187. if (path.mnt) {
  1188. - path_get(&path);
  1189. if (!open_mapping_peer(inode->i_mapping,
  1190. &path, &init_cred))
  1191. nr_opened++;
  1192. diff --git a/mm/memory.c b/mm/memory.c
  1193. index 2f09839..618c36c 100644
  1194. --- a/mm/memory.c
  1195. +++ b/mm/memory.c
  1196. @@ -4317,7 +4317,6 @@ restart:
  1197. if (!peer->i_peer_file) {
  1198. file = dentry_open(path, O_RDONLY | O_LARGEFILE, cred);
  1199. if (IS_ERR(file)) {
  1200. - path_put(path);
  1201. return PTR_ERR(file);
  1202. }
  1203.  
  1204. @@ -4334,8 +4333,6 @@ restart:
  1205. }
  1206. if (peer->i_peer_file) {
  1207. spin_unlock(&inode->i_lock);
  1208. - *path = file->f_path;
  1209. - path_get(path);
  1210. fput(file);
  1211. file = NULL;
  1212. goto restart;
  1213. @@ -4361,9 +4358,7 @@ restart:
  1214. if (file) {
  1215. file_accessed(file);
  1216. fput(file);
  1217. - } else
  1218. - path_put(path);
  1219. -
  1220. + }
  1221. return 0;
  1222. }
  1223. EXPORT_SYMBOL(open_mapping_peer);
  1224. --
  1225. 1.8.3.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement