Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2288417pxb; Wed, 9 Feb 2022 15:15:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJypSJxAimEhkhiv3AOdyAswWlvBhzOt1iG7Qjf9QNvCNEZBirDtWVkOcea75KjVU22NiqwV X-Received: by 2002:a65:6093:: with SMTP id t19mr3745086pgu.584.1644448505054; Wed, 09 Feb 2022 15:15:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644448505; cv=none; d=google.com; s=arc-20160816; b=LZT0xrM7cTdTDBPu3thB73z7tr5VlVEpyoaCB1QTs+Ue+k62KrN+xtLuJWaYKm01PH TqLraQiObJsWW0TayRlDirHj4c2SkyfCBhRUr6Upnrprma7yrhLc1Iv7mRhV6mpp9Y5s qu6JZaCpTcetreu8pFlRgIRYUnGyE716b3aSUPRWCYlWrzv2jlOB7024xvdul+A9P8gw Q0mu6O4WrQVDBZb6G8IFyP6Ad1ZIkh3/H5e6tCh8De23+8Dm+sK9OAtqQ7szC8D1XWI7 ai1Jbv3QWm3V/PYpfEn4stye5kiHA9aHjL7Rw/JXMAuMCIwXAYUeUtR01E0p2qhPpO8R vppA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=QwxGeIICnqHoY2j7nGhsMaxduU8evuxeVgZai3IhacA=; b=vbJFqPNtrra59yQiOGS6lXuwQ/889yLvky7xhL+Unv3JexvCYUXySKTbS1WgzeJHC6 zNntW+2BH5JpgQ+ztOeO3fW5uJkAlEZX6uY0Xb9DsFCVE23EUC/mAVd/ZtoniRpsjd8R LVMtw27Tgqt8XSyyyEDVLptmphsdvfu4qqdIEyIzyB3n0RMSACfDFyx/npfWODopOtYG myop/Em9y3mgPjttK2uiVLRguOktl3gFKkZdeWeJhIJMjlLO34azDSFBeetWAIPV57BX aYmOQzVaGc69FhflRoShbSZ0AjJNVK+EpX7J5LBqR2T+4XmUR932asuy4BoJSPlRa7NL LHGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b="xZ/h7zej"; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g8si299405plo.193.2022.02.09.15.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 15:15:05 -0800 (PST) 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=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b="xZ/h7zej"; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 50E72E05138E; Wed, 9 Feb 2022 15:14:40 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235803AbiBIWaN (ORCPT + 99 others); Wed, 9 Feb 2022 17:30:13 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:35866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236064AbiBIWaB (ORCPT ); Wed, 9 Feb 2022 17:30:01 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B7A1E01C8B5 for ; Wed, 9 Feb 2022 14:29:34 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id e7so6935098ejn.13 for ; Wed, 09 Feb 2022 14:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QwxGeIICnqHoY2j7nGhsMaxduU8evuxeVgZai3IhacA=; b=xZ/h7zej5j3WDnJltPH+HHCzgcCr9JfH+MMu9lY0KjxOVQ/+RU/qqu9tBwzalHdJAd T3C2RWDm7kbMtC81ogUlrbeAiGBC5f+z330S6lMDqnXvCPCzu4XmbM6/pRxQOk8ky/9c F2/RBMCoEsh4Ubuug8Hhy6u2sJi1OO7R+NMpKSoyhLEaHAQHZcUrTcFVy9konIUAbFQW W+LWGHaDVPKsTAy0t2um82593RIIu6JHxgPZopY9b3pOi63KKA7nu2GhDc8XJANg8VTE Bv4UvrtulBkXVJ4kriNO/O8EfJyCRZiSHFA1e9eSQA0uwewREbIu3Z1nHo/YNc1NnxnS 6K/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QwxGeIICnqHoY2j7nGhsMaxduU8evuxeVgZai3IhacA=; b=YPkDzB0iMVJmozkRrpZH9IbCOeQYZUcwW93Gi8AnIPeW3ODbOsPZiXZAf1Ys4nIfWk hkll9odp4pd/MNxbebowRJqTkF8B+GZkOYwTF92H5+Sxj+9lFczo2qP3rWzMehh+CkZK 3rW7xhsgEiFbguroy3M23OVGiTABdUTcgSykhHTYadRojJrYSHziV2TFAPDV58HIsSSm I6auF/q0/pQJkrIF5AXfOmFdNitN/ij8G5hkTyUg61WfRcRcggZSalFOW9VeCaqY4RVj XR3F6o2cJf9aE9TPk86/+Crl3Ax/lfh1oRO1841lXWgJah2ZIj0xKRrkHs6TGdg6f/+q /NkA== X-Gm-Message-State: AOAM530XLYIpE5Y7DUjMzx5IGomS+B+qvi4VqWbZrJDj4XtILk/HsGpv BfKCkO70NUC1JkEtStw7f+PKqfNSWVenf9IN5Qa8 X-Received: by 2002:a17:907:d15:: with SMTP id gn21mr3552212ejc.701.1644445772885; Wed, 09 Feb 2022 14:29:32 -0800 (PST) MIME-Version: 1.0 References: <20220209214048.GF1708086@madcap2.tricolour.ca> In-Reply-To: <20220209214048.GF1708086@madcap2.tricolour.ca> From: Paul Moore Date: Wed, 9 Feb 2022 17:29:21 -0500 Message-ID: Subject: Re: [PATCH v4 2/3] audit: add support for the openat2 syscall To: Richard Guy Briggs Cc: Jeff Mahoney , Linux-Audit Mailing List , LKML , linux-fsdevel@vger.kernel.org, Eric Paris , Steve Grubb , Alexander Viro , Eric Paris , Tony Jones Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Wed, Feb 9, 2022 at 4:41 PM Richard Guy Briggs wrote: > On 2022-02-09 10:57, Paul Moore wrote: > > On Tue, Feb 8, 2022 at 10:44 PM Jeff Mahoney wrote: > > > > > > Hi Richard - > > > > > > On 5/19/21 16:00, Richard Guy Briggs wrote: > > > > The openat2(2) syscall was added in kernel v5.6 with commit fddb5d430ad9 > > > > ("open: introduce openat2(2) syscall") > > > > > > > > Add the openat2(2) syscall to the audit syscall classifier. > > > > > > > > Link: https://github.com/linux-audit/audit-kernel/issues/67 > > > > Signed-off-by: Richard Guy Briggs > > > > Link: https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git.rgb@redhat.com > > > > --- > > > > > > [...] > > > > > > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > > > > index d775ea16505b..3f59ab209dfd 100644 > > > > --- a/kernel/auditsc.c > > > > +++ b/kernel/auditsc.c > > > > @@ -76,6 +76,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > #include "audit.h" > > > > > > > > @@ -196,6 +197,8 @@ static int audit_match_perm(struct audit_context *ctx, int mask) > > > > return ((mask & AUDIT_PERM_WRITE) && ctx->argv[0] == SYS_BIND); > > > > case AUDITSC_EXECVE: > > > > return mask & AUDIT_PERM_EXEC; > > > > + case AUDITSC_OPENAT2: > > > > + return mask & ACC_MODE((u32)((struct open_how *)ctx->argv[2])->flags); > > > > default: > > > > return 0; > > > > } > > > > > > ctx->argv[2] holds a userspace pointer and can't be dereferenced like this. > > > > > > I'm getting oopses, like so: > > > BUG: unable to handle page fault for address: 00007fff961bbe70 > > > > Thanks Jeff. > > > > Yes, this is obviously the wrong thing to being doing; I remember > > checking to make sure we placed the audit_openat2_how() hook after the > > open_how was copied from userspace, but I missed the argv dereference > > in the syscall exit path when reviewing the code. > > > > Richard, as we are already copying the open_how info into > > audit_context::openat2 safely, the obvious fix is to convert > > audit_match_perm() to use the previously copied value instead of argv. > > If you can't submit a patch for this today please let me know. > > Agreed. It would have been more awkward with the original order of the > patches. > > The syscalls_file test in the audit-testsuite should have caught this. > https://github.com/rgbriggs/audit-testsuite/commit/1c99021ae27ea23eccce2bb1861df4c9c665cd5b > The test provided does essentially the same thing. I would have thought so, but I've now run this multiple times on both affected and patched kernels but I don't see the page fault on my test system. Anyway, that test has now been merged with the audit-testsuite as well as some cleanup on top to test for the new OPENAT2 record when applicable. -- paul-moore.com