Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5451926imm; Tue, 16 Oct 2018 10:25:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV6145ba4Uceh3DC4EAxiuwaOJ6iHFCqqVuwjT3tSfYIQi9OnoH+mQRFxqiBMFECIS67I4ckJ X-Received: by 2002:a63:a80c:: with SMTP id o12-v6mr21203486pgf.271.1539710732278; Tue, 16 Oct 2018 10:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539710732; cv=none; d=google.com; s=arc-20160816; b=XyyYBAtE1gs58Qw/U5uA2jf3hDxd88MtFbJRfPc/ymd9otJHEZTs6WQYLBduvL2IV9 UZYXzyIeONg6STihkNE03uUyMENsKmtnPptjDZZw3vQtPtg393PutSIUqw64ipKPNXIZ SubRK5TRMxfeorcG3Tl9Od8o7R2qrINcUu6chyHpZTf2WMGrMbO+amCI+qq2nrbn5fVj TUvc0dc9D549o3QVESdvGMONUvKqKrCvj2nhMmpXCuQTiSBvSh/Knivq+5VMcf+ja6UX Rmf2Wc3Onmi5tFe/KHguR0ZiaC2CXXvnKKYcZPA4baaUtL6GFrVNY4y7Pa4NKXwfck9+ CPNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L5mWcXl2AP35STQmk3c9+/RblZCPgXbppdy+cOumwro=; b=GDInBhr3S9aN/TZSCXzqQqrpcXS0JG0C+OTWLFSqPZPbCD8JBpcBkMXqxiv3Igkm8c hXRss3KSa7PeNb2Su3XpPRwW/DnNQpp9M+Nc2ST0aQKEqkMhUUf8TQJ2q6pnrX3ODqqg UhjPX1dX1TKJsSFml8/jylaslsqKVli8RWRjrVTQYD/AB17kJ558Asc0K8/G4uFkeLXX GrA9n2X4xSKJz11i3UYpIga6pLBrktLHp10imvPTYXgNLVfQSAolrOycCSEKwty6p9Aw DB4tkpwhpXhufn7HYSy+vwViz3quPCtNMiKFXnTeNwDSsZgfB1b7uzpxVCdScy4bcNMZ JweA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=as5PFs1r; 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 j3-v6si14786490pld.231.2018.10.16.10.25.15; Tue, 16 Oct 2018 10:25:32 -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=as5PFs1r; 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 S1731424AbeJQBO5 (ORCPT + 99 others); Tue, 16 Oct 2018 21:14:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:33448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730397AbeJQBO4 (ORCPT ); Tue, 16 Oct 2018 21:14:56 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 40E9D20866; Tue, 16 Oct 2018 17:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710610; bh=8VMKZVl1XUnG4zde9geNPLXtx6U+GmWBRA5HkspuBBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=as5PFs1r5C0ZrKCyt2LQ+wryAiPeCjDiQ1qA6BE1IXGRkSDq1303U7mrdXEuyFg5/ Gb72vvkHYPAb5ZC1Ya5ucNeP/NVIGbP+pIYh3i0n7x+fwENRS4AHsa0BMzzxoP2DqT g9oleLftVU0hKHcJD5rOf1RoZZD0XqjgoznVlRj4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Willem de Bruijn , syzbot , "David S. Miller" Subject: [PATCH 4.9 26/71] ipv4: fix use-after-free in ip_cmsg_recv_dstaddr() Date: Tue, 16 Oct 2018 19:09:23 +0200 Message-Id: <20181016170540.711499782@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 64199fc0a46ba211362472f7f942f900af9492fd ] Caching ip_hdr(skb) before a call to pskb_may_pull() is buggy, do not do it. Fixes: 2efd4fca703a ("ip: in cmsg IP(V6)_ORIGDSTADDR call pskb_may_pull") Signed-off-by: Eric Dumazet Cc: Willem de Bruijn Reported-by: syzbot Acked-by: Willem de Bruijn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_sockglue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -134,7 +134,6 @@ static void ip_cmsg_recv_security(struct static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb) { struct sockaddr_in sin; - const struct iphdr *iph = ip_hdr(skb); __be16 *ports; int end; @@ -149,7 +148,7 @@ static void ip_cmsg_recv_dstaddr(struct ports = (__be16 *)skb_transport_header(skb); sin.sin_family = AF_INET; - sin.sin_addr.s_addr = iph->daddr; + sin.sin_addr.s_addr = ip_hdr(skb)->daddr; sin.sin_port = ports[1]; memset(sin.sin_zero, 0, sizeof(sin.sin_zero));