Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp292159ybh; Mon, 20 Jul 2020 17:06:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxVTBK3VuDtYDfFpJWgHymh+nOwqFHdUcjkvsBCqydzJdfRy4puzDjpIEwEAmxysSlDVzy X-Received: by 2002:a17:906:410a:: with SMTP id j10mr23385694ejk.201.1595290007274; Mon, 20 Jul 2020 17:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595290007; cv=none; d=google.com; s=arc-20160816; b=KW3HRht6kPusroCHOcv37ianJRqDswIrmIgnFSC03qTBBPQSIy9PAIMw0HpFz0qnWI BNObEW4M1dOqA/u939RJQsbUikSdhX3Dp2seX0hQ1+YHP54pEa2LOQsGi7FrOEbH/C2O o0+TiWHdxGC8qe4DNCxaiEY3cnREQUb6HFwsKuqyOmnDpRsnU3L+QM1byjKRkUvX/55o dPyA6TI4Vs656Sisfenfi21m1JhH5bk2KWvlz+ZjK+19i0vxZoj5n1bRj6k8Y+LyH8Ud qiQi0g5LdAAdqVkc7SkWRuMu3CUCS0dzjUz6N7h5beJbLOMlgWV1rfupqOsjTTA45pUQ Zl9w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=M7ne2wNKGUVfQ0Rq3JJyzcSeIutkzaWRH6uidYm39t4=; b=ohSjISsX5eHQPaWhyHCCMvCYj78K8O7EqVOSjnCeniNqc2A6xNxZ86mK/HU0jLZzOO Dz59qokFmwH6yYHoqmexhz5aZZVik2m7uH8KrFI+QQLXyl9NhhLwBHtp+8kLKig3x7ds iKa8idsLEpdeMU+RuLdF8AuDq2fA+RPOowJN56Ud6+Km42ISWqdh8WUoRaP3BaOtpe8d gRGTgTzf9NVdEAxk85u19NUmu/EEuewXr2EOKO8RK2ex1SrPfNdATQil+NjwR0crANzP gcdBdoP5cxyWdsQEYGaCIy9/PyU9G+WVtc6zYIcovmQ/mgWfwB6n/nLk+88Ws9ZDy7lk hgXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@dancol.org header.s=x header.b=Cf9bd9kD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p23si11671967ejz.151.2020.07.20.17.06.21; Mon, 20 Jul 2020 17:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@dancol.org header.s=x header.b=Cf9bd9kD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbgGUAF3 (ORCPT + 99 others); Mon, 20 Jul 2020 20:05:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbgGUAF1 (ORCPT ); Mon, 20 Jul 2020 20:05:27 -0400 X-Greylist: delayed 1140 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 20 Jul 2020 17:05:27 PDT Received: from dancol.org (dancol.org [IPv6:2600:3c01::f03c:91ff:fedf:adf3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99E18C061794; Mon, 20 Jul 2020 17:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=M7ne2wNKGUVfQ0Rq3JJyzcSeIutkzaWRH6uidYm39t4=; b=Cf9bd9kD7v15wkq5sgFaaARD9w l+ogJcTLirmPy+sz6hVZY9VSrPOk3KqeB8fKR6CFfBqwanb1SAgwQcLszVewUHssb2ckJp5hC5GPL 7rAUYbNVVRhEsIclBaQmtdjQ4cy9xpzA7CLRX5PeSEtgmROcx1rO+Zncr4xhJNy0AtXyqoLvAwT0D vZ3QgzCD1utTm1+ctnDxX9cItabFAlzM8UKbyOMtd2BSztER8X+QMWUZTgoLRdaF8YgOOrorEK/Lh OPn6vp7jVmuczxtaA4mSE09zHR3BqXa02Bwwoc66unZ8KlhkzAAJZpt6sIZw4/Wt46F7tqFl7HVFj LKXEuaag==; Received: from [2604:4080:1321:9a00:cd6:9ee0:a66c:7274] by dancol.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jxfUC-0000tF-Re; Mon, 20 Jul 2020 16:46:20 -0700 Subject: Re: KASAN: use-after-free Read in userfaultfd_release (2) To: Al Viro , Hillf Danton Cc: syzbot , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Markus Elfring References: <0000000000001bbb6705aa49635a@google.com> <20200713084512.10416-1-hdanton@sina.com> <20200720160059.GO2786714@ZenIV.linux.org.uk> From: Daniel Colascione Message-ID: <1f69c0ab-5791-974f-8bc0-3997ab1d61ea@dancol.org> Date: Mon, 20 Jul 2020 16:46:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200720160059.GO2786714@ZenIV.linux.org.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/20/20 9:00 AM, Al Viro wrote: > On Mon, Jul 13, 2020 at 04:45:12PM +0800, Hillf Danton wrote: > >> Bridge the gap between slab free and the fput in task work wrt >> file's private data. > > No. This > >> @@ -2048,6 +2055,7 @@ SYSCALL_DEFINE1(userfaultfd, int, flags) >> >> fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC); >> if (fd < 0) { >> + file->private_data = NULL; >> fput(file); >> goto out; >> } >> > > is fundamentally wrong; you really shouldn't take over the cleanups > if you ever do fput(). Yep. I don't recall how the O_CLOEXEC got in there: that's indeed wrong, and probably the result of patch-editing butchery. As for the exit cleanup: yes, that's a bug. I was trying to keep the exit paths together. We could fix it forward (which seems simple enough) or re-submit.