[Devel] [PATCH rh7] vznetstat: fix RCU-protected "info_V{4, 6}" pointers initialization
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Nov 17 06:38:00 PST 2015
Stas, i'm applying this, thank you.
Vasya, as far as i see 2.6.32-x kernel has the same code,
please check and apply the patch if needed.
--
Best regards,
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
On 11/12/2015 04:42 PM, Stanislav Kinsburskiy wrote:
> This pointers have to be referenced and assigned under rcu_read_lock().
> Moreover, there is no need to take tc_lock: it protects stats hash, but not
> info pointers.
>
> Fixes the following warning:
>
> [ 31.658913] ===============================
> [ 31.659035] [ INFO: suspicious RCU usage. ]
> [ 31.659155] 3.10.0+ #121 Not tainted
> [ 31.659258] -------------------------------
> [ 31.659377] kernel/ve/vznetstat/vznetstat.c:95 suspicious
> rcu_dereference_check() usage!
> [ 31.659597]
> [ 31.659597] other info that might help us debug this:
> [ 31.659597]
> [ 31.659831]
> [ 31.659831] rcu_scheduler_active = 1, debug_locks = 0
> [ 31.660026] 1 lock held by vztactl/831:
> [ 31.660136] #0: (tc_lock){.+.+..}, at: [<ffffffffa0052e64>]
> venet_acct_set_classes+0xf4/0x240 [vznetstat]
> [ 31.660454]
> [ 31.660454] stack backtrace:
> [ 31.660584] CPU: 0 PID: 831 Comm: vztactl ve: 0 Not tainted 3.10.0+ #121
> ovz.9.8-21-g6c64ed7
> [ 31.660823] Hardware name: Parallels Software International Inc. Parallels
> Virtual Platform/Parallels Virtual Platform, BIOS 6.9.23856.1122235 03/18/2015
> [ 31.661201] 0000000000000000 000000003e77c710 ffff8800a960bd88
> ffffffff816298fe
> [ 31.661436] ffff8800a960bdb8 ffffffff810f9667 0000000000000000
> ffff8801446e2f08
> [ 31.661661] 0000000000000000 000000000000000c ffff8800a960bdf0
> ffffffffa0052f61
> [ 31.661910] Call Trace:
> [ 31.661989] [<ffffffff816298fe>] dump_stack+0x19/0x1b
> [ 31.662134] [<ffffffff810f9667>] lockdep_rcu_suspicious+0xe7/0x120
> [ 31.662308] [<ffffffffa0052f61>] venet_acct_set_classes+0x1f1/0x240
> [vznetstat]
> [ 31.662511] [<ffffffffa005390b>] venet_acct_ioctl+0x2bb/0xaf0 [vznetstat]
> [ 31.662706] [<ffffffffa003f0d5>] vzctl_ioctl+0x45/0x60 [vzdev]
> [ 31.662875] [<ffffffff812296d5>] do_vfs_ioctl+0x265/0x540
> [ 31.663041] [<ffffffff81236177>] ? fget_light+0x377/0x4e0
> [ 31.663193] [<ffffffff81229a04>] SyS_ioctl+0x54/0xa0
> [ 31.663334] [<ffffffff8163bf09>] system_call_fastpath+0x16/0x1b
>
>
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
> ---
> kernel/ve/vznetstat/vznetstat.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/ve/vznetstat/vznetstat.c b/kernel/ve/vznetstat/vznetstat.c
> index 99feafb..c47865a 100644
> --- a/kernel/ve/vznetstat/vznetstat.c
> +++ b/kernel/ve/vznetstat/vznetstat.c
> @@ -87,7 +87,7 @@ static int venet_acct_set_classes(const void __user *user_info, int length, int
> goto out_free;
> }
>
> - write_lock_irq(&tc_lock);
> + rcu_read_lock();
> if (v6) {
> old = rcu_dereference(info_v6);
> rcu_assign_pointer(info_v6, info);
> @@ -95,7 +95,7 @@ static int venet_acct_set_classes(const void __user *user_info, int length, int
> old = rcu_dereference(info_v4);
> rcu_assign_pointer(info_v4, info);
> }
> - write_unlock_irq(&tc_lock);
> + rcu_read_unlock();
>
> synchronize_net();
> /* IMPORTANT. I think reset of statistics collected should not be
>
> _______________________________________________
> Devel mailing list
> Devel at openvz.org
> https://lists.openvz.org/mailman/listinfo/devel
>
More information about the Devel
mailing list