Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3932750rwa; Tue, 23 Aug 2022 12:49:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR7mDaD4i8wfCf/cEl7Zv5jtR4Nr6p5CsVvrZvzKu8wJ5XbU/z3xcOYHnI62q0tRQ1XO2655 X-Received: by 2002:a17:90b:1c8e:b0:1f7:524f:bfcc with SMTP id oo14-20020a17090b1c8e00b001f7524fbfccmr4719340pjb.132.1661284149849; Tue, 23 Aug 2022 12:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661284149; cv=none; d=google.com; s=arc-20160816; b=Jdd7JjNNHZ/fJBZTGjsFcJM4EVCSJmw9zHwnOhomNUIAr11HP02+bOh87auzPX73PR Kglkf7/3bCr/kxuACVNrYclw7cHxm98uImA9IqldoTl05x5xQzakIWlqUOhGMY74o0D5 bFfwYawKFeNtoSezy6VnuTBU47xPa12Hf7n7QD9Qj8gBAcdrRRZY9oe4TDHIkaI5Jslq yHzQ1jTfOPng/5GrJdohAr2qJMtKnpk79OlvpknC8oWq+RHz0Hv0AJ5KTJBti6GejP6t Zfjy7fWFohy9sOyLBEbh3HHQgF7TOt+G62g4c4ToKz4rAKlQualbU0tirMgXWckrMITs hK/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=vYvZfyu3JCgIJ6ksQzBD+OS0lAba1p3hUHWdV+56vKA=; b=jp9qNHH4c9u9xfxUh0JNvGxLavThe70pEfmSYmanVNzGMhEfZvj1ouyk15V8Vwjfau n4bg8c29C5/EHxdM1VPbR5UJ+Ehkf4Pv868AwMpR8eIzIQpBlORLMwo9wEnnNNg5YasG QEEbnU9uAiwgsl3HnZtgfb+frcQFAUS063Xl82LUr12CyIl1aL3kyXFUmKUBx7VWE8ft KzPSNgO6ftIG/hh0zl+4gUy9xGN+ak9VcADg13uzS6KeBdMTmGplVH6yqvvE/L+Dwn8G 2+cZhQ+hvho6pQWsvJIZZhunBjvzWlAVRa1pC+PhyGoQXgc4EV0b8KjB0BLtptDgvgoR GImQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t37-20020a634465000000b0041beb6e9d14si8836838pgk.525.2022.08.23.12.48.58; Tue, 23 Aug 2022 12:49:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231534AbiHWTcU (ORCPT + 99 others); Tue, 23 Aug 2022 15:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbiHWTby (ORCPT ); Tue, 23 Aug 2022 15:31:54 -0400 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 817F9BF68; Tue, 23 Aug 2022 11:23:23 -0700 (PDT) Received: from in01.mta.xmission.com ([166.70.13.51]:60738) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1oQYYb-0041Dr-Vo; Tue, 23 Aug 2022 12:23:22 -0600 Received: from ip68-110-29-46.om.om.cox.net ([68.110.29.46]:37014 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1oQYYa-00GUYx-1U; Tue, 23 Aug 2022 12:23:21 -0600 From: "Eric W. Biederman" To: Olivier Langlois Cc: Jens Axboe , Pavel Begunkov , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Alexander Viro , Oleg Nesterov , Linus Torvalds References: <192c9697e379bf084636a8213108be6c3b948d0b.camel@trillion01.com> <9692dbb420eef43a9775f425cb8f6f33c9ba2db9.camel@trillion01.com> <87h7i694ij.fsf_-_@disp2133> <1b519092-2ebf-3800-306d-c354c24a9ad1@gmail.com> <13250a8d-1a59-4b7b-92e4-1231d73cbdda@gmail.com> <878rw9u6fb.fsf@email.froward.int.ebiederm.org> <303f7772-eb31-5beb-2bd0-4278566591b0@gmail.com> <87ilsg13yz.fsf@email.froward.int.ebiederm.org> <8218f1a245d054c940e25142fd00a5f17238d078.camel@trillion01.com> <87y1wnrap0.fsf_-_@email.froward.int.ebiederm.org> <87mtd3rals.fsf_-_@email.froward.int.ebiederm.org> <61abfb5a517e0ee253b0dc7ba9cd32ebd558bcb0.camel@trillion01.com> Date: Tue, 23 Aug 2022 13:22:53 -0500 In-Reply-To: (Olivier Langlois's message of "Mon, 22 Aug 2022 23:35:37 -0400") Message-ID: <875yiisttu.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1oQYYa-00GUYx-1U;;;mid=<875yiisttu.fsf@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.110.29.46;;;frm=ebiederm@xmission.com;;;spf=softfail X-XM-AID: U2FsdGVkX1/GeEI4Y8IQexfRUNq3YWki9SJ3OxiLRg4= X-SA-Exim-Connect-IP: 68.110.29.46 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *****;Olivier Langlois X-Spam-Relay-Country: X-Spam-Timing: total 1387 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 11 (0.8%), b_tie_ro: 10 (0.7%), parse: 0.86 (0.1%), extract_message_metadata: 11 (0.8%), get_uri_detail_list: 1.19 (0.1%), tests_pri_-1000: 9 (0.6%), tests_pri_-950: 1.18 (0.1%), tests_pri_-900: 0.96 (0.1%), tests_pri_-90: 72 (5.2%), check_bayes: 70 (5.1%), b_tokenize: 6 (0.4%), b_tok_get_all: 6 (0.4%), b_comp_prob: 2.0 (0.1%), b_tok_touch_all: 53 (3.8%), b_finish: 0.79 (0.1%), tests_pri_0: 1254 (90.4%), check_dkim_signature: 0.50 (0.0%), check_dkim_adsp: 2.7 (0.2%), poll_dns_idle: 0.42 (0.0%), tests_pri_10: 2.3 (0.2%), tests_pri_500: 21 (1.5%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 2/2] coredump: Allow coredumps to pipes to work with io_uring X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Olivier Langlois writes: > On Mon, 2022-08-22 at 17:16 -0400, Olivier Langlois wrote: >> >> What is stopping the task calling do_coredump() to be interrupted and >> call task_work_add() from the interrupt context? >> >> This is precisely what I was experiencing last summer when I did work >> on this issue. >> >> My understanding of how async I/O works with io_uring is that the >> task >> is added to a wait queue without being put to sleep and when the >> io_uring callback is called from the interrupt context, >> task_work_add() >> is called so that the next time io_uring syscall is invoked, pending >> work is processed to complete the I/O. >> >> So if: >> >> 1. io_uring request is initiated AND the task is in a wait queue >> 2. do_coredump() is called before the I/O is completed >> >> IMHO, this is how you end up having task_work_add() called while the >> coredump is generated. >> > I forgot to add that I have experienced the issue with TCP/IP I/O. > > I suspect that with a TCP socket, the race condition window is much > larger than if it was disk I/O and this might make it easier to > reproduce the issue this way... I was under the apparently mistaken impression that the io_uring task_work_add only comes from the io_uring userspace helper threads. Those are definitely suppressed by my change. Do you have any idea in the code where io_uring code is being called in an interrupt context? I would really like to trace that code path so I have a better grasp on what is happening. If task_work_add is being called from interrupt context then something additional from what I have proposed certainly needs to be done. Eric