Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1917323imm; Thu, 24 May 2018 02:54:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo1id1eFAphtLxN1RY/Mg7Lnsnh0tAfABPJ6DzjC2/t2WvQkoxHEUV6WkUGD9A0ERswL8TZ X-Received: by 2002:a17:902:850a:: with SMTP id bj10-v6mr6493971plb.239.1527155685498; Thu, 24 May 2018 02:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527155685; cv=none; d=google.com; s=arc-20160816; b=wI54Oac6OI7oW85bJ+OzthYIt2qHaa22kW6R6WyePtgk9FYMmwSEAMX5NLdGAva54F 4Oh5Vams/d42TAXqnMxTa9DLF4+p/ZIEr+IZiZeO6WAbegjZbSqxN+2OMnu20/ECSQJc Zrwh3wsZ3Z1ylQhq7liP0D3CVpPv1XF4iW0GoikhLxgQBy6r5lzT//n3nMHWgQ1rY926 5AHld73CEF2KsqkUstHyiWrK88NFChrLFMxveoxcHd3NFfLRGu3rYHHnL+3CWMKrnjNA zjeRCdlSJbYltInoBw0a9lIj0qRxoSVaSsSwA9J5Vatbh9oZmMX70fptSRmrsLIOdSLW FEwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=zpMOL45XSIC9I+uunuZFCYxYMuJl4ZNFEzPHmnUOHJA=; b=OYkKCP5l/8SRlAQuFviHJvIedsDI/ADR/eFh04szuCFLMkHbP+lhpJDGq/uLFyrzUm WM3DggUBxHncrzFiAbvYQRSC46Tw6L6Pi00saFLRJLVV27cx7tNzSdXoe68hPdAN0iIA 6gPSKWTdAxyHNqZ2f8d9Ccm7aOePKM1bHwzbl0N6gKQ2ESJzADsc7TRytAEaU+74RRVx JHx8wp6PJpG47UiJvuhonXUJ0YiFrFo+XECUw9iW/j5RA2L97hSgWl5m6EYhGXxK8E/1 MTm3hzy1hVAoxfSGlLUsIfClSGmDDd+jY7YS1/+HqtDjwVto6i4WxBZ682UtLcT2k9qF zgJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ms0/zhSq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2-v6si10185560pgf.432.2018.05.24.02.54.31; Thu, 24 May 2018 02:54:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ms0/zhSq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967993AbeEXJxI (ORCPT + 99 others); Thu, 24 May 2018 05:53:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:56196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967967AbeEXJxD (ORCPT ); Thu, 24 May 2018 05:53:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E236E20847; Thu, 24 May 2018 09:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155582; bh=hzgjLyHI+h6LtrSs+wmihVwkLTRi6426f/7KmxTzijU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ms0/zhSqGQXr1t06iLf09kWpIj/MEPeJ6Q430fXZbXJaY50bRnWbVJL8byrNvzFEk XaaobzqgTsiuvUdJVBDHfsyYBk6kDcy5W2Cr96F2m3jgNUdjfqEsu3t6BMSajbjxpA cbGnlqGiDsYO/9o89feFvlyoewhCzyGQ5irmkwAg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+71d74a5406d02057d559@syzkaller.appspotmail.com, Willem de Bruijn , "David S. Miller" Subject: [PATCH 4.14 007/165] packet: in packet_snd start writing at link layer allocation Date: Thu, 24 May 2018 11:36:53 +0200 Message-Id: <20180524093622.272797943@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Willem de Bruijn [ Upstream commit b84bbaf7a6c8cca24f8acf25a2c8e46913a947ba ] Packet sockets allow construction of packets shorter than dev->hard_header_len to accommodate protocols with variable length link layer headers. These packets are padded to dev->hard_header_len, because some device drivers interpret that as a minimum packet size. packet_snd reserves dev->hard_header_len bytes on allocation. SOCK_DGRAM sockets call skb_push in dev_hard_header() to ensure that link layer headers are stored in the reserved range. SOCK_RAW sockets do the same in tpacket_snd, but not in packet_snd. Syzbot was able to send a zero byte packet to a device with massive 116B link layer header, causing padding to cross over into skb_shinfo. Fix this by writing from the start of the llheader reserved range also in the case of packet_snd/SOCK_RAW. Update skb_set_network_header to the new offset. This also corrects it for SOCK_DGRAM, where it incorrectly double counted reserve due to the skb_push in dev_hard_header. Fixes: 9ed988cd5915 ("packet: validate variable length ll headers") Reported-by: syzbot+71d74a5406d02057d559@syzkaller.appspotmail.com Signed-off-by: Willem de Bruijn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/packet/af_packet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2912,13 +2912,15 @@ static int packet_snd(struct socket *soc if (skb == NULL) goto out_unlock; - skb_set_network_header(skb, reserve); + skb_reset_network_header(skb); err = -EINVAL; if (sock->type == SOCK_DGRAM) { offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len); if (unlikely(offset < 0)) goto out_free; + } else if (reserve) { + skb_push(skb, reserve); } /* Returns -EFAULT on error */