Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3672101lfo; Mon, 23 May 2022 11:00:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+VV9P70JqSTf/9N06CWy3803qdspUUYuqfBE7io/wK6+5bCdIfcJSGFJGnbMEDxQhU/ni X-Received: by 2002:a17:90a:740f:b0:1df:6210:48a1 with SMTP id a15-20020a17090a740f00b001df621048a1mr175758pjg.219.1653328807203; Mon, 23 May 2022 11:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653328807; cv=none; d=google.com; s=arc-20160816; b=axeSKk+ffSVuHsjWtMLjh7CUDISgIOVMqrca7fSbvBkNLmmK9Ryi5gER+cCXv9ukle qlMvuS8mdu7TkDWHX4+T7tj+IRu+JPfAqXOeb2+YI7umcJ6slVf/1SSnpitJZ2zyE62H vLyKZZqyyNNewP6Tt+mbHJWGbcFK4n8ummQwXkSP3ia+txTVysIRfKJ4qlU2yxIdssTC fTaLIFWcuRNhXmS4zX/gei3WJz0T6ZmyXmRR053bnIxyNyA9nIFan0/KB8KKLy+7TbQ0 I+V98UAnp6rJX1K4mErUMgGHK5+djeagWb0IG21wmQ06qmbKjubQBOqCTQCNrOR5vGSe DeYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ilz8d5u1yn4tSHuAnwmWyuVqBiuF6opJF65SGDHU0Vg=; b=mdM+BdZXtBdNVRYDqiu6e/Wsy8C6V/9Tl9xNJRTliuZgKRZAMejDFW9/KPwuA4fA63 T462fEEtTBLariwf065erz1xwZh4tviyVugeDAA3CBPAtWx+az7iit4t8R3ezn5zO32b Dtcr6yogsbuw6HmlQCk4VFFGORHSXQBFtU2UYgHxe8MnS4ZyG4BoqVpIQruN84r/XYcC /iR2hm1TPxyBL9lD9QEadDWiKc9/mWjnUS/gKWmMaB7sfZSPmRzJXgBX+e0nWnovqrzz 58BueLUIzWt0qbI8Mwsduai3EzK7cD0j/FqQDZ5hv1dAHpzNvrve5YomhNmrTdUAQw8b Y/1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AkNhqtee; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w11-20020a17090abc0b00b001cb7565298csi13670677pjr.76.2022.05.23.11.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:00:07 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AkNhqtee; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6104A12817F; Mon, 23 May 2022 10:59:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242213AbiEWRye (ORCPT + 99 others); Mon, 23 May 2022 13:54:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241423AbiEWRap (ORCPT ); Mon, 23 May 2022 13:30:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46AC6007A; Mon, 23 May 2022 10:26:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 44B86611CB; Mon, 23 May 2022 17:26:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4891EC385A9; Mon, 23 May 2022 17:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326764; bh=RTDzHiDei7ULDBzcavq5W0If3VTGoCPC3qmIElAhzlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AkNhqteeaR1KBnXBWYPOey8DfU4LK7bPWJxSecSnhPjrROZzpxfi2ArCxqFPXGDFt 5kVPfimcfwvVY6fGQWavEbLUYqYc1pK3asXYkquxXAtg7ay5bGf3ljq9cgUCEHbfCU /tIQSC2OI7GkKdSNqriYhIVebIKEcWrCN0QUf4oQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Orth , Paul Moore Subject: [PATCH 5.17 051/158] audit,io_uring,io-wq: call __audit_uring_exit for dummy contexts Date: Mon, 23 May 2022 19:03:28 +0200 Message-Id: <20220523165839.183895296@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165830.581652127@linuxfoundation.org> References: <20220523165830.581652127@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julian Orth commit 69e9cd66ae1392437234a63a3a1d60b6655f92ef upstream. Not calling the function for dummy contexts will cause the context to not be reset. During the next syscall, this will cause an error in __audit_syscall_entry: WARN_ON(context->context != AUDIT_CTX_UNUSED); WARN_ON(context->name_count); if (context->context != AUDIT_CTX_UNUSED || context->name_count) { audit_panic("unrecoverable error in audit_syscall_entry()"); return; } These problematic dummy contexts are created via the following call chain: exit_to_user_mode_prepare -> arch_do_signal_or_restart -> get_signal -> task_work_run -> tctx_task_work -> io_req_task_submit -> io_issue_sqe -> audit_uring_entry Cc: stable@vger.kernel.org Fixes: 5bd2182d58e9 ("audit,io_uring,io-wq: add some basic audit support to io_uring") Signed-off-by: Julian Orth [PM: subject line tweaks] Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman --- include/linux/audit.h | 2 +- kernel/auditsc.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -339,7 +339,7 @@ static inline void audit_uring_entry(u8 } static inline void audit_uring_exit(int success, long code) { - if (unlikely(!audit_dummy_context())) + if (unlikely(audit_context())) __audit_uring_exit(success, code); } static inline void audit_syscall_entry(int major, unsigned long a0, --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -1959,6 +1959,12 @@ void __audit_uring_exit(int success, lon { struct audit_context *ctx = audit_context(); + if (ctx->dummy) { + if (ctx->context != AUDIT_CTX_URING) + return; + goto out; + } + if (ctx->context == AUDIT_CTX_SYSCALL) { /* * NOTE: See the note in __audit_uring_entry() about the case