1
0
Fork 0
remarkable-linux/net/ieee802154
Lennert Buytenhek 6ab8bb14ed ieee802154: Fix sockaddr_ieee802154 implicit padding information leak.
commit 8a70cefa30 upstream.

The AF_IEEE802154 sockaddr looks like this:

	struct sockaddr_ieee802154 {
		sa_family_t family; /* AF_IEEE802154 */
		struct ieee802154_addr_sa addr;
	};

	struct ieee802154_addr_sa {
		int addr_type;
		u16 pan_id;
		union {
			u8 hwaddr[IEEE802154_ADDR_LEN];
			u16 short_addr;
		};
	};

On most architectures there will be implicit structure padding here,
in two different places:

* In struct sockaddr_ieee802154, two bytes of padding between 'family'
  (unsigned short) and 'addr', so that 'addr' starts on a four byte
  boundary.

* In struct ieee802154_addr_sa, two bytes at the end of the structure,
  to make the structure 16 bytes.

When calling recvmsg(2) on a PF_IEEE802154 SOCK_DGRAM socket, the
ieee802154 stack constructs a struct sockaddr_ieee802154 on the
kernel stack without clearing these padding fields, and, depending
on the addr_type, between four and ten bytes of uncleared kernel
stack will be copied to userspace.

We can't just insert two 'u16 __pad's in the right places and zero
those before copying an address to userspace, as not all architectures
insert this implicit padding -- from a quick test it seems that avr32,
cris and m68k don't insert this padding, while every other architecture
that I have cross compilers for does insert this padding.

The easiest way to plug the leak is to just memset the whole struct
sockaddr_ieee802154 before filling in the fields we want to fill in,
and that's what this patch does.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Acked-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-03 09:28:59 -07:00
..
6lowpan ieee802154: 6lowpan: fix ARPHRD to ARPHRD_6LOWPAN 2015-03-14 17:11:30 +01:00
Kconfig ieee802154: create 6lowpan sub-directory 2015-01-08 07:25:59 +01:00
Makefile ieee802154: Add trace events for rdev->ops 2015-04-30 18:48:09 +02:00
core.c ieee802154: change wpan-phy name to phy 2015-03-14 17:11:30 +01:00
core.h ieee802154: add wpan_phy dump support 2014-11-09 19:50:29 +01:00
header_ops.c ieee802154: move ieee802154 header 2014-10-25 21:39:57 +02:00
ieee802154.h ieee802154: add nl802154 framework 2014-11-09 19:50:29 +01:00
netlink.c netlink: make nlmsg_end() and genlmsg_end() void 2015-01-18 01:03:45 -05:00
nl-mac.c ieee802154: don't export static symbol 2015-03-14 17:11:31 +01:00
nl-phy.c cfg802154: pass name_assign_type to rdev_add_virtual_intf() 2015-04-30 18:48:10 +02:00
nl802154.c cfg802154: pass name_assign_type to rdev_add_virtual_intf() 2015-04-30 18:48:10 +02:00
nl802154.h ieee802154: add nl802154 framework 2014-11-09 19:50:29 +01:00
nl_policy.c ieee802154: mac802154: remove FSF address 2014-10-25 08:07:30 +02:00
rdev-ops.h cfg802154: pass name_assign_type to rdev_add_virtual_intf() 2015-04-30 18:48:10 +02:00
socket.c ieee802154: Fix sockaddr_ieee802154 implicit padding information leak. 2015-08-03 09:28:59 -07:00
sysfs.c ieee802154: remove deprecated sysfs entries 2015-03-14 17:11:30 +01:00
sysfs.h ieee802154: introduce sysfs file 2014-10-28 23:19:09 +01:00
trace.c ieee802154: Add trace events for rdev->ops 2015-04-30 18:48:09 +02:00
trace.h ieee802154: trace: fix endian convertion 2015-04-30 18:48:11 +02:00