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=-8.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,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 AF392C4338F for ; Tue, 24 Aug 2021 22:28:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A6FB613AD for ; Tue, 24 Aug 2021 22:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230197AbhHXW2v (ORCPT ); Tue, 24 Aug 2021 18:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbhHXW2v (ORCPT ); Tue, 24 Aug 2021 18:28:51 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CFABC061764 for ; Tue, 24 Aug 2021 15:28:06 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id cn28so33963953edb.6 for ; Tue, 24 Aug 2021 15:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6hkZeZy2+xnAtQuXUMmxKgSMrK4i0nbQ3t/wf4o0qRY=; b=MmaJfPHpzRbsJlXZkuzVrbjLlibt11hoE05tPy3m6OqW1mqorfjF3831NjH+2ZVsM0 3tQ1MDElb4EL6KsuGyo/eRpP8pRZLatz3prx1nOGZYIunfFat1WLQRHvrwHEt92KTvDw suP9XqmGqqbszlSoSCrJDknn9Qk/pFkbFxaVFHWIAjCmqUDURgIVb0vk8KX0xRcSS0xe k+6A1TqarcNGCICZ+bXg1dPz7SQdziYP38FbzHfFGNQiKTrVaXlB82/bmdG10eHZvw2K zH56yKSScerUTS+WljEcvCbcmbqIBsI8hOtobL+d/4DHKXwtmz1X95jqNgWNQ2PC00Vh SLiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6hkZeZy2+xnAtQuXUMmxKgSMrK4i0nbQ3t/wf4o0qRY=; b=Um92cYrNCCdgs/x8WxJ2oLnLhUVZziz9GFMBgqzP62+8GVt8odlUWD3OYEVWyvSuPR e8Uc8ek7GYu5cvu3POz3yED5f803rsh7f7mxXFBzHjjUCms2nBG6tQSnGORuxf9t9r// stQs0Hvrx7rMAoioVa1XyFVyViMh3e7Mh+Otbl7Tl0nJzNpOcGvvKQeQk/1uyEgZPdLe YbJ3Rwcsj0T5mNd8ZuYMm0EBPEcFdIHhVge8/zkFTMzJ9WGCJ5Ie0jloMOasLzl1/ZNJ C6TKVioqvg5G2LMYhUi4LcR9XC8069NLFdDoKcWu2Di5tchxg9ghAC2DL1AEgGO1WDQG /tbg== X-Gm-Message-State: AOAM532MT0cihXCH0VVDM3DUNdBmMDxphg3NixMrE0DOqO5sJKZ0u6J3 Wu4WhwoxU/OZvdwoxkiZQScs+1iL1dKdzgImgWoq X-Google-Smtp-Source: ABdhPJziBOe5SY3bWwGhrb7aAvJqWfLkgbImlhY5CVyOoivBO4wFGSLnXI7zHb+BwM9x270TA1Ph9HCTAAT96LTfTfk= X-Received: by 2002:aa7:d982:: with SMTP id u2mr44953224eds.164.1629844084932; Tue, 24 Aug 2021 15:28:04 -0700 (PDT) MIME-Version: 1.0 References: <162871480969.63873.9434591871437326374.stgit@olly> <20210824205724.GB490529@madcap2.tricolour.ca> In-Reply-To: <20210824205724.GB490529@madcap2.tricolour.ca> From: Paul Moore Date: Tue, 24 Aug 2021 18:27:53 -0400 Message-ID: Subject: Re: [RFC PATCH v2 0/9] Add LSM access controls and auditing to io_uring To: Richard Guy Briggs Cc: linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-audit@redhat.com, io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, Kumar Kartikeya Dwivedi , Jens Axboe , Pavel Begunkov Content-Type: multipart/mixed; boundary="000000000000b8e52705ca55a5a6" Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org --000000000000b8e52705ca55a5a6 Content-Type: text/plain; charset="UTF-8" On Tue, Aug 24, 2021 at 4:57 PM Richard Guy Briggs wrote: > Thanks for the tests. I have a bunch of userspace patches to add to the > last set I posted and these tests will help exercise them. I also have > one more kernel patch to post... I'll dive back into that now. I had > wanted to post them before now but got distracted with AUDIT_TRIM > breakage. If it helps, last week I started working on a little test tool for the audit-testsuite and selinux-testsuite (see attached). It may not be final, but I don't expect too many changes to it before I post the test suite patches; it is definitely usable now. It's inspired by the previous tests, but it uses a much more test suite friendly fork/exec model for testing the sharing of io_urings across process boundaries. Would you mind sharing your latest userspace patches, if not publicly I would be okay with privately off-list; I'm putting together the test suite patches this week and it would be good to make sure I'm using your latest take on the userspace changes. Also, what is the kernel patch? Did you find a bug or is this some new functionality you think might be useful? Both can be important, but the bug is *really* important; even if you don't have a fix for that, just a description of the problem would be good. -- paul moore www.paul-moore.com --000000000000b8e52705ca55a5a6 Content-Type: text/x-csrc; charset="US-ASCII"; name="iouring.4.c" Content-Disposition: attachment; filename="iouring.4.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ksqn1u1n0 LyoKICogaW9fdXJpbmcgdGVzdCB0b29sIHRvIGV4ZXJj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