Revision a18e6a186f53af06937a2c268c72443336f4ab56 authored by Thomas Graf on 18 December 2014, 10:30:26 UTC, committed by David S. Miller on 18 December 2014, 17:35:55 UTC
Each mmap Netlink frame contains a status field which indicates
whether the frame is unused, reserved, contains data or needs to
be skipped. Both loads and stores may not be reordeded and must
complete before the status field is changed and another CPU might
pick up the frame for use. Use an smp_mb() to cover needs of both
types of callers to netlink_set_status(), callers which have been
reading data frame from the frame, and callers which have been
filling or releasing and thus writing to the frame.

- Example code path requiring a smp_rmb():
  memcpy(skb->data, (void *)hdr + NL_MMAP_HDRLEN, hdr->nm_len);
  netlink_set_status(hdr, NL_MMAP_STATUS_UNUSED);

- Example code path requiring a smp_wmb():
  hdr->nm_uid	= from_kuid(sk_user_ns(sk), NETLINK_CB(skb).creds.uid);
  hdr->nm_gid	= from_kgid(sk_user_ns(sk), NETLINK_CB(skb).creds.gid);
  netlink_frame_flush_dcache(hdr);
  netlink_set_status(hdr, NL_MMAP_STATUS_VALID);

Fixes: f9c228 ("netlink: implement memory mapped recvmsg()")
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4682a03
History
File Mode Size
Kconfig -rw-r--r-- 1.0 KB
Makefile -rw-r--r-- 150 bytes
hsr_device.c -rw-r--r-- 11.7 KB
hsr_device.h -rw-r--r-- 815 bytes
hsr_forward.c -rw-r--r-- 9.8 KB
hsr_forward.h -rw-r--r-- 577 bytes
hsr_framereg.c -rw-r--r-- 13.1 KB
hsr_framereg.h -rw-r--r-- 1.7 KB
hsr_main.c -rw-r--r-- 3.1 KB
hsr_main.h -rw-r--r-- 4.9 KB
hsr_netlink.c -rw-r--r-- 11.2 KB
hsr_netlink.h -rw-r--r-- 923 bytes
hsr_slave.c -rw-r--r-- 4.3 KB
hsr_slave.h -rw-r--r-- 1.1 KB

back to top