From patchwork Sun Aug 22 21:05:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Langlois X-Patchwork-Id: 12451691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD0F3C432BE for ; Sun, 22 Aug 2021 21:05:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D19761051 for ; Sun, 22 Aug 2021 21:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232989AbhHVVG3 (ORCPT ); Sun, 22 Aug 2021 17:06:29 -0400 Received: from cloud48395.mywhc.ca ([173.209.37.211]:36020 "EHLO cloud48395.mywhc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232539AbhHVVG3 (ORCPT ); Sun, 22 Aug 2021 17:06:29 -0400 Received: from modemcable064.203-130-66.mc.videotron.ca ([66.130.203.64]:52706 helo=localhost) by cloud48395.mywhc.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mHuf4-0001qj-4c; Sun, 22 Aug 2021 17:05:46 -0400 Date: Sun, 22 Aug 2021 17:05:44 -0400 Message-Id: From: Olivier Langlois To: Jens Axboe , Pavel Begunkov , Oleg Nesterov , Steven Rostedt , Ingo Molnar , "Eric W. Biederman" , io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] coredump: io_uring: Cancel io_uring to avoid core truncation X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud48395.mywhc.ca X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - trillion01.com X-Get-Message-Sender-Via: cloud48395.mywhc.ca: authenticated_id: olivier@trillion01.com X-Authenticated-Sender: cloud48395.mywhc.ca: olivier@trillion01.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Before writing the core dump, io_uring requests have to be cancelled. Also, io_uring cancellation code had to be modified as it could set the TIF_NOTIFY_SIGNAL bit. Few notes about this patchset: 1. My coredump.c proposal puts the io_uring_task_cancel call further down the do_coredump function over what Jens did propose. Considering that this function call can be relatively expensive, I believe that postponing it as much as possible is the way to go. I did place it before coredump_wait which clears signal bits so that seems to be an appropriate location but the logic could possibly be pushed even more with possibly no harm. 2. The current patch proposal only address specifically the issue caused by io_uring. It could reoccur as soon as something else flips the TIF_NOTIFY_SIGNAL bit. Therefore, another solution would simply be to modify __dump_emit to make it resilient to TIF_NOTIFY_SIGNAL as Eric W. Biederman originally suggested. or maybe do both... So making __dump_emit more robust to the TIF_NOTIFY_SIGNAL situation might be something interesting to investigate if it would be a good idea to do on top or in replacement to this patchset. Lastly, Jens did already submit a patch to solve the same problem: https://lkml.org/lkml/2021/8/17/1156 If his patch ends being a superior solution to the problem, the first 2 patches of this set are still relevant. Olivier Langlois (3): tracehook: Add a return value to tracehook_notify_signal io_uring: Clear TIF_NOTIFY_SIGNAL when cancelling requests coredump: cancel io_uring requests before dumping core fs/coredump.c | 3 +++ fs/io_uring.c | 2 +- include/linux/tracehook.h | 8 ++++++-- 3 files changed, 10 insertions(+), 3 deletions(-)