[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b4854287-cb97-27fb-053f-e52179c05e97@ssi.bg>
Date: Thu, 10 Aug 2023 09:20:28 +0300 (EEST)
From: Julian Anastasov <ja@....bg>
To: Sishuai Gong <sishuai.system@...il.com>
cc: horms@...ge.net.au,
Linux Kernel Network Developers <netdev@...r.kernel.org>,
lvs-devel@...r.kernel.org
Subject: Re: Race over table->data in proc_do_sync_threshold()
Hello,
On Wed, 9 Aug 2023, Sishuai Gong wrote:
> Hi,
>
> We observed races over (struct ctl_table *) table->data when two threads
> are running proc_do_sync_threshold() in parallel, as shown below:
>
> Thread-1 Thread-2
> memcpy(val, valp, sizeof(val)); memcpy(valp, val, sizeof(val));
>
> This race probably would mess up table->data. Is it better to add a lock?
We can put mutex_lock(&ipvs->sync_mutex) before the first
memcpy and to use two WRITE_ONCE instead of the second memcpy. But
this requires extra2 = ipvs in ip_vs_control_net_init_sysctl():
tbl[idx].data = &ipvs->sysctl_sync_threshold;
+ tbl[idx].extra2 = ipvs;
Will you provide patch?
Regards
--
Julian Anastasov <ja@....bg>
Powered by blists - more mailing lists