Re: cgroup/next tree: reference to uninitialized percpu ref

2013-08-18 Thread Li Zefan
On 2013/8/19 11:32, Ming Lei wrote:
> Hi,
> 
> The kernel oops[1] is triggered during kernel boot with the latest next
> tree(3.11.0-rc5-next-20130816), looks it is caused by reference to 
> uninitialized
> percpu ref of root cgroup, and below patch can fix the problem:
> 

Thanks for the report. Li Zhong has summited a patch to fix it:

www.spinics.net/lists/linux-next/msg26414.html

and it should show up in linux-next tree when next is updated.

> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 723194f..0e8954b 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -4485,7 +4485,8 @@ static long cgroup_create(struct cgroup *parent,
> struct dentry *dentry,
>   struct cgroup_subsys_state *css = css_ar[ss->subsys_id];
> 
>   dget(dentry);
> - percpu_ref_get(&css->parent->refcnt);
> + if (!(css->parent->flags & CSS_ROOT))
> + percpu_ref_get(&css->parent->refcnt);
>   }
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


cgroup/next tree: reference to uninitialized percpu ref

2013-08-18 Thread Ming Lei
Hi,

The kernel oops[1] is triggered during kernel boot with the latest next
tree(3.11.0-rc5-next-20130816), looks it is caused by reference to uninitialized
percpu ref of root cgroup, and below patch can fix the problem:

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 723194f..0e8954b 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4485,7 +4485,8 @@ static long cgroup_create(struct cgroup *parent,
struct dentry *dentry,
  struct cgroup_subsys_state *css = css_ar[ss->subsys_id];

  dget(dentry);
- percpu_ref_get(&css->parent->refcnt);
+ if (!(css->parent->flags & CSS_ROOT))
+ percpu_ref_get(&css->parent->refcnt);
  }

  /* hold a ref to the parent's dentry */



[1], oops log:
[3.155985] Unable to handle kernel paging request at virtual
address 011bb000
[3.163083] pgd = ee864000
[3.165715] [011bb000] *pgd=
[3.169219] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[3.174428] Modules linked in: ipv6
[3.177844] CPU: 1 PID: 1 Comm: systemd Not tainted
3.11.0-rc5-next-20130816+ #237
[3.185280] task: ef00e400 ti: ef09c000 task.ti: ef09c000
[3.190573] PC is at cgroup_mkdir+0x324/0x5a0
[3.194841] LR is at cgroup_mkdir+0x314/0x5a0
[3.199114] pc : []lr : []psr: 40010013
[3.199114] sp : ef09def8  ip :   fp : ee8e
[3.210393] r10: c064b4e4  r9 : ef09c000  r8 : c064b528
[3.215511] r7 : c064b4dc  r6 : ee8e0018  r5 : eed1f880  r4 : eebf2c00
[3.221918] r3 : 011bb000  r2 : ef09de78  r1 : 60010013  r0 : 0030
[3.228326] Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[3.235329] Control: 10c5387d  Table: 6e86406a  DAC: 0015
[3.240964] Process systemd (pid: 1, stack limit = 0xef09c238)
[3.246687] Stack: (0xef09def8 to 0xef09e000)
[3.250956] dee0:
00d0 eef837f8
[3.258993] df00: 180fb270  eeb75023 ee8e000c eed1f8d4
ee8e0130  
[3.267020] df20: eea1fa80 ef0de880   
 0003 
[3.275049] df40: eefe2d70 eed1f880 01ed ff9c ef09c000
0011be80 be9814ac c00ec0bc
[3.283077] df60: eefe2d70 eed1f880 01ed eed1f880 0002
01ed 0027 c00efb74
[3.291106] df80: ef2ebc10 eef837f8 01ed 0011be80 01ed
000cc730 0027 c000e048
[3.299135] dfa0:  c000dea0 0011be80 01ed 0011be80
01ed 0001 
[3.307164] dfc0: 0011be80 01ed 000cc730 0027 000d7202
ffef 0011be80 be9814ac
[3.315192] dfe0: 000cc03c be9813bc 00055280 b6d6769c 60010010
0011be80 fffd 
[3.323225] [] (cgroup_mkdir+0x324/0x5a0) from
[] (vfs_mkdir+0x88/0xc8)
[3.331424] [] (vfs_mkdir+0x88/0xc8) from []
(SyS_mkdirat+0x6c/0xa0)
[3.339369] [] (SyS_mkdirat+0x6c/0xa0) from []
(ret_fast_syscall+0x0/0x30)
[3.347821] Code: e59dc00c e31c0003 1a04 ee1d3f90 (e793200c)
[3.353817] ---[ end trace ea0a2516971df41f ]---

Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/