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>,
Andrey Konovalov <andreyknvl@google.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 3.18 33/39] tcp: do not underestimate skb->truesize in tcp_trim_head()
Date: Thu, 11 May 2017 15:03:08 +0200 [thread overview]
Message-ID: <20170511130245.052637499@linuxfoundation.org> (raw)
In-Reply-To: <20170511130238.045434679@linuxfoundation.org>
3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@google.com>
[ Upstream commit 7162fb242cb8322beb558828fd26b33c3e9fc805 ]
Andrey found a way to trigger the WARN_ON_ONCE(delta < len) in
skb_try_coalesce() using syzkaller and a filter attached to a TCP
socket over loopback interface.
I believe one issue with looped skbs is that tcp_trim_head() can end up
producing skb with under estimated truesize.
It hardly matters for normal conditions, since packets sent over
loopback are never truncated.
Bytes trimmed from skb->head should not change skb truesize, since
skb->head is not reallocated.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/ipv4/tcp_output.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1212,7 +1212,7 @@ int tcp_fragment(struct sock *sk, struct
* eventually). The difference is that pulled data not copied, but
* immediately discarded.
*/
-static void __pskb_trim_head(struct sk_buff *skb, int len)
+static int __pskb_trim_head(struct sk_buff *skb, int len)
{
struct skb_shared_info *shinfo;
int i, k, eat;
@@ -1222,7 +1222,7 @@ static void __pskb_trim_head(struct sk_b
__skb_pull(skb, eat);
len -= eat;
if (!len)
- return;
+ return 0;
}
eat = len;
k = 0;
@@ -1248,23 +1248,28 @@ static void __pskb_trim_head(struct sk_b
skb_reset_tail_pointer(skb);
skb->data_len -= len;
skb->len = skb->data_len;
+ return len;
}
/* Remove acked data from a packet in the transmit queue. */
int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
{
+ u32 delta_truesize;
+
if (skb_unclone(skb, GFP_ATOMIC))
return -ENOMEM;
- __pskb_trim_head(skb, len);
+ delta_truesize = __pskb_trim_head(skb, len);
TCP_SKB_CB(skb)->seq += len;
skb->ip_summed = CHECKSUM_PARTIAL;
- skb->truesize -= len;
- sk->sk_wmem_queued -= len;
- sk_mem_uncharge(sk, len);
- sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
+ if (delta_truesize) {
+ skb->truesize -= delta_truesize;
+ sk->sk_wmem_queued -= delta_truesize;
+ sk_mem_uncharge(sk, delta_truesize);
+ sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
+ }
/* Any change of skb->len requires recalculation of tso factor. */
if (tcp_skb_pcount(skb) > 1)
next prev parent reply other threads:[~2017-05-11 13:07 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-11 13:02 [PATCH 3.18 00/39] 3.18.53-stable review Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 01/39] 9p: fix a potential acl leak Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 02/39] tty: remove platform_sysrq_reset_seq Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 03/39] mtd: cfi: reduce stack size Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 04/39] ARM: 8452/3: PJ4: make coprocessor access sequences buildable in Thumb2 mode Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 05/39] cpupower: Fix turbo frequency reporting for pre-Sandy Bridge cores Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 06/39] powerpc/powernv: Fix opal_exit tracepoint opcode Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 07/39] power: supply: bq24190_charger: Fix irq trigger to IRQF_TRIGGER_FALLING Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 08/39] power: supply: bq24190_charger: Call set_mode_host() on pm_resume() Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 09/39] ARM: OMAP5 / DRA7: Fix HYP mode boot for thumb2 build Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 10/39] mwifiex: debugfs: Fix (sometimes) off-by-1 SSID print Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 11/39] mwifiex: Avoid skipping WEP key deletion for AP Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 13/39] kprobes/x86: Fix kernel panic when certain exception-handling addresses are probed Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 14/39] x86/platform/intel-mid: Correct MSI IRQ line for watchdog device Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 16/39] usb: host: ehci-exynos: Decrese node refcount on exynos_ehci_get_phy() error paths Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 17/39] usb: host: ohci-exynos: " Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 18/39] USB: serial: keyspan_pda: fix receive sanity checks Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 19/39] USB: serial: digi_acceleport: fix incomplete rx sanity check Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 20/39] USB: serial: ssu100: fix control-message error handling Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 21/39] USB: serial: io_edgeport: fix epic-descriptor handling Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 22/39] USB: serial: ti_usb_3410_5052: fix control-message error handling Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 23/39] USB: serial: ark3116: fix open " Greg Kroah-Hartman
2017-05-11 13:02 ` [PATCH 3.18 24/39] USB: serial: ftdi_sio: fix latency-timer " Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 25/39] USB: serial: quatech2: fix control-message " Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 26/39] USB: serial: mct_u232: fix modem-status " Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 27/39] USB: serial: io_edgeport: fix descriptor " Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 28/39] USB: serial: sierra: fix bogus alternate-setting assumption Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 29/39] scsi: scsi_dh_emc: return success in clariion_std_inquiry() Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 30/39] brcmfmac: Ensure pointer correctly set if skb data location changes Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 31/39] brcmfmac: Make skb header writable before use Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 32/39] staging: emxx_udc: remove incorrect __init annotations Greg Kroah-Hartman
2017-05-11 13:03 ` Greg Kroah-Hartman [this message]
2017-05-11 13:03 ` [PATCH 3.18 34/39] ipv4, ipv6: ensure raw socket message is big enough to hold an IP header Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 35/39] ipv6: initialize route null entry in addrconf_init() Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 36/39] ipv6: reorder ip6_route_dev_notifier after ipv6_dev_notf Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 37/39] tcp: fix wraparound issue in tcp_lp Greg Kroah-Hartman
2017-05-11 13:03 ` [PATCH 3.18 38/39] f2fs: sanity check segment count Greg Kroah-Hartman
2017-05-11 21:16 ` [PATCH 3.18 00/39] 3.18.53-stable review Guenter Roeck
2017-05-11 21:31 ` Matthijs van Duin
2017-05-11 21:46 ` Tony Lindgren
2017-05-12 9:37 ` Greg Kroah-Hartman
2017-05-12 10:15 ` Arnd Bergmann
2017-05-12 10:44 ` Greg Kroah-Hartman
2017-05-12 15:23 ` Shuah Khan
2017-05-12 19:47 ` Guenter Roeck
2017-05-14 10:56 ` Greg Kroah-Hartman
2017-05-14 14:02 ` Guenter Roeck
2017-05-14 20:58 ` Greg Kroah-Hartman
2017-05-14 23:38 ` Guenter Roeck
2017-05-15 6:17 ` Greg Kroah-Hartman
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=20170511130245.052637499@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=andreyknvl@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@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).