Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp121706lqh; Fri, 3 May 2024 15:46:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5DT6JpUigm6L/FPvKTHJq245BBf6z/HGElXtR8EAvrT+9ZmvgntrSgWh32Jo39AeMCos8ZQl5sAwDRvsYrVF8gwE4uShMYtkbNqyssA== X-Google-Smtp-Source: AGHT+IGBXf5p8cCcpKKjy7Egk9jhZKq+eGxq7UlJKNlyXFexVFEEZhxNYMi2vtgZywftNTPPFpTT X-Received: by 2002:a05:620a:4156:b0:790:88fe:5658 with SMTP id k22-20020a05620a415600b0079088fe5658mr8854775qko.32.1714776401597; Fri, 03 May 2024 15:46:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714776401; cv=pass; d=google.com; s=arc-20160816; b=SEHMIwwxXJFRuqIBMvqsv3pByt9o2O6qAIEuUIfk1tnV5nOTcUmTQpY+pt9hmDGWcV UBpK4cP9XnEnVuMNPBLvZ3ZaqXkieJSrIUumn2fHFtH9tZ6Ra+RgpFRaZgwQ8zSKUTbR ZIXGKjZ6n7WBibSeN2MgksKfkx6Ux4xd41iVKmW44fLEcsRhv3TD38cV+VvSjxQopk+5 kobD12v6IsNASPlzvAdpekAG2HvhbpAyJR+ttfSmyxTnLVyTj9U94Q7Yu/M5bJhhXXWo qLTfvjqHcMLb+6M1L1agBmCXP3GHMEfVxw5hjNsgSsh/+RLQnrJ/mJ+1CtzwN+Sd2qcF nZDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=mDJm+G1eQTkRtzeGacfCcUIfkVf82OdjbXxPvJWkGL8=; fh=/K+BBnOO5mT1Y8JQaNicNnKArJMbhcMiEieSpV15Wt8=; b=T4nv0BwyHX3DRp9liyVD/zGaZXlDXLmQICCj79mI0b0rBAlj49pbF55QvFRxYz5X2l Omp6eotoj54dfn3YsfNLSOcuah31gMfwj+8JEXIHsQ9g6hnCc6w13gTn63e2yD0RQe7W queo4MHrL22mMlrF9GJi4oyykoiSxhGRDrhRK851XubZUXuMslItM8+tIHB1iQ5/Tywc FDj3iP6JybjnwpOI20IK+UwRQOtdsmkwA4qqjdsFqgYrtwK8NaJSYfwW7GgnZBo72X5S n85mKYMIckRFnlubNcQEwJivkHEp5pYOSDTUnBe7wPbGn9q0vAXQTI/8gt0Ekoss58ph oFjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XPZYpFfq; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-168375-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168375-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id qf4-20020a05620a660400b00789e6b10da3si2505533qkn.427.2024.05.03.15.46.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 15:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168375-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XPZYpFfq; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-168375-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168375-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 56B191C20B43 for ; Fri, 3 May 2024 22:46:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFA8C83CA2; Fri, 3 May 2024 22:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XPZYpFfq" Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D93A85BAF0 for ; Fri, 3 May 2024 22:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714776389; cv=none; b=hdk3+2IGFwybHe4FSYXj0rc729ILeH7lTXEsVPHcYXlIV2TwlCGQEoYAKj6SlFpY4xdM+Uk322uHnscdh4KZet9g8ZXdhYVwo2ApPIdlhiIC5Jfs10ERRkKLXhEDlwVkqtBnSpfKgJ3ZRuxJpJKC8tpcmbzOtawuSu7tjnHNSHQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714776389; c=relaxed/simple; bh=iOYe7kRINa7Nbtm22olG2bI2SMpe/8xXq1fjYHcE2To=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aF4NjVP8Zf0lZkRrH2i6SAdHQVqnVc/5Z9pFhyGk9fF//4scrgWs4F4pnWQgDJk46BfxRQjEhKOTM34avRw1Icm24u8fKhC23+yDYLjIDol0kPt/ztTrYD0nteChS40Ypo0/G3LrD/ZsN2SWB5E18EZ8YvfT9a+NMJMaIVV9LAw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=XPZYpFfq; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6f0aeee172dso104192b3a.1 for ; Fri, 03 May 2024 15:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714776387; x=1715381187; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mDJm+G1eQTkRtzeGacfCcUIfkVf82OdjbXxPvJWkGL8=; b=XPZYpFfqASbH92roVadM1Ux0CXeXl7kWbmWkFMukvW2trXx/AlLIeB55xooBdErhgo I6ScubhAM8iZg6HtGsLWR10szv1RWDGqto0Zmqf3txgW0w5xM3x1TwGmxaGNMFuP0MUR K54GXBCG1Uejp/NdlJJw9l6t+XUksMQzK9VBg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714776387; x=1715381187; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mDJm+G1eQTkRtzeGacfCcUIfkVf82OdjbXxPvJWkGL8=; b=iHjS2bphBTcjTPBbt++zAIuAZp5QchHVcf39FmQCTOqkqFCreZ0ewMCrDP+hD9Pp5+ Qtsq6NcbLJENsnz97Xdln0GqYgD+XCsQeAL1ZUVfp7HpvpD/mHrHYGFyszLtRhaT5hhj o6/VBXRXbrcz/6zlTuMMHiyDGt6LKeBoxUkZFWccp8Cbn9RyHQUQ+3OevD0QeqIshLfr QcROReV7h0t8guVpD4gg3Kys86XGbDN+JXR1EC/n5YzFyIwnOu3poppj+Zi/DCjiIF8E mHOpK2VyLQUNYf/22wmcwtagKmAR2YjdQ08M1RNBNe/QTaFZkoSLkG6IvEVUEk8DKbsO qWVw== X-Forwarded-Encrypted: i=1; AJvYcCVoMYxaKsK/0FjumqttRmyjkXAhBT3CEtC4csw7rb0Nl86jgdcd3B1R1GNarbxCZ+hOCD0MaimSl24FXTD1EkQ1EeXDJrUD1cuNKgAQ X-Gm-Message-State: AOJu0Yx/+he+nmw0EGyJShFDeMLfeP8QqLjIGPTBkU2/lFHr3Z7qZYa7 x1p3XR/UC+y27/dqRb/p726sCT/aYAH6my4Y27rkTEvjd/fi+ufCRbr0SGBT8A== X-Received: by 2002:aa7:88d2:0:b0:6e7:48e3:7895 with SMTP id k18-20020aa788d2000000b006e748e37895mr9433402pff.2.1714776387222; Fri, 03 May 2024 15:46:27 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id w17-20020aa79a11000000b006f4476e078dsm2406826pfj.192.2024.05.03.15.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 15:46:26 -0700 (PDT) Date: Fri, 3 May 2024 15:46:25 -0700 From: Kees Cook To: Linus Torvalds Cc: Al Viro , axboe@kernel.dk, brauner@kernel.org, christian.koenig@amd.com, dri-devel@lists.freedesktop.org, io-uring@vger.kernel.org, jack@suse.cz, laura@labbott.name, linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, minhquangbui99@gmail.com, sumit.semwal@linaro.org, syzbot+045b454ab35fd82a35fb@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com Subject: Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes Message-ID: <202405031529.2CD1BFED37@keescook> References: <202405031110.6F47982593@keescook> <20240503211129.679762-2-torvalds@linux-foundation.org> <20240503212428.GY2118490@ZenIV> <20240503214531.GB2118490@ZenIV> 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: On Fri, May 03, 2024 at 02:52:38PM -0700, Linus Torvalds wrote: > That means that the file will be released - and it means that you have > violated all the refcounting rules for poll(). I feel like I've been looking at this too long. I think I see another problem here, but with dmabuf even when epoll is fixed: dma_buf_poll() get_file(dmabuf->file) /* f_count + 1 */ dma_buf_poll_add_cb() dma_resv_for_each_fence ... dma_fence_add_callback(fence, ..., dma_buf_poll_cb) dma_buf_poll_cb() ... fput(dmabuf->file); /* f_count - 1 ... for each fence */ Isn't it possible to call dma_buf_poll_cb() (and therefore fput()) multiple times if there is more than 1 fence? Perhaps I've missed a place where a single struct dma_resv will only ever signal 1 fence? But looking through dma_fence_signal_timestamp_locked(), I don't see anything about resv nor somehow looking into other fence cb_list contents... -- Kees Cook