mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 02:39:48 +00:00
ipv6: use READ_ONCE() for inet->hdrincl as in ipv4
[ Upstream commit59e3e4b526
] As it was done in commit8f659a03a0
("net: ipv4: fix for a race condition in raw_sendmsg") and commit20b50d7997
("net: ipv4: emulate READ_ONCE() on ->hdrincl bit-field in raw_sendmsg()") for ipv4, copy the value of inet->hdrincl in a local variable, to avoid introducing a race condition in the next commit. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4b83a95655
commit
ee6e0cec59
1 changed files with 10 additions and 2 deletions
|
@ -782,6 +782,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
|
|||
struct sockcm_cookie sockc;
|
||||
struct ipcm6_cookie ipc6;
|
||||
int addr_len = msg->msg_namelen;
|
||||
int hdrincl;
|
||||
u16 proto;
|
||||
int err;
|
||||
|
||||
|
@ -795,6 +796,13 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
|
|||
if (msg->msg_flags & MSG_OOB)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* hdrincl should be READ_ONCE(inet->hdrincl)
|
||||
* but READ_ONCE() doesn't work with bit fields.
|
||||
* Doing this indirectly yields the same result.
|
||||
*/
|
||||
hdrincl = inet->hdrincl;
|
||||
hdrincl = READ_ONCE(hdrincl);
|
||||
|
||||
/*
|
||||
* Get and verify the address.
|
||||
*/
|
||||
|
@ -913,7 +921,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
|
|||
fl6.flowi6_oif = np->ucast_oif;
|
||||
security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
|
||||
|
||||
if (inet->hdrincl)
|
||||
if (hdrincl)
|
||||
fl6.flowi6_flags |= FLOWI_FLAG_KNOWN_NH;
|
||||
|
||||
if (ipc6.tclass < 0)
|
||||
|
@ -936,7 +944,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
|
|||
goto do_confirm;
|
||||
|
||||
back_from_confirm:
|
||||
if (inet->hdrincl)
|
||||
if (hdrincl)
|
||||
err = rawv6_send_hdrinc(sk, msg, len, &fl6, &dst, msg->msg_flags);
|
||||
else {
|
||||
ipc6.opt = opt;
|
||||
|
|
Loading…
Reference in a new issue