Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6599624imm; Mon, 23 Jul 2018 22:57:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcbxibTGHnVqCfLCw41p5VMDiVhog19pKFBbiGYEuuXx4E7wWFQ3C/K0eZ/07IgFgUUCgcR X-Received: by 2002:a63:b02:: with SMTP id 2-v6mr14502486pgl.301.1532411829078; Mon, 23 Jul 2018 22:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532411829; cv=none; d=google.com; s=arc-20160816; b=opgC9Y/HVZ78z4K45I6qpKNi9WE3k73ECPB5n0DL+QejmA/tbJ9Nv3gLKhQ2IG7d4b 2QwoYir6zR1ZV26wq8tUiSeanwEfvro1ga5sWfxQU7//ae/AQjYIhQhsziJI5YhSk0C2 48CbNNdaBpSWtGwa+OmuMv/Q90iVmz5qv6vhPSb2B1ulYd6Y7nN0zJW0htr8Sbna5/yB mYQHjqJjqn/fNjZ2PehzMaisQsU+q18gGCjBg4/NyMyhQHUCy0uHv4MUR5LjS9TG0jex 9F7vHkrA2+nUXJndn324Ig8IUHU20aC1vnb9rrsgehhUaGCAtdTys0oqAFbPXi6SB4Ng G7kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature :arc-authentication-results; bh=HJo2GSQsG0Rq8+QEvAyvSmBuFvSnujlifPtmrbDyFLw=; b=uZ58aLpjccpfne8MlRmmO2vEoyqsTSKT0vTOC3HHd5DZRpjcZ4nRgY4XGp35pd0LdV 4JueY55wXt09Ya+0OBe72HjlPkScOwCCUR1+fFmgl2b5hl0DaN4Wega+XzIe67jMT71o jF97cYLGcXONocAKI5fGPxmyobrYJ6RxGxMrYEDlwIx1Nv9otmhjuNXrcmTHZOU1EM2s Ra+g5/iefRjzapzLN2AWSLgucY6pPX2r80qU2VXKe2aeXr7ptTqcmwBa2WsdgKHbj3BN KWfcKlgQFe9Frnp6PmVB3u75IB8mzQ2M2ITT9JK7YEtMa/w9rt1O/LWT3NXkasNgZpwI 8+tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p7kpTsmf; 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 l11-v6si9200661pgq.174.2018.07.23.22.56.54; Mon, 23 Jul 2018 22:57:09 -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=p7kpTsmf; 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 S2388285AbeGXHAu (ORCPT + 99 others); Tue, 24 Jul 2018 03:00:50 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43150 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388245AbeGXHAt (ORCPT ); Tue, 24 Jul 2018 03:00:49 -0400 Received: by mail-pg1-f196.google.com with SMTP id v13-v6so2059388pgr.10; Mon, 23 Jul 2018 22:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version; bh=HJo2GSQsG0Rq8+QEvAyvSmBuFvSnujlifPtmrbDyFLw=; b=p7kpTsmfjxSpepTz/wntvAEsv22xPyonwMwg74k+eS5N0UHLal7yaJFJMWMU9Q6PMi 9e4QPlPYXwiKKO1jOA4KS/+sou1MPdFieWSehb1UhOLcTmVqNkHIf4+m/56fxj+xUFhl +kPi4FpL0XApMAeQ1RvLafY51p0qdHWA5mfaQDjiq1RgKzcYrsBXx6qbqLqO4Ns4PiSG lwwSEy3xsL63o2vs6qRwbNnvzv91MINhh77V9OhXeYF5P0o6NgiAtJFFiwDcadzuDUOd 7bz5Pmx9U6a0uZP7zppEDEc+EwpIPTiz2N7kq2V781EIhT3L6kvc43Qci4EtNfhQlY7+ kP3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version; bh=HJo2GSQsG0Rq8+QEvAyvSmBuFvSnujlifPtmrbDyFLw=; b=E50WqFCs6rQlLvrtOpHXGEfK2zn/dP0xSrdzLOdqbRNKtodgflwOO1R+cVlYrT8DfU Cwo72zAsdYV2Di69uvbtWvqnzQeAOVAGyYzHbzbCVPUt8i5PvYgT/3YRZyN2jPswgFKl rM2cWOffikUuJcw49WbsZm4x7rznH96pMEqozeMhQX69OpBOlSO1d6ZbqxWdKApsueqz Z58RDQI0vc0u2Rl+7w+w85CzZ05DzBu4D8Y+SY3B1JM1BGw6AwcTdVHpU3gpfFtKtG3V 4R3uYzpQkzpk3Xof1NWeVN3t7B1qwoEkvWgmulJAbxtIKC/7g4WaEEn3tKg5DfGrXZjk p2nw== X-Gm-Message-State: AOUpUlFPsRbGhcLdYXQCXrempGYDG7m6xOmSrlhBdf7/HOwK2X+eImJK WAti03oZ7IMxc5OzFeDIMqE= X-Received: by 2002:a62:3a5b:: with SMTP id h88-v6mr16323799pfa.61.1532411764028; Mon, 23 Jul 2018 22:56:04 -0700 (PDT) Received: from [102.12.68.45] ([175.223.10.199]) by smtp.gmail.com with ESMTPSA id r71-v6sm18793308pfg.43.2018.07.23.22.56.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 22:56:03 -0700 (PDT) Date: Tue, 24 Jul 2018 14:54:21 +0900 From: DaeRyong Jeong To: Al Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, byoungyoung@purdue.edu, kt0755@gmail.com, bammanag@purdue.edu Message-ID: In-Reply-To: <20180724052929.GI30522@ZenIV.linux.org.uk> References: <20180724034542.GA19283@dragonet> <20180724051726.GH30522@ZenIV.linux.org.uk> <20180724052929.GI30522@ZenIV.linux.org.uk> Subject: Re: KASAN: use-after-free Read in link_path_walk X-Readdle-Message-ID: f5266b91-0305-4d1c-af17-d982edc50035@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="5b56bf6d_1befd79f_5b9" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --5b56bf6d_1befd79f_5b9 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Because our fuzzer has a problem, I don't have a C reproducer so far. I reported the crash becasue I saw the crash repeatedly in our fuzzer and I hoped the report is helpful. But it seems not enough. If I was wrong and I made you confused, I am really sorry for that. Could you give me a second? I am trying to fix our fuzzer and to make a C reproducer. I think the C reproducer is necessary here. On 24 Jul 2018, 2:29 PM +0900, Al Viro , wrote: > On Tue, Jul 24, 2018 at 06:17:26AM +0100, Al Viro wrote: > > On Tue, Jul 24, 2018 at 12:45:42PM +0900, Dae R. Jeong wrote: > > > Diagnosis: > > > We think that it is possible that link_path_walk() dereferences a > > > freed pointer when cleanup_mnt() is executed between path_init() and > > > link_path_walk(). > > > > > > Since I'm not an expert on a file system and don't fully understand > > > the crash, please see a executed program and a crash log below in > > > case that my understanding is wrong. > > > > > > > > > Executed Program: > > > Thread0 Thread1 > > > mkdir("./file0") > > > |--------------------------| > > > | mount("./file0", "./file0", "devpts", 0x0, "") > > > | | > > > openat(AT_FDCWD, chroot("./file0") > > > "/dev/vcs", 0x200, 0x0) umount("./file0", 0x2) > > > > > > openat(), chroot(), umount() syscalls are executed after mount() syscall. > > > We think a race occurs between openat() and chroot() because RaceFuzzer > > > executed openat() and chroot() concurrently. > > > > > > > > > (Possible) Thread interleaving: > > > CPU0 (path_openat) CPU1 (cleanup_mnt) > > Wait a bloody minute. Where does cleanup_mnt() come from in that thing? > You are doing lazy-umount of the thing you've chrooted into; if it ends > up with zero refcount on that mount, we are already in deep, deep trouble, > races with open() on not. Simply following that with stat / (in thread 1, > without thread0 at all) would end up accessing the same vfsmount. And > if it's been freed, we are well and truly fucked, race or no race. > > I really want details. *Is* cleanup_mnt() called by thread 1 in your > reproducer before the use-after-free hits? And what's the root of > thread 0 at that point? --5b56bf6d_1befd79f_5b9 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Because our fuzzer has a problem, I = don't have a C reproducer so far.
I reported the crash becasue I saw the crash repeatedly in our fuzzer and= I hoped the report is helpful. But it seems not enough.
If I was wrong and I made you confused, I am really sorry for that.
= Could you give me a second=3F
I am trying to fix our fuzzer and to make a C reproducer.
I think the C reproducer is necessary here.
On 24 Jul 2018, 2:29 PM +0900, Al V= iro <viro=40zeniv.linux.org.uk>, wrote:
On Tue, Jul 24, 2018 at 06:17:26AM +0100, A= l Viro wrote:
On Tue, Jul 24, 2018 at 12:45:42PM +0900, D= ae R. Jeong wrote:
Diagnosis:
We think that it is possible that link=5Fpath=5Fwalk() dereferences a
freed pointer when cleanup=5Fmnt() is executed between path=5Finit() and<= br /> link=5Fpath=5Fwalk().

Since I'm not an expert on a file system and don't fully understand
= the crash, please see a executed program and a crash log below in
case that my understanding is wrong.


Executed Program:
Thread0 Thread1
mkdir(=22./file0=22)
=7C--------------------------=7C
=7C mount(=22./file0=22, =22./file0=22, =22devpts=22, 0x0, =22=22)
=7C =7C
openat(AT=5F=46DCWD, chroot(=22./file0=22)
=22/dev/vcs=22, 0x200, 0x0) umount(=22./file0=22, 0x2)

openat(), chroot(), umount() syscalls are executed after mount() syscall.=
We think a race occurs between openat() and chroot() because Race=46uzzer=
executed openat() and chroot() concurrently.


(Possible) Thread interleaving:
CPU0 (path=5Fopenat) CPU1 (cleanup=5Fmnt)

Wait a bloody minute. Where does cleanup=5Fmnt() come from in that thing=3F=
You are doing lazy-umount of the thing you've chrooted into; if it ends up with zero refcount on that mount, we are already in deep, deep trouble= ,
races with open() on not. Simply following that with stat / (in thread 1,=
without thread0 at all) would end up accessing the same vfsmount. And
if it's been freed, we are well and truly fucked, race or no race.

I really want details. *Is* cleanup=5Fmnt() called by thread 1 in your reproducer before the use-after-free hits=3F And what's the root of
= thread 0 at that point=3F
--5b56bf6d_1befd79f_5b9--