]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ipvs: fix racy memcpy in proc_do_sync_threshold
authorSishuai Gong <sishuai.system@gmail.com>
Thu, 10 Aug 2023 19:12:42 +0000 (15:12 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Aug 2023 14:35:14 +0000 (16:35 +0200)
commit58a3d1d4b3908d29e988061d59399ee6422273a0
tree30708139b18f651fa5d49d9c08746ae5a872308c
parentdbcfa782d9be607abfebbc5842264fb2d9529b9d
ipvs: fix racy memcpy in proc_do_sync_threshold

commit 5310760af1d4fbea1452bfc77db5f9a680f7ae47 upstream.

When two threads run proc_do_sync_threshold() in parallel,
data races could happen between the two memcpy():

Thread-1 Thread-2
memcpy(val, valp, sizeof(val));
memcpy(valp, val, sizeof(val));

This race might mess up the (struct ctl_table *) table->data,
so we add a mutex lock to serialize them.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://lore.kernel.org/netdev/B6988E90-0A1E-4B85-BF26-2DAF6D482433@gmail.com/
Signed-off-by: Sishuai Gong <sishuai.system@gmail.com>
Acked-by: Simon Horman <horms@kernel.org>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/ipvs/ip_vs_ctl.c