From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 AEF4AC63777 for ; Mon, 30 Nov 2020 22:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5960420725 for ; Mon, 30 Nov 2020 22:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388913AbgK3W76 (ORCPT ); Mon, 30 Nov 2020 17:59:58 -0500 Received: from out02.mta.xmission.com ([166.70.13.232]:40542 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727125AbgK3W76 (ORCPT ); Mon, 30 Nov 2020 17:59:58 -0500 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kjs8Z-001bqu-Ue; Mon, 30 Nov 2020 15:59:15 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1kjs8Z-0008Jw-B6; Mon, 30 Nov 2020 15:59:15 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Cc: Linus Torvalds , Oleg Nesterov , Al Viro , Kees Cook , Jens Axboe Date: Mon, 30 Nov 2020 16:58:46 -0600 Message-ID: <878saih2op.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1kjs8Z-0008Jw-B6;;;mid=<878saih2op.fsf@x220.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19Y6q1ezVHxrrwTupDQXlbLEG2XON0U6dQ= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [PATCH] exec: Move io_uring_task_cancel after the point of no return X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that unshare_files happens in begin_new_exec after the point of no return, io_uring_task_cancel can also happen later. Effectively this means io_uring activities for a task are only canceled when exec succeeds. Signed-off-by: Eric W. Biederman --- This is against my exec-for-v5.11 branch fs/exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 14fae2ec1c9d..9e9368603168 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1257,6 +1257,11 @@ int begin_new_exec(struct linux_binprm * bprm) if (retval) goto out; + /* + * Cancel any io_uring activity across execve + */ + io_uring_task_cancel(); + /* Ensure the files table is not shared. */ retval = unshare_files(); if (retval) @@ -1783,11 +1788,6 @@ static int bprm_execve(struct linux_binprm *bprm, struct file *file; int retval; - /* - * Cancel any io_uring activity across execve - */ - io_uring_task_cancel(); - retval = prepare_bprm_creds(bprm); if (retval) return retval; -- 2.20.1