diff mbox

[BUG] net_cls: Panic occured when net_cls subsystem use

Message ID 20090608153951.dfa4b162.usui@mxm.nes.nec.co.jp
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Minoru Usui June 8, 2009, 6:39 a.m. UTC
Hi Thomas

On Mon, 1 Jun 2009 18:12:01 +0900
Minoru Usui <usui@mxm.nes.nec.co.jp> wrote:

> Hi Thomas
> 
> Original mail sent to netdev and containers before.
> (http://www.spinics.net/lists/netdev/msg97745.html)
> 
> I have a question about how to use cls_cgroup.
> 
> On Thu, 21 May 2009 09:22:56 +0900
> Minoru Usui <usui@mxm.nes.nec.co.jp> wrote:
> 
> > Hi
> > 
> > Unfortunately this is only panic report.
> > 
> > I used cgroup net_cls subsystem, then kernel panic occured.
> > I attach panic message and kernel config in this mail's last paragraph.
> > If my operation is wrong, could you tell me how to use net_cls and
> > where the documentation is. 
> > 
> > # But I think panic is very bad even if my operation is wrong.
> 
> The cause of panic will fix soon. (Now I'll make a patch and will test it.)
> 
> I want to know how to use cls_cgroup correctly, so could you tell me how to use it if my operation is wrong. 
> Now, I think I might have to specify 'handle' with tc command line, is this true?
> But when I specified 'handle', I faced oops. X-P

I investigated this problem, and I found a bug in cls_cgroup_change() in cls_cgroup.c.
cls_cgroup_change() expected tca[TCA_OPTIONS] was set from user space properly,
but tc in iproute2-2.6.29-1 (which I used) didn't set it.

I saw the current source code of tc in git, I found the code for cls_cgroup in iproute2/tc/f_cgroup.c.
It set tca[TCA_OPTIONS].

  git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git

# Unfortunately, current source coude of iproute2 couldn't compile, because it occured compile error. X-P
# But this is another issue.

If we always use a newest iproute2 in git when we use cls_cgroup, we don't face this oops probably.
But I think, kernel shouldn't panic regardless of use program's behaviour. 


Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>

Comments

Jarek Poplawski June 8, 2009, 7:48 a.m. UTC | #1
On Mon, Jun 08, 2009 at 03:39:51PM +0900, Minoru Usui wrote:
> Hi Thomas
> 
> On Mon, 1 Jun 2009 18:12:01 +0900
> Minoru Usui <usui@mxm.nes.nec.co.jp> wrote:
> 
> > Hi Thomas
> > 
> > Original mail sent to netdev and containers before.
> > (http://www.spinics.net/lists/netdev/msg97745.html)
> > 
> > I have a question about how to use cls_cgroup.
> > 
> > On Thu, 21 May 2009 09:22:56 +0900
> > Minoru Usui <usui@mxm.nes.nec.co.jp> wrote:
> > 
> > > Hi
> > > 
> > > Unfortunately this is only panic report.
> > > 
> > > I used cgroup net_cls subsystem, then kernel panic occured.
> > > I attach panic message and kernel config in this mail's last paragraph.
> > > If my operation is wrong, could you tell me how to use net_cls and
> > > where the documentation is. 
> > > 
> > > # But I think panic is very bad even if my operation is wrong.
> > 
> > The cause of panic will fix soon. (Now I'll make a patch and will test it.)
> > 
> > I want to know how to use cls_cgroup correctly, so could you tell me how to use it if my operation is wrong. 
> > Now, I think I might have to specify 'handle' with tc command line, is this true?
> > But when I specified 'handle', I faced oops. X-P
> 
> I investigated this problem, and I found a bug in cls_cgroup_change() in cls_cgroup.c.
> cls_cgroup_change() expected tca[TCA_OPTIONS] was set from user space properly,
> but tc in iproute2-2.6.29-1 (which I used) didn't set it.
> 
> I saw the current source code of tc in git, I found the code for cls_cgroup in iproute2/tc/f_cgroup.c.
> It set tca[TCA_OPTIONS].
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git
> 
> # Unfortunately, current source coude of iproute2 couldn't compile, because it occured compile error. X-P
> # But this is another issue.
> 
> If we always use a newest iproute2 in git when we use cls_cgroup, we don't face this oops probably.
> But I think, kernel shouldn't panic regardless of use program's behaviour. 
> 

This patch looks OK to me, but I guess you should add some title (plus
"[PATCH]" in the subject), and a changelog (with lines width <= 80).

Cheers,
Jarek P.

> 
> Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
> 
> diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
> index cc29b44..2ec0adc 100644
> --- a/net/sched/cls_cgroup.c
> +++ b/net/sched/cls_cgroup.c
> @@ -167,6 +167,9 @@ static int cls_cgroup_change(struct tcf_proto *tp, unsigned long base,
>  	struct tcf_exts e;
>  	int err;
>  
> +	if (!tca[TCA_OPTIONS])
> +		return -EINVAL;
> +
>  	if (head == NULL) {
>  		if (!handle)
>  			return -EINVAL;
> 
> 
> -- 
> Minoru Usui <usui@mxm.nes.nec.co.jp>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Minoru Usui June 9, 2009, 12:02 a.m. UTC | #2
Hi, Jarek

On Mon, 8 Jun 2009 07:48:14 +0000
Jarek Poplawski <jarkao2@gmail.com> wrote:

> On Mon, Jun 08, 2009 at 03:39:51PM +0900, Minoru Usui wrote:
> > Hi Thomas
> > 
> > On Mon, 1 Jun 2009 18:12:01 +0900
> > Minoru Usui <usui@mxm.nes.nec.co.jp> wrote:
> > 
> > > Hi Thomas
> > > 
> > > Original mail sent to netdev and containers before.
> > > (http://www.spinics.net/lists/netdev/msg97745.html)
> > > 
> > > I have a question about how to use cls_cgroup.
> > > 
> > > On Thu, 21 May 2009 09:22:56 +0900
> > > Minoru Usui <usui@mxm.nes.nec.co.jp> wrote:
> > > 
> > > > Hi
> > > > 
> > > > Unfortunately this is only panic report.
> > > > 
> > > > I used cgroup net_cls subsystem, then kernel panic occured.
> > > > I attach panic message and kernel config in this mail's last paragraph.
> > > > If my operation is wrong, could you tell me how to use net_cls and
> > > > where the documentation is. 
> > > > 
> > > > # But I think panic is very bad even if my operation is wrong.
> > > 
> > > The cause of panic will fix soon. (Now I'll make a patch and will test it.)
> > > 
> > > I want to know how to use cls_cgroup correctly, so could you tell me how to use it if my operation is wrong. 
> > > Now, I think I might have to specify 'handle' with tc command line, is this true?
> > > But when I specified 'handle', I faced oops. X-P
> > 
> > I investigated this problem, and I found a bug in cls_cgroup_change() in cls_cgroup.c.
> > cls_cgroup_change() expected tca[TCA_OPTIONS] was set from user space properly,
> > but tc in iproute2-2.6.29-1 (which I used) didn't set it.
> > 
> > I saw the current source code of tc in git, I found the code for cls_cgroup in iproute2/tc/f_cgroup.c.
> > It set tca[TCA_OPTIONS].
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git
> > 
> > # Unfortunately, current source coude of iproute2 couldn't compile, because it occured compile error. X-P
> > # But this is another issue.
> > 
> > If we always use a newest iproute2 in git when we use cls_cgroup, we don't face this oops probably.
> > But I think, kernel shouldn't panic regardless of use program's behaviour. 
> > 
> 
> This patch looks OK to me, but I guess you should add some title (plus
> "[PATCH]" in the subject), and a changelog (with lines width <= 80).

Thank you for your comments.
I'll resend my patch as a start of a new thread.
diff mbox

Patch

diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index cc29b44..2ec0adc 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -167,6 +167,9 @@  static int cls_cgroup_change(struct tcf_proto *tp, unsigned long base,
 	struct tcf_exts e;
 	int err;
 
+	if (!tca[TCA_OPTIONS])
+		return -EINVAL;
+
 	if (head == NULL) {
 		if (!handle)
 			return -EINVAL;