Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5103329pxb; Wed, 19 Jan 2022 11:05:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhUIjf1HWKjsRJZL0tNSoLTc9E5YFdlKmTHxsW+lzCQBlf032XYs/UKPjjlWP7ExpAwL4u X-Received: by 2002:a63:88c2:: with SMTP id l185mr28066206pgd.340.1642619106177; Wed, 19 Jan 2022 11:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642619106; cv=none; d=google.com; s=arc-20160816; b=JiWn69RVjk0+L4oCR/R+h3j+rG/LAoBl2G+bQM+QTINTTCpvh86ChP1+E00/a3yWLy +z7FQUfocCD7+e6AP2pl5NQkwwza4oJGzHjlZ5/OYOiknqeDBTvdG75PFu7p1TtW0NON mqC2SY60f3Mxc78iPvLEn4wMJGfIjWgIXd/CAyxUoG6mWvmuc88yPfhE3ghIu68JCWgo p058hajv4xFSTbsHVL0s38siKJjt2ZhM30urU6qdaVgt8z6KBGiBGOeQmV9LJqEYMih1 Dt8OpqG9AiKTHQTsNCisXkwugWV3qvRYWw/691VzosOBwTMLzhXTcRDms1gVe6DodiA3 4NsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/zF5YGbP0nEkT+Uha6r3jtWZKXjZYuO+eTPXU/yYfOc=; b=d5CGdcMTgGaVlyvnTfJqFd4iWzjoR5sDz2nBIO0183DcHc2E1+ve44moSYm4xDCL1p 2edQTldcUczBHcAPPBAy9tZQizkKz41HVU5Tx/sGedRwWDNV/7IMihuVKc9yHu2hmWEm Ih+b4YLg+y/uh5+9v5gsTpA6vL2lPN9Yslzg98d+8BAR4Rdp90+EXHZYKvTQ4onyB3hi XUIrq8anqu5iBWUN8eHrZsnSt4CM6Z+Y28JIJ+fKP8XSB7fglzY2v+5t7BK/9vu41HYB I17IqZBkqv11pO0i0aGV+NUh89Www5SSt/mOF3+uuWdQ3nyPeE4VTSD7Eg/sGWhz4GI2 06MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=XlkT9EJX; 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 i10si593054plr.231.2022.01.19.11.04.53; Wed, 19 Jan 2022 11:05:06 -0800 (PST) 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=pass header.i=@linux-foundation.org header.s=google header.b=XlkT9EJX; 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 S232256AbiAREYN (ORCPT + 99 others); Mon, 17 Jan 2022 23:24:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232224AbiAREYM (ORCPT ); Mon, 17 Jan 2022 23:24:12 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE9D4C061574 for ; Mon, 17 Jan 2022 20:24:11 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id a18so74171925edj.7 for ; Mon, 17 Jan 2022 20:24:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/zF5YGbP0nEkT+Uha6r3jtWZKXjZYuO+eTPXU/yYfOc=; b=XlkT9EJX4wkAEbbjts/SRs/Oca3s7hNnc/YxVUdn5XXezzzfWLPOgcdIg2Eih08gC6 iyP5Xy26dc+EWHtnjXbLEbLbvuWerIEEl8qJ3kEwiW5OjDVPByTmajKydrPBjcTLLzF6 EJIKzzZfM0pAGb4rz0nfHJ7VtKgcCae7zrXTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/zF5YGbP0nEkT+Uha6r3jtWZKXjZYuO+eTPXU/yYfOc=; b=xlEAv3L3yd76EhBSZJPkStCIkuoxMER+zUOyLlI9O4IlWk4Kwj+BTycQgzw3sin/Ui JsJo7AOzz0l7ATCAY/5lVuKMEncxIKdZd9U7OBOFPiH3DxCoZSiFRVEnMMD5C4SchAjF ggKAweQ2Hffhjlb2KxL+Pxfi+BPACbpNq1XwvzlQIyfu2dwpCDLa1yfD2l9KMIyP/dox 2KtgctdCVJzLf4atwrGZeHvjrYAKOvdMgqml/+M4bS7w078ZdC6bScUkgehtdUh7ojU3 A5oDt0oUTfydwUvPwW71NZ0WpRFX2vXsDtaDZW9tdBd7wOOHeXZx2RNY7qsna1s5Bqu2 vfOw== X-Gm-Message-State: AOAM531xSPqFsptHskEVtKXA/PqzVmYWrmV3XHnfW173GRAw91UB2LOp qVY/Z0c9GbA3Wdzz4L4Mv2rNti8M+nOgKk1x X-Received: by 2002:aa7:c917:: with SMTP id b23mr8290869edt.309.1642479850232; Mon, 17 Jan 2022 20:24:10 -0800 (PST) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com. [209.85.128.49]) by smtp.gmail.com with ESMTPSA id gt38sm4981197ejc.114.2022.01.17.20.24.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jan 2022 20:24:08 -0800 (PST) Received: by mail-wm1-f49.google.com with SMTP id v123so24871013wme.2 for ; Mon, 17 Jan 2022 20:24:07 -0800 (PST) X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr8150004wrg.281.1642479847518; Mon, 17 Jan 2022 20:24:07 -0800 (PST) MIME-Version: 1.0 References: <87a6ha4zsd.fsf@email.froward.int.ebiederm.org> <20211213225350.27481-1-ebiederm@xmission.com> <87sfu3b7wm.fsf@email.froward.int.ebiederm.org> <87ilurwjju.fsf@email.froward.int.ebiederm.org> <87o84juwhg.fsf@email.froward.int.ebiederm.org> <57dfc87c7dd5a2f9f9841bba1185336016595ef7.camel@trillion01.com> <87lezmrxlq.fsf@email.froward.int.ebiederm.org> <87mtk2qf5s.fsf@email.froward.int.ebiederm.org> <87h7a5kgan.fsf@email.froward.int.ebiederm.org> <991211d94c6dc0ad3501cd9f830cdee916b982b3.camel@trillion01.com> <87ee56e43r.fsf@email.froward.int.ebiederm.org> <87v8yi8ajr.fsf_-_@email.froward.int.ebiederm.org> In-Reply-To: <87v8yi8ajr.fsf_-_@email.froward.int.ebiederm.org> From: Linus Torvalds Date: Tue, 18 Jan 2022 06:23:51 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: io_uring truncating coredumps To: "Eric W. Biederman" Cc: Olivier Langlois , Heiko Carstens , Linux Kernel Mailing List , "" , Linux API , Alexey Gladkov , Kyle Huey , Oleg Nesterov , Kees Cook , Al Viro , Jens Axboe , Pavel Begunkov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 17, 2022 at 8:47 PM Eric W. Biederman wrote: > > Thinking about it from the perspective of not delivering the wake-ups > fixing io_uring and coredumps in a non-hacky way looks comparatively > simple. The function task_work_add just needs to not wake anything up > after a process has started dying. > > Something like the patch below. Hmm. Yes, I think this is the right direction. That said, I think it should not add the work at all, and return -ESRCH, the exact same way that it does for that work_exited condition. Because it's basically the same thing: the task is dead and shouldn't do more work. In fact, task_work_run() is the thing that sets it to &work_exited as it sees PF_EXITING, so it feels to me that THAT is actually the issue here - we react to PF_EXITING too late. We react to it *after* we've already added the work, and then we do that "no more work" logic only after we've accepted those late work entries? So my gut feel is that task_work_add() should just also test PF_EXITING. And in fact, my gut feel is that PF_EXITING is too late anyway (it happens after core-dumping, no?) But I guess that thing may be on purpose, and maybe the act of dumping core itself wants to do more work, and so that isn't an option? So I don't think your patch is "right" as-is, and it all worries me, but yes, I think this area is very much the questionable one. I think that work stopping and the io_uring shutdown should probably move earlier in the exit queue, but as mentioned above, maybe the work addition boundary in particular really wants to be late because the exit process itself still uses task works? ;( Linus