Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp115140lqh; Fri, 3 May 2024 15:28:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW3biY9RJCflW3qjTzdylCAM0q1RWCOkxd2H61GjN1LywrgGLLdC9U4kQxnLYNm+OCM/JBHPqMzG/75IUUErmnr4j2XNu4hwLyDxZiBxg== X-Google-Smtp-Source: AGHT+IHAf35TKGJ4YdeuQ0gWWR3yn2fi7bvCBlX+cm3vbd5VlCH4HLwZ+NQM8t2LWFUOwoL5Pz76 X-Received: by 2002:a05:6a20:9f9a:b0:1aa:43f4:3562 with SMTP id mm26-20020a056a209f9a00b001aa43f43562mr4387464pzb.11.1714775312912; Fri, 03 May 2024 15:28:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714775312; cv=pass; d=google.com; s=arc-20160816; b=YAdQ03OpmLwgQCHU/6oYmsqLAXG8bWht/eO1E/icPWflV8Mu6mDL6Top1Vi9vjdgLz 6OeCh80pjr8fOqvUPwYgFxDEggG56eQeOZ2OvDOKFsXWQljD+YkRTkQCemTMWwXxDitJ f1F90shfVYx16imhYfIFqROMXu2+mUb0qTGHA7ZHelvxTwVOmF/QO83gqWbB+7mVKcia H4HlihztMajz8FzFHV3w7QCluFWdytx4HSR6pSayXZTezG3jUTKFP6hw/Cjgm1wZ6oZT 64va9xANvxtBP2wNPyjF9GH4vVhuPX1RYQ8zmM/W446UNSFN00JcQ413CkA20qFcXeUi DG3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=NY7dpnWNXhQQKVFdAJPJlG4e4ZXMaDmQRQbDTVWLCeE=; fh=rEts7UgNYtWz403W+vmSPny6GL+pnJ5XQI/osiz88eI=; b=LYXEAVseyauaAvf05u06WEK3+ZbkOyzXpe0HIOMLcBUo6U9evIOp0FAO5AZncaeehz iJjmBOs5f7Gz1+rKbclvixz+p3a1uYZbmnKyWR2sbpXyuEgYLSJMas71L+V7QApfclFI Ubq4umXkWYKgGwYrggICd8ZQZug+zzA6jdZzu4rCpO0hKbxLYpym/YGeaMdLiHCvaCo7 6KaJ3vpsUuhmCwC1HYIEUe1kChxoHZHY1Xa84zbPOfMc5tKMu9sKPg0IqJy2VDzhv/sm 6892Jpf2GFKBQwjTaamSzaQx0YO417O5i4QTubEMXMwNjlXtbBTiq+XeORVasSYD2CfW g2QA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=Rs9B3xI+; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-168218-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i5-20020a6551c5000000b006206235950dsi340096pgq.186.2024.05.03.15.28.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 15:28:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168218-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=Rs9B3xI+; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-168218-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9EB632850DB for ; Fri, 3 May 2024 21:12:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5326745D9; Fri, 3 May 2024 21:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="Rs9B3xI+" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43A5341746; Fri, 3 May 2024 21:11:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770681; cv=none; b=hYSoo5VppYtLtSnFe0b5JYEbsOzi0YpdGota5peXEnsoDee0BS1ARUTrZiBPWGxI2CAIEUrdYkP1MtNlg2hH6Ttmu/DoSRsXA2fXwd2AOoAnQlLzCyACIXvoExA1gNjEfQhW1XPB/ifd2Yt9vBn1kRcEsVfVxD9Q1h0Ch44Jc9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770681; c=relaxed/simple; bh=ir4jVAwHqZZPJB/DE9uWzxgHlCj8HSje/nWd9XFDyhY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=l/2br5Z+mvgfi+nJgRC8/+n6F3fzgUJOBSVgagc1/SC0AhUuP7gHGeDjW9TIl2OIDUyIiRxx0owzJdTEJStOCyyJfkif54BA5xaxAZEUYiR/mHnQIX4lzzd52/Pb4IjuylT4lfppqkvE5IcmymX6ciw3G/lDMf+tlQRnqe/0/dA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=Rs9B3xI+; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NY7dpnWNXhQQKVFdAJPJlG4e4ZXMaDmQRQbDTVWLCeE=; b=Rs9B3xI+XdmJK5vPYQK8J22QKS EgQQjCflBDYUtxW7SIX67RGaVIh3sQxNGH90bxispPeYAm3Rch22e5sDAaxhSEmNW2ySJllWffdb5 a4oV0hJkK1wMLB0wsYYYxmpIJp7sPoevLWMdPWdjnwETEp1S5NfsIj1h0wJX1d3jNqehubjWUYPn+ 7uDmwbVMNILcV4WyvLYqHObXMuav53kC37sidi15Uw1VLUrj5+Sngx5+0djz5feXF5HjHfmThe2Wn SpKgjexjGpBfd+US1tn2T08npPs/aGPCeX21rEsxXS0Wot3Ugzg/2Yns9RIFdjTU5nMXuJMK+yyG7 QAAoXHQQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1s30BR-00B72n-1X; Fri, 03 May 2024 21:11:09 +0000 Date: Fri, 3 May 2024 22:11:09 +0100 From: Al Viro To: Kees Cook Cc: Jens Axboe , Bui Quang Minh , Christian Brauner , syzbot , io-uring@vger.kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Laura Abbott , Linus Torvalds Subject: Re: get_file() unsafe under epoll (was Re: [syzbot] [fs?] [io-uring?] general protection fault in __ep_remove) Message-ID: <20240503211109.GX2118490@ZenIV> References: <0000000000002d631f0615918f1e@google.com> <7c41cf3c-2a71-4dbb-8f34-0337890906fc@gmail.com> <202405031110.6F47982593@keescook> <64b51cc5-9f5b-4160-83f2-6d62175418a2@kernel.dk> <202405031207.9D62DA4973@keescook> <202405031237.B6B8379@keescook> <202405031325.B8979870B@keescook> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202405031325.B8979870B@keescook> Sender: Al Viro On Fri, May 03, 2024 at 01:28:37PM -0700, Kees Cook wrote: > > Is this the right approach? It still feels to me like get_file() needs > to happen much earlier... I don't believe it needs to happen at all. The problem is not that ->release() can be called during ->poll() - it can't and it doesn't. It's that this instance of ->poll() is trying to extend the lifetime of that struct file, when it might very well be past the point of no return. What we need is * promise that ep_item_poll() won't happen after eventpoll_release_file(). AFAICS, we do have that. * ->poll() not playing silly buggers. As it is, dma_buf ->poll() is very suspicious regardless of that mess - it can grab reference to file for unspecified interval. Have that happen shortly before reboot and you are asking for failing umount. ->poll() must be refcount-neutral wrt file passed to it. I'm seriously tempted to make ->poll() take const struct file * and see if there's anything else that would fall out.