Re: [Vserver] Bug in vc_net_remove in kernel/vserver/network.c (including fix)

From: Herbert Poetzl <herbert_at_13thfloor.at>
Date: Fri 25 Aug 2006 - 20:01:12 BST
Message-ID: <20060825190112.GD27417@MAIL.13thfloor.at>

On Wed, Aug 23, 2006 at 01:05:21PM +0200, Christopher Alexander Tobias Schulze wrote:
> Hello everyone.
>
> While experimenting with the VServer kernel interface I found out that
> the VCMD_net_remove primitive is not implemented correctly, always
> leading to EINVAL. In the current implementation, there is no way to
> remove IP addresses assigned to a NID from userspace because of this
> bug, although the vserver kernel code implements this functionality.

thanks a lot for the feedback!
(and sorry for the late reply)

> (Note that the userspace programs in the vserver utilities currently
> seem not to use this functionality. The fact that the kernel interface
> provides more functionality than what we can get using the vserver
> utilities was the cause for studying whether it is possible to use the
> kernel interface directly for custom tools.)

you might want to look at the vcmd 'hack' tool, which
can be used to test all the interfaces we have ...
(unfortunately there is no sufficiently complex test
script which would do that right now)

http://vserver.13thfloor.at/Experimental/TOOLS/vcmd-0.05.tar.bz2

> The problem lies in the way NXA_TYPE_ANY is used. In
> include/linux/vserver/network.h, we have
>
> #define NXA_TYPE_ANY (~0)
>
> and in kernel/vserer/network.c this is used in
>
> switch ((unsigned)vc_data.type) {
> case NXA_TYPE_ANY:
> nxi->nbipv4 = 0;
> break;
>
> default:
> ret = -EINVAL;
> break;
> }
>
> Unfortunately, there is no way to set vc_data.type to a value so that
>
> (unsigned) vc_data.type == NXA_TYPE_ANY,
>
> as NXA_TYPE_ANY consists of 32 binary ones, and the upper 16 bits of
> the left hand side are always zero, as vc_data.type is a uint16_t.
>
> The fix is quite simple, e.g.
>
> switch (vc_data.type) {
> case (uint16_t)(NXA_TYPE_ANY):
> nxi->nbipv4 = 0;
> break;
>
> default:
> ret = -EINVAL;
> break;
> }
>
> Now we are comparing the value stored in vc_data.type with the value
> that gets stored with the assignment
>
> vc_data.type = NXA_TYPE_ANY,
>
> what was obviously the original author's intention.

correct, here is the fix I applied to stable and devel
branches (fortunately that was reported just right on
time :)

http://vserver.13thfloor.at/Experimental/delta-net-fix02.diff

> (Tested with a 2.6.15.7 kernel under ubuntu dapper, but should work
> also with more recent kernels. I verified that the bug still exists in
> the 2.6.17.8 vserver 2.1.1-rc29 patches.)

the 'hack tool' commands to test are:

vcmd -i 42 -AC net_create .flagword=^34 -- sleep 100 &
vcmd -i 42 -AC net_remove .type=~0

thanks again!

best,
Herbert

> HTH,
> Alexander Schulze
> _______________________________________________
> Vserver mailing list
> Vserver@list.linux-vserver.org
> http://list.linux-vserver.org/mailman/listinfo/vserver
_______________________________________________
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver
Received on Fri Aug 25 20:02:51 2006

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Fri 25 Aug 2006 - 20:02:58 BST by hypermail 2.1.8