linux/drivers/net
Michal Hocko 2f064f3485 mm: make page pfmemalloc check more robust
Commit c48a11c7ad ("netvm: propagate page->pfmemalloc to skb") added
checks for page->pfmemalloc to __skb_fill_page_desc():

        if (page->pfmemalloc && !page->mapping)
                skb->pfmemalloc = true;

It assumes page->mapping == NULL implies that page->pfmemalloc can be
trusted.  However, __delete_from_page_cache() can set set page->mapping
to NULL and leave page->index value alone.  Due to being in union, a
non-zero page->index will be interpreted as true page->pfmemalloc.

So the assumption is invalid if the networking code can see such a page.
And it seems it can.  We have encountered this with a NFS over loopback
setup when such a page is attached to a new skbuf.  There is no copying
going on in this case so the page confuses __skb_fill_page_desc which
interprets the index as pfmemalloc flag and the network stack drops
packets that have been allocated using the reserves unless they are to
be queued on sockets handling the swapping which is the case here and
that leads to hangs when the nfs client waits for a response from the
server which has been dropped and thus never arrive.

The struct page is already heavily packed so rather than finding another
hole to put it in, let's do a trick instead.  We can reuse the index
again but define it to an impossible value (-1UL).  This is the page
index so it should never see the value that large.  Replace all direct
users of page->pfmemalloc by page_is_pfmemalloc which will hide this
nastiness from unspoiled eyes.

The information will get lost if somebody wants to use page->index
obviously but that was the case before and the original code expected
that the information should be persisted somewhere else if that is
really needed (e.g.  what SLAB and SLUB do).

[akpm@linux-foundation.org: fix blooper in slub]
Fixes: c48a11c7ad ("netvm: propagate page->pfmemalloc to skb")
Signed-off-by: Michal Hocko <mhocko@suse.com>
Debugged-by: Vlastimil Babka <vbabka@suse.com>
Debugged-by: Jiri Bohac <jbohac@suse.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>
Acked-by: Mel Gorman <mgorman@suse.de>
Cc: <stable@vger.kernel.org>	[3.6+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-08-21 14:30:10 -07:00
..
appletalk
arcnet drivers/net: remove all references to obsolete Ethernet-HOWTO 2015-06-23 06:50:35 -07:00
bonding bonding: Gratuitous ARP gets dropped when first slave added 2015-08-12 14:37:33 -07:00
caif
can can: mcp251x: get regulators optionally 2015-07-16 09:04:22 +02:00
cris
dsa net: dsa: bcm_sf2: do not use indirect reads and writes for 7445E0 2015-07-20 16:47:30 -07:00
ethernet mm: make page pfmemalloc check more robust 2015-08-21 14:30:10 -07:00
fddi fddi: print an address with %p format specifier rather than %x 2015-06-07 00:31:22 -07:00
hamradio mkiss: Fix error handling in mkiss_open() 2015-08-10 21:10:31 -07:00
hippi
hyperv Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2015-06-24 16:49:49 -07:00
ieee802154 at86rf230: cleanup start and stop callbacks 2015-06-16 18:55:11 +02:00
ipvlan ipvlan: ignore addresses from ipv6 autoconfiguration 2015-07-15 21:33:40 -07:00
irda irda: irda-usb: use msecs_to_jiffies for conversions 2015-05-25 17:39:21 -04:00
phy net: phy: fix semicolon.cocci warnings 2015-08-17 15:53:06 -07:00
plip
ppp ppp: fix device unregistration upon netns deletion 2015-08-17 12:22:20 -07:00
slip
team switchdev: add support for fdb add/del/dump via switchdev_port_obj ops. 2015-05-17 22:49:09 -04:00
usb net: qmi_wwan: add HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module 2015-08-17 15:39:58 -07:00
vmxnet3 vmxnet3: prevent receive getting out of sequence on napi poll 2015-07-08 23:36:11 -07:00
wan cosa: missing error code on failure in probe() 2015-08-12 16:53:11 -07:00
wimax
wireless rtlwifi: rtl8723be: Add module parameter for MSI interrupts 2015-08-03 11:26:24 +03:00
xen-netback xen/netback: Wake dealloc thread after completing zerocopy work 2015-08-06 23:42:48 -07:00
dummy.c
eql.c
geneve.c geneve: allow user to specify TOS info for tunnel frames 2015-06-01 17:05:04 -07:00
ifb.c act_mirred: Fix bogus header when redirecting from VLAN 2015-04-17 13:29:28 -04:00
Kconfig A very significant modification to NTB in this series. 2015-07-04 14:07:47 -07:00
LICENSE.SRC
loopback.c
macvlan.c macvlan: Propagate promiscuity setting to lower devices. 2015-05-04 00:14:13 -04:00
macvtap.c macvtap: fix network header pointer for VLAN tagged pkts 2015-07-27 14:49:54 -07:00
Makefile geneve: add initial netdev driver for GENEVE tunnels 2015-05-13 15:59:13 -04:00
mdio.c
mii.c
netconsole.c netconsole: implement extended console support 2015-06-25 17:00:39 -07:00
nlmon.c
ntb_netdev.c NTB: ntb_netdev not covering all receive errors 2015-08-09 16:32:21 -04:00
rionet.c
sb1000.c
Space.c
sungem_phy.c
tun.c virtio/vhost: cross endian support 2015-07-03 16:02:25 -07:00
veth.c
virtio_net.c virtio-net: drop NETIF_F_FRAGLIST 2015-08-07 00:13:10 -07:00
vxlan.c vxlan: release lock after each bucket in vxlan_cleanup 2015-05-27 13:33:21 -04:00
xen-netfront.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-07-01 14:58:07 -07:00