Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2039198imm; Thu, 24 May 2018 04:58:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpdMyz8odEQOqc/Zj2WbEbN/0x2EOqp04qZyqG4yMdunGCHnBeMVrfvc7oKC2Ve0fQ3Jgxl X-Received: by 2002:a62:89db:: with SMTP id n88-v6mr6925988pfk.11.1527163098248; Thu, 24 May 2018 04:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163098; cv=none; d=google.com; s=arc-20160816; b=GgFnIvd/q0X7nMUS2BE5L8kPDh9UB5JA3L0zyo8Nggsd0WF7t+MPNQTwH3vSU44/c4 m2M1M+kMEaz/uE+uJnY169fh5TJwlmgPYSFspk/c4xnnK0YzlZVniQRr68ZphCYsuHah EVyEd2mHYd83Kh/QZSOjPB7o2+k1FAZ0hGZmCnItZa2rtrYD5rITsj4wqa62vB22p5ep QVxTdDI888CXI9FvgrcBK4PfKrGUbwSUJvrsgmlhuhq7OIGxiMsaQFgNZK+DI4YnfJaP 9JU6hNgXZYQBqTMMOoKDv6lCJxqHEGzJKvC8pKiaDwERN2VlSeNlDHdRR7cRratRGEDF 5d/A== 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=JLU9O5UeOsa+0ncVhx+j7sWgOxNAxEMqOS8c8kxPUjo=; b=KhgrwMBecXPXiacCzp1/KH+EeEt0khuP9rrUeaI5HSdnASBkb8r9xHfPMGJIbwOlkx MQ8dhZHeZm31RvfzYP1L/z2RhPvdbmXbPf7bThrOgydZS7xcZAaiqk6OceFEI2Y3+LeD 48/IsUnv5GI2dgbH2UgimxgBvadU9XnpYKjguusel/Ah48Qv9KErh//Q2KgBMvsTucZH 4nVAnCaJB6vsPuWg8QS4cjSt7clAcrK3LhH3ZCec7y4rXJgHNF2QWFeObO5w49g81Mq6 FuA9A/tgYsYIJ9VeCOKaV/YRXCFlx1uChhsXSH/T4R6KM/OymKrpJuHWlrOXu5sFqTOA KLEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MHCq8+ry; 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 x21-v6si4625459pgx.55.2018.05.24.04.58.03; Thu, 24 May 2018 04:58:18 -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=MHCq8+ry; 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 S969428AbeEXL4V (ORCPT + 99 others); Thu, 24 May 2018 07:56:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:57020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966843AbeEXJpv (ORCPT ); Thu, 24 May 2018 05:45:51 -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 6417C208BA; Thu, 24 May 2018 09:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155150; bh=Uh2L1H56OhdBROFkM6RtYm5o9DjBQSjlGkqOJcjbNKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MHCq8+ryPnlwDTr6FTGIFEd4q0rPZkhqt0Ejc9a3n/0IOiuuVuPaVtYO3uLp9pUn3 BfNpn5SBvdBhHIa+RJ+FHyQdwccmkayDkSt5+MnD2QOaK7LELcJ3qjKXAh8ASDmK8n tq0vYSXRXV9cCbH04T5unL90/pdkdoVNV51k22eg= 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.4 72/92] packet: in packet_snd start writing at link layer allocation Date: Thu, 24 May 2018 11:38:49 +0200 Message-Id: <20180524093206.227673739@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@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.4-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 @@ -2771,13 +2771,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 */