From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
Greg Thelen <gthelen@google.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 3.10 06/17] net: add pfmemalloc check in sk_add_backlog()
Date: Fri, 23 Oct 2015 10:44:51 -0700 [thread overview]
Message-ID: <20151023174453.673528842@linuxfoundation.org> (raw)
In-Reply-To: <20151023174453.469858454@linuxfoundation.org>
3.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@google.com>
[ Upstream commit c7c49b8fde26b74277188bdc6c9dca38db6fa35b ]
Greg reported crashes hitting the following check in __sk_backlog_rcv()
BUG_ON(!sock_flag(sk, SOCK_MEMALLOC));
The pfmemalloc bit is currently checked in sk_filter().
This works correctly for TCP, because sk_filter() is ran in
tcp_v[46]_rcv() before hitting the prequeue or backlog checks.
For UDP or other protocols, this does not work, because the sk_filter()
is ran from sock_queue_rcv_skb(), which might be called _after_ backlog
queuing if socket is owned by user by the time packet is processed by
softirq handler.
Fixes: b4b9e35585089 ("netvm: set PF_MEMALLOC as appropriate during SKB processing")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Greg Thelen <gthelen@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/net/sock.h | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -782,6 +782,14 @@ static inline __must_check int sk_add_ba
if (sk_rcvqueues_full(sk, skb, limit))
return -ENOBUFS;
+ /*
+ * If the skb was allocated from pfmemalloc reserves, only
+ * allow SOCK_MEMALLOC sockets to use it as this socket is
+ * helping free memory
+ */
+ if (skb_pfmemalloc(skb) && !sock_flag(sk, SOCK_MEMALLOC))
+ return -ENOMEM;
+
__sk_add_backlog(sk, skb);
sk->sk_backlog.len += skb->truesize;
return 0;
next prev parent reply other threads:[~2015-10-23 17:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 17:44 [PATCH 3.10 00/17] 3.10.92-stable review Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 01/17] l2tp: protect tunnel->del_work by ref_count Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 02/17] af_unix: Convert the unix_sk macro to an inline function for type safety Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 03/17] af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 04/17] skbuff: Fix skb checksum flag on skb pull Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 05/17] skbuff: Fix skb checksum partial check Greg Kroah-Hartman
2015-10-23 17:44 ` Greg Kroah-Hartman [this message]
2015-10-23 17:44 ` [PATCH 3.10 07/17] ppp: dont override sk->sk_state in pppoe_flush_dev() Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 08/17] ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 09/17] asix: Dont reset PHY on if_up for ASIX 88772 Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 10/17] asix: Do full reset during ax88772_bind Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 11/17] m68k/uaccess: Fix asm constraints for userspace access Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 12/17] crypto: sparc - initialize blkcipher.ivsize Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 13/17] crypto: ahash - ensure statesize is non-zero Greg Kroah-Hartman
2015-10-23 17:44 ` [PATCH 3.10 14/17] i2c: rcar: enable RuntimePM before registering to the core Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.10 15/17] workqueue: make sure delayed work run in local cpu Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.10 16/17] dm thin: fix missing pool reference count decrement in pool_ctr error path Greg Kroah-Hartman
2015-10-23 17:45 ` [PATCH 3.10 17/17] rbd: fix double free on rbd_dev->header_name Greg Kroah-Hartman
2015-10-23 21:07 ` [PATCH 3.10 00/17] 3.10.92-stable review Shuah Khan
2015-10-24 2:01 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151023174453.673528842@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gthelen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).