Received: by 10.192.165.148 with SMTP id m20csp270255imm; Wed, 9 May 2018 12:23:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZokZElLJWJnVUxOkAi8I6Ql3gP2+TwVav3Rc4VIxKLyYA7yXweiK0n1k3XN/yFN9WL9ohlo X-Received: by 2002:a63:6f0f:: with SMTP id k15-v6mr36288386pgc.91.1525893787256; Wed, 09 May 2018 12:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525893787; cv=none; d=google.com; s=arc-20160816; b=uUfzaK5QNMDq7PGl1STKmqS0wU0GREUlHzWZ8ucyOdO824cXFYZSp+n+KfY2nYAWjh QxQ/ilOlS4ZqasUSuqoIyTNGtT5sL86rvWO7JtEt0oNW7Y36symUdxb6kAXL/rsoBd+l QzgIi/kpP6T2P59eORsDo23ax9wylm6cO8Vturtj39GRg5eVqxqXcpYH0ppTp4aNj0wW mlTPpqVPLOCPnZCRa/WhFbRT5yyULcHm9pX39E2bl8OyLWLBu057cPBFVQqI6xRJ3hQu 4dax5DBBcDMFC0zyJkj6ztAtMkWk4GOTJHavXhcTUJilMMJkL9Eecdai8q5iEUk+J5y/ 4UUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=zeTRHWpvPK0wCoZ+ES4041KrQUnqw+utrMIXhFmUrbc=; b=bJYDq65W0V+o4a7cBm9eZqfVtZGc9g6phgKs53kuWDi1vWBtQp2nlWCxUW7JXE+Cr+ +QcIBGkKQdukVG569Lv8HKf0pMyJCjUk28aS9nE8k9ZLFMlrwi3+viw5VO1t60BtGx6N cbyxTvmAncDMGEyUvw1HLH+g3CJ8untY3U3IlFRPNpNd1OqodsHJIIWZG6V8ZUPBBqV0 IiEj5K7KRLtJWOtxXgTgpWkqoJ4bXF3T1sSR8Pd8oypfVggoQxeGgLr2xuif6AUGVvEr NPp1eqWSJhlzguhjsvROlZBlF+3mp8eKdVuo6pPieYSvSdm2q24Z2+vKW4r1kbVIjZDw QFeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ql3E3AsJ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si27171108pfj.178.2018.05.09.12.22.52; Wed, 09 May 2018 12:23:07 -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=@gmail.com header.s=20161025 header.b=ql3E3AsJ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965413AbeEITWR (ORCPT + 99 others); Wed, 9 May 2018 15:22:17 -0400 Received: from mail-vk0-f67.google.com ([209.85.213.67]:40534 "EHLO mail-vk0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965051AbeEITWP (ORCPT ); Wed, 9 May 2018 15:22:15 -0400 Received: by mail-vk0-f67.google.com with SMTP id v194-v6so6107924vkd.7; Wed, 09 May 2018 12:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=zeTRHWpvPK0wCoZ+ES4041KrQUnqw+utrMIXhFmUrbc=; b=ql3E3AsJ3y9NbgwwNUcsscq0XX3182hLLV+6Fex7tJaVAUeAkD2Mg4o3bAX/4WE0aS Cx2RJsw3lkvEV0YvrKeu/gBrGvCaiSOolma9YEjoaOPitjAN1zLNPI9DdCJfAsmsDwPR rx2+T7VS5rVhjsKtrh6ORiFIT2R0KQljqIXCJqyvvv4oaZ2pSpYQBK8QzeM7J0v9KVt9 1tXaNuwyOdskCqoDwa8kALfF3jR2qzIA14lT7y0ieSdiX2o3QetfTaenYB0oDTc1HdV1 m7euWDA7TqJVfB8mTH/peahKXpQSoWZS3wDbo6I3NHtYuwQMqOZ778MMQtzLUf7aguVA UVTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=zeTRHWpvPK0wCoZ+ES4041KrQUnqw+utrMIXhFmUrbc=; b=ZcphTZNmc5j6WNO7I9yMZqsu/79ZpKu+W3HZxlQt41AKyo+E1iB/7mwcrnLlUUfAjq B7LODAZfzyk3bxJkv0e2vIIFaRcDoTzIDIMY8peM4eEQZDVvdOj0Z+KDzq8J/0QdEHdN LjsVLIDoSUZu7SSE0CFBDqjrz3J+f36U3mwAeywNv8bTz6SVSK8BA6eyOqkC+Qi6I7OH 5Vb4gcvuRU1AB0/pStW6oVdkpt/XcxRfkCGDlHFeEsAEuP/YH17sUCPjaGvmFVmtARcT Yx0DkfRsDnz7oL19Aa7WM5r9CvITsDJkc099V7Ojdp0+wXkjB9Ce8rRqQb8YSe1KpArJ UXug== X-Gm-Message-State: ALQs6tCASGJzyefxuhkdzxg8uchGDtLPLHQ6AjKcuDH+anbAwjW1M6DA VEOKPfyPzc09hMcINLWXI1hwg+CrrcA5jeRdxgU= X-Received: by 2002:a1f:824a:: with SMTP id e71-v6mr37173571vkd.7.1525893734404; Wed, 09 May 2018 12:22:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.151.90 with HTTP; Wed, 9 May 2018 12:21:33 -0700 (PDT) In-Reply-To: References: <94eb2c0ce3aa27cfa40561ec2dc3@google.com> <1515048794.131759.4.camel@gmail.com> <20180509073754.GG711@sol.localdomain> From: Willem de Bruijn Date: Wed, 9 May 2018 15:21:33 -0400 Message-ID: Subject: Re: KASAN: use-after-free Read in __dev_queue_xmit To: Eric Biggers Cc: Eric Dumazet , syzbot , alexander.deucher@amd.com, Andrey Konovalov , Anoob Soman , chris@chris-wilson.co.uk, David Miller , "Reshetova, Elena" , Greg Kroah-Hartman , Kees Cook , LKML , Mike Maloney , mchehab@kernel.org, netdev , "Rosen, Rami" , Sowmini Varadhan , syzkaller-bugs@googlegroups.com, Willem de Bruijn 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 On Wed, May 9, 2018 at 12:38 PM, Willem de Bruijn wrote: >>> But a crash with the same signature is still occurring, so it should eventually >>> get reported again. C reproducer is here, it works on Linus' tree (commit >>> 036db8bd963): https://syzkaller.appspot.com/text?tag=ReproC&x=105b1ae7800000 >> >> This appears to be a separate issue. >> >> This reproducer requires a setsockopt SOL_SOCKET/SO_TIMESTAMPING >> to trigger the use-after-free. And the freed path also points at a timestamping >> skb: >> >> [ 31.963619] Freed by task 2672: >> [ 31.964006] __kasan_slab_free+0x125/0x170 >> [ 31.964509] kfree+0x8b/0x1a0 >> [ 31.964875] skb_free_head+0x6f/0xa0 >> [ 31.965314] skb_release_data+0x420/0x5a0 >> [ 31.965802] skb_release_all+0x46/0x60 >> [ 31.966260] kfree_skb+0x91/0x1c0 >> [ 31.966669] __skb_complete_tx_timestamp+0x2e9/0x3d0 >> [ 31.967273] __skb_tstamp_tx+0x3b3/0x620 >> [ 31.967774] __dev_queue_xmit+0xed5/0x1a20 >> [ 31.968300] packet_sendmsg+0x36fd/0x5400 >> [ 31.968821] sock_sendmsg+0xc0/0x100 >> [ 31.969284] ___sys_sendmsg+0x367/0x880 >> [ 31.969777] __sys_sendmmsg+0x178/0x410 >> [ 31.970267] __x64_sys_sendmmsg+0x99/0x100 >> [ 31.970789] do_syscall_64+0x9a/0x2c0 >> [ 31.971260] entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > This is a rare path taken when the timestamp skb cannot be queued > onto the socket (likely because of insufficient rcvbuf). > > Somehow, freeing the timestamp skb triggers this use-after-free in > the original skb from which the timestamp was cloned. As if there > is a bug in the shared info dataref. Indeed. The skb shared info struct is zeroed by dev_validate_header as a result of dev->hard_header_len exceeding skb->end - skb->data. Not exactly sure yet how this can happen. The hard header length space is accounted for during allocation as reserved memory. But, packet_alloc_skb does call skb_reserve(), moving skb->data effectively beyond this reserved region. It may be incorrect to pass skb->data to dev_validate_header, as that does not point to the start of the ll_header anymore. Still figuring out what the right fix is..