Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2289907pxb; Wed, 9 Feb 2022 15:17:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6EKAhPjEld6Xmm0X42+JbTZirpUMqV/fVYUUjS81CmuzAXCsth0G0SuDh3WicPdD/RLbr X-Received: by 2002:a17:902:e887:: with SMTP id w7mr4530932plg.161.1644448646020; Wed, 09 Feb 2022 15:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644448646; cv=none; d=google.com; s=arc-20160816; b=0A2XOrlut4BIfTyW2BcLLmMszVIGY1vz4PqVx6JZ+FYEKgJQ7KnQm3rgT10xM6B8Cr xRxs+t09gqkubSqzKKho1WAVPBNtrzrsleaeSijTroPYdj8QXke+6mn2EKm2kkQ3sQVn 1Ez6+t7AnCkJbb0uFGBUL9E14kkbLfV9qCLSs20A6kz3CuL4dDkGUt/u9I3XdIqDsqv5 W+dURyV2j0EcskUbyQg6NDsfPC72YXYWjydsG8SscDNSaNiaSNPmUgVj/iEw3baDqOKu 6uXT0JIu9nuLqwVh4wVq9fvEkcw/SEo/Q3MnPbhAyrJ+A2OUm9utMDboETuNbSxDIpiZ KNDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=smkfZoDYqP3/eJTnNRlO1L7Zl22cCTCgCp929irEWv8=; b=OU4OmJwOgiMHgpeEYP0cfCrIjZeeQrvqV1mU79aL5b3M55nWGnEEudjyLj9WwNHNKl 0qxsXwkXeK/BSwW2iUf5G84JDi7MDqaXdEnQ6zoaw48aPM3oOJCRjRZrlUh3OXuVH0gO 6avHNt4taBvjb61bbApbFrG145qq6J2MZeZS61t2D1YkxBN1VhnyMoTHfgOfhvEyLVoL cBjbfXgzDoPjSKi/XZBgVtY4a/4qVpUfY3SKzsBi6Qd2sd9z6QKjFFTKO6px1xFX1qcb ZEted6Jwo7RRw7ohXqqfAue7q0Wg8o66vOODQuHPJfro8ks9nzckCMA7OjsTxOeMN9WF GksA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A50gUUVL; 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=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o5si17567512pgs.119.2022.02.09.15.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 15:17:26 -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=@redhat.com header.s=mimecast20190719 header.b=A50gUUVL; 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=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C76EE054AFD; Wed, 9 Feb 2022 15:15:33 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233609AbiBIVlN (ORCPT + 99 others); Wed, 9 Feb 2022 16:41:13 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:51452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233598AbiBIVlM (ORCPT ); Wed, 9 Feb 2022 16:41:12 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3A7CAC050CF8 for ; Wed, 9 Feb 2022 13:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644442872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=smkfZoDYqP3/eJTnNRlO1L7Zl22cCTCgCp929irEWv8=; b=A50gUUVLoVDIAnIX0m8UpBCFGWQcqmXOp23eJ+iQDVZUAsywmDqubQ9PjMhSS3htbnA6lo tDVioYD0iS6cwL4EHjRyvvKwDoFxr1nOsczouDskiPqbdtlNK3Qp5+7ekxTflkRiLMmqVX 6MzhELNdvmx8/Zerhj9YdZPx3yoJAng= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-lP7ou0rHMXKiF0AW0Nkh5g-1; Wed, 09 Feb 2022 16:41:07 -0500 X-MC-Unique: lP7ou0rHMXKiF0AW0Nkh5g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E29018143EF; Wed, 9 Feb 2022 21:41:05 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.22.48.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C859D5DB90; Wed, 9 Feb 2022 21:40:50 +0000 (UTC) Date: Wed, 9 Feb 2022 16:40:48 -0500 From: Richard Guy Briggs To: Paul Moore Cc: Jeff Mahoney , Linux-Audit Mailing List , LKML , linux-fsdevel@vger.kernel.org, Eric Paris , Steve Grubb , Alexander Viro , Eric Paris , Tony Jones Subject: Re: [PATCH v4 2/3] audit: add support for the openat2 syscall Message-ID: <20220209214048.GF1708086@madcap2.tricolour.ca> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Spam-Status: No, score=-2.0 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=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 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 should have a tested patch posted today. > paul-moore.com - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635