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=-4.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 8A6E1C47098 for ; Thu, 3 Jun 2021 10:40:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 692206101B for ; Thu, 3 Jun 2021 10:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229958AbhFCKmV (ORCPT ); Thu, 3 Jun 2021 06:42:21 -0400 Received: from mail-ej1-f52.google.com ([209.85.218.52]:41958 "EHLO mail-ej1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhFCKmU (ORCPT ); Thu, 3 Jun 2021 06:42:20 -0400 Received: by mail-ej1-f52.google.com with SMTP id gb17so8491603ejc.8; Thu, 03 Jun 2021 03:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jjgngqqiD1MzF4drjDhfJO81FwwmSm8rHRAQDoLI4hk=; b=i5zdCu7eh+exc3xVtGwn/14tE99F9S6SruDvOQWgTazyiiWQej8zLeVr2UmL4UvcE4 feRfK8yNI/0EVqCRgzt4FDrXsFhXitU/G5Kr7vmnJy2h8CxxTlQ/mY4WUjlcrqgE0epg 0GrCkvW1TMNs5xoY5poEBZlfW50G0Ay6IkEFxzGZzaibL52u8IlG09QzmHMajSdAg+dH zzEnJcXMVB6R+FW3kgS0AYEoJyv8HlB6kTD/1F/5+vqfFNTH4qS80g7stAYowIr7O4i6 Ir6CJRD/7o6g7jZ9q+1XbuPqThLD+ES/asQm7haHvhoahEOgULrRGaITDwkKWtLHhB2y fFrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jjgngqqiD1MzF4drjDhfJO81FwwmSm8rHRAQDoLI4hk=; b=KF7M7MHyQ72Lgsz9h4BAaNPN7OqToOkulRHxtxfp6wxNzBKAsPyW4GcuUud2Lr/dUs DTX94thpJ1fQvGaWS+xKkh2Nb7xR0NTQCmTx0US4mNQZ0Xe5rhRy0pw+9jwYEDRj5P2F CXJ2rSCW4azglrH+G9IQB9nu0t67oiVDv995b/5g9IIlIqwi0QNOC2oPTEQVxWcOIaJW R/rPNDmdotlHCM+J5398FYhnUdLDypfuav1YuvkYB/Ae21I6X/V0vktryn4cOz3IPi/S NndfA/9vm3qSRMlkqqbLctn6yRF+iMrWauRHQsSeOgaDYCmzG7U7uvAqpy5EJjrV/o7y 5aTw== X-Gm-Message-State: AOAM533SluP/l9klCIlVrqwU3ZB8/dultsiXwI7T45BbgRUE0W3YIKUK uuLwYL+T6J4+E1xtJSZd6xU= X-Google-Smtp-Source: ABdhPJxBNyhzAnY+FdObN7pnTAta+DGpnvQFV2i3L7an+ohCIQSKtw/KtDZc/3aOtErcO8sTHGd/6Q== X-Received: by 2002:a17:906:af7b:: with SMTP id os27mr23608805ejb.154.1622716761257; Thu, 03 Jun 2021 03:39:21 -0700 (PDT) Received: from ?IPv6:2620:10d:c096:310::2410? ([2620:10d:c093:600::2:6c45]) by smtp.gmail.com with ESMTPSA id s2sm1565455edu.89.2021.06.03.03.39.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 03:39:20 -0700 (PDT) To: Richard Guy Briggs Cc: Paul Moore , Jens Axboe , selinux@vger.kernel.org, linux-security-module@vger.kernel.org, linux-audit@redhat.com, Kumar Kartikeya Dwivedi , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Alexander Viro References: <9e69e4b6-2b87-a688-d604-c7f70be894f5@kernel.dk> <3bef7c8a-ee70-d91d-74db-367ad0137d00@kernel.dk> <94e50554-f71a-50ab-c468-418863d2b46f@gmail.com> <20210602154638.GA3711857@madcap2.tricolour.ca> From: Pavel Begunkov Subject: Re: [RFC PATCH 2/9] audit,io_uring,io-wq: add some basic audit support to io_uring Message-ID: Date: Thu, 3 Jun 2021 11:39:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210602154638.GA3711857@madcap2.tricolour.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On 6/2/21 4:46 PM, Richard Guy Briggs wrote: > On 2021-06-02 09:26, Pavel Begunkov wrote: >> On 5/28/21 5:02 PM, Paul Moore wrote: >>> On Wed, May 26, 2021 at 4:19 PM Paul Moore wrote: >>>> ... If we moved the _entry >>>> and _exit calls into the individual operation case blocks (quick >>>> openat example below) so that only certain operations were able to be >>>> audited would that be acceptable assuming the high frequency ops were >>>> untouched? My initial gut feeling was that this would involve >50% of >>>> the ops, but Steve Grubb seems to think it would be less; it may be >>>> time to look at that a bit more seriously, but if it gets a NACK >>>> regardless it isn't worth the time - thoughts? >>>> >>>> case IORING_OP_OPENAT: >>>> audit_uring_entry(req->opcode); >>>> ret = io_openat(req, issue_flags); >>>> audit_uring_exit(!ret, ret); >>>> break; >>> >>> I wanted to pose this question again in case it was lost in the >>> thread, I suspect this may be the last option before we have to "fix" >>> things at the Kconfig level. I definitely don't want to have to go >>> that route, and I suspect most everyone on this thread feels the same, >>> so I'm hopeful we can find a solution that is begrudgingly acceptable >>> to both groups. >> >> May work for me, but have to ask how many, and what is the >> criteria? I'd think anything opening a file or manipulating fs: >> >> IORING_OP_ACCEPT, IORING_OP_CONNECT, IORING_OP_OPENAT[2], >> IORING_OP_RENAMEAT, IORING_OP_UNLINKAT, IORING_OP_SHUTDOWN, >> IORING_OP_FILES_UPDATE >> + coming mkdirat and others. >> >> IORING_OP_CLOSE? IORING_OP_SEND IORING_OP_RECV? >> >> What about? >> IORING_OP_FSYNC, IORING_OP_SYNC_FILE_RANGE, >> IORING_OP_FALLOCATE, IORING_OP_STATX, >> IORING_OP_FADVISE, IORING_OP_MADVISE, >> IORING_OP_EPOLL_CTL >> >> >> Another question, io_uring may exercise asynchronous paths, >> i.e. io_issue_sqe() returns before requests completes. >> Shouldn't be the case for open/etc at the moment, but was that >> considered? > > This would be why audit needs to monitor a thread until it wraps up, to > wait for the result code. My understanding is that both sync and async > parts of an op would be monitored. There may be a misunderstanding audit_start(req) ret = io_issue_sqe(req); audit_end(ret); io_issue_sqe() may return 0 but leave the request inflight, which will be completed asynchronously e.g. by IRQ, not going through io_issue_sqe() or any io_read()/etc helpers again, and after last audit_end() had already happened. That's the case with read/write/timeout, but is not true for open/etc. >> I don't see it happening, but would prefer to keep it open >> async reimplementation in a distant future. Does audit sleep? > > Some parts do, some parts don't depending on what they are interacting > with in the kernel. It can be made to not sleep if needed. Ok, good -- Pavel Begunkov 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=-2.9 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 3A0ACC47096 for ; Thu, 3 Jun 2021 13:09:53 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD64B613B8 for ; Thu, 3 Jun 2021 13:09:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD64B613B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=linux-audit-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-284-ENmYmn7mMMCjbSxFXkWGMA-1; Thu, 03 Jun 2021 09:09:50 -0400 X-MC-Unique: ENmYmn7mMMCjbSxFXkWGMA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A34E7180FD67; Thu, 3 Jun 2021 13:09:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF79B60C17; Thu, 3 Jun 2021 13:09:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4D5E54BB40; Thu, 3 Jun 2021 13:09:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 153AdRb6006468 for ; Thu, 3 Jun 2021 06:39:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id EED3921F1B06; Thu, 3 Jun 2021 10:39:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9E8A21F1B05 for ; Thu, 3 Jun 2021 10:39:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AE830805F45 for ; Thu, 3 Jun 2021 10:39:24 +0000 (UTC) Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-3tlRNs04N5OsOTaiqt2Zzw-1; Thu, 03 Jun 2021 06:39:22 -0400 X-MC-Unique: 3tlRNs04N5OsOTaiqt2Zzw-1 Received: by mail-ej1-f43.google.com with SMTP id c10so8455598eja.11; Thu, 03 Jun 2021 03:39:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jjgngqqiD1MzF4drjDhfJO81FwwmSm8rHRAQDoLI4hk=; b=fzGFEuYn6Hgn28+X3BxCGX146vY4XuZwXAuUxtt3RLrLBgiFryu2xYWPdoEk+dyfjh xgXZozsOVzTemeXvAOrJAmLX8+NxRYxR6KN6wynOixpg2Jjqcj6mYA8PvXEYua+1Oz9o i9/05osZwZqnzYf0WO9BVsWjypyyAp0xNX4upDbaepsunYLuGiqEKzOSGaDVPr+mm6b2 kYH/06zcH5ZckvY5rsVvMUMYId3X9Qub/L2dQQyiNINlM4+VjI74NccTe+nRP/XdRUKi +CI49/Qcx2XZBa4g/fMkAKirUQQdOWP9SqtqoqnabNvjwKcRyZQ/9bBG/D9JtxZ0s1GE 0DfQ== X-Gm-Message-State: AOAM530YmjN/slrZlFPLVw0OotNAI6ejMUEe51HsicZG3L91FJIQhjLs CxyeFdP6k96/eReL3xgSyIo= X-Google-Smtp-Source: ABdhPJxBNyhzAnY+FdObN7pnTAta+DGpnvQFV2i3L7an+ohCIQSKtw/KtDZc/3aOtErcO8sTHGd/6Q== X-Received: by 2002:a17:906:af7b:: with SMTP id os27mr23608805ejb.154.1622716761257; Thu, 03 Jun 2021 03:39:21 -0700 (PDT) Received: from ?IPv6:2620:10d:c096:310::2410? ([2620:10d:c093:600::2:6c45]) by smtp.gmail.com with ESMTPSA id s2sm1565455edu.89.2021.06.03.03.39.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 03:39:20 -0700 (PDT) To: Richard Guy Briggs References: <9e69e4b6-2b87-a688-d604-c7f70be894f5@kernel.dk> <3bef7c8a-ee70-d91d-74db-367ad0137d00@kernel.dk> <94e50554-f71a-50ab-c468-418863d2b46f@gmail.com> <20210602154638.GA3711857@madcap2.tricolour.ca> From: Pavel Begunkov Subject: Re: [RFC PATCH 2/9] audit,io_uring,io-wq: add some basic audit support to io_uring Message-ID: Date: Thu, 3 Jun 2021 11:39:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210602154638.GA3711857@madcap2.tricolour.ca> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: linux-audit@redhat.com X-Mailman-Approved-At: Thu, 03 Jun 2021 09:03:04 -0400 Cc: Jens Axboe , selinux@vger.kernel.org, linux-security-module@vger.kernel.org, linux-audit@redhat.com, Kumar Kartikeya Dwivedi , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Alexander Viro X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On 6/2/21 4:46 PM, Richard Guy Briggs wrote: > On 2021-06-02 09:26, Pavel Begunkov wrote: >> On 5/28/21 5:02 PM, Paul Moore wrote: >>> On Wed, May 26, 2021 at 4:19 PM Paul Moore wrote: >>>> ... If we moved the _entry >>>> and _exit calls into the individual operation case blocks (quick >>>> openat example below) so that only certain operations were able to be >>>> audited would that be acceptable assuming the high frequency ops were >>>> untouched? My initial gut feeling was that this would involve >50% of >>>> the ops, but Steve Grubb seems to think it would be less; it may be >>>> time to look at that a bit more seriously, but if it gets a NACK >>>> regardless it isn't worth the time - thoughts? >>>> >>>> case IORING_OP_OPENAT: >>>> audit_uring_entry(req->opcode); >>>> ret = io_openat(req, issue_flags); >>>> audit_uring_exit(!ret, ret); >>>> break; >>> >>> I wanted to pose this question again in case it was lost in the >>> thread, I suspect this may be the last option before we have to "fix" >>> things at the Kconfig level. I definitely don't want to have to go >>> that route, and I suspect most everyone on this thread feels the same, >>> so I'm hopeful we can find a solution that is begrudgingly acceptable >>> to both groups. >> >> May work for me, but have to ask how many, and what is the >> criteria? I'd think anything opening a file or manipulating fs: >> >> IORING_OP_ACCEPT, IORING_OP_CONNECT, IORING_OP_OPENAT[2], >> IORING_OP_RENAMEAT, IORING_OP_UNLINKAT, IORING_OP_SHUTDOWN, >> IORING_OP_FILES_UPDATE >> + coming mkdirat and others. >> >> IORING_OP_CLOSE? IORING_OP_SEND IORING_OP_RECV? >> >> What about? >> IORING_OP_FSYNC, IORING_OP_SYNC_FILE_RANGE, >> IORING_OP_FALLOCATE, IORING_OP_STATX, >> IORING_OP_FADVISE, IORING_OP_MADVISE, >> IORING_OP_EPOLL_CTL >> >> >> Another question, io_uring may exercise asynchronous paths, >> i.e. io_issue_sqe() returns before requests completes. >> Shouldn't be the case for open/etc at the moment, but was that >> considered? > > This would be why audit needs to monitor a thread until it wraps up, to > wait for the result code. My understanding is that both sync and async > parts of an op would be monitored. There may be a misunderstanding audit_start(req) ret = io_issue_sqe(req); audit_end(ret); io_issue_sqe() may return 0 but leave the request inflight, which will be completed asynchronously e.g. by IRQ, not going through io_issue_sqe() or any io_read()/etc helpers again, and after last audit_end() had already happened. That's the case with read/write/timeout, but is not true for open/etc. >> I don't see it happening, but would prefer to keep it open >> async reimplementation in a distant future. Does audit sleep? > > Some parts do, some parts don't depending on what they are interacting > with in the kernel. It can be made to not sleep if needed. Ok, good -- Pavel Begunkov -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit