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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3583AC433EF for ; Wed, 9 Feb 2022 22:32:02 +0000 (UTC) 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-88-xbtMUTojMk28vc0xJfKpEw-1; Wed, 09 Feb 2022 17:31:59 -0500 X-MC-Unique: xbtMUTojMk28vc0xJfKpEw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3994C8144E0; Wed, 9 Feb 2022 22:31:56 +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 12A314E2CB; Wed, 9 Feb 2022 22:31:56 +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 BAAC44BB7C; Wed, 9 Feb 2022 22:31:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219MVquE020760 for ; Wed, 9 Feb 2022 17:31:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C375401E79; Wed, 9 Feb 2022 22:31:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58974401E78 for ; Wed, 9 Feb 2022 22:31:52 +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 3FB9A85A5A8 for ; Wed, 9 Feb 2022 22:31:52 +0000 (UTC) Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-167-GYMKo5GhOcKNokp8vV18RA-1; Wed, 09 Feb 2022 17:31:50 -0500 X-MC-Unique: GYMKo5GhOcKNokp8vV18RA-1 Received: by mail-ed1-f51.google.com with SMTP id da4so7867113edb.4 for ; Wed, 09 Feb 2022 14:31:50 -0800 (PST) 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=gY7hhO1bC5lbho8ZpFz/uvNbjMguzN7sAedEp2sBebU=; b=mlHstlHgfQKaqDeEketJ63GvBt5tPH1Dz5DxCyFG/o1Q09xkRwGd9oW11kPz7qatGw 4zGiAP6udSiyugT+k29tBlRsuIJ/D8I/dy3X6xgzpgk6c1WsLGkdOQq2xjKjQHFH/Nv4 vcWJoQycAb2mtC7CHoGKr3qX3amsnSA7yCw955mmtPa0sl9iPWjeALvTlNShaPmmIoKg tpY+CHG3U/dYagbC/7WTfB0YKfI5T+tuEV92RplSZE7bXnVahvk0j80lik314mOym6af VbswSAnLL1fK2LCOdK/D6OCpI1BHPUCH67HiZPrcRF8c7/JKGZMl0ew0djOxVdXF5zFF /urg== X-Gm-Message-State: AOAM531t3xesHU8RpalKe+bWVCIGZHZAVpAR/yHzUmP76exA6IB/xj97 TaHC9Hcdvc4i+El/+qFa8DhwBXDBgtTcDIF2hqrj X-Google-Smtp-Source: ABdhPJwUNfjZCGfPkj27TA/J7q2UqoS1q9fubbNKT1mgH9jGEz3c/HLfBuBOOF3m+LSj/E70I6YdHGqH0gyxSIBVG7k= X-Received: by 2002:a05:6402:896:: with SMTP id e22mr5291750edy.427.1644445909356; Wed, 09 Feb 2022 14:31:49 -0800 (PST) MIME-Version: 1.0 References: <20220209221352.GG1708086@madcap2.tricolour.ca> In-Reply-To: <20220209221352.GG1708086@madcap2.tricolour.ca> From: Paul Moore Date: Wed, 9 Feb 2022 17:31:38 -0500 Message-ID: Subject: Re: [PATCH v4 2/3] audit: add support for the openat2 syscall To: Richard Guy Briggs 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.85 on 10.11.54.10 X-loop: linux-audit@redhat.com Cc: Tony Jones , Jeff Mahoney , LKML , Eric Paris , Linux-Audit Mailing List , Alexander Viro , linux-fsdevel@vger.kernel.org, Eric Paris 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.13 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, Feb 9, 2022 at 5:14 PM Richard Guy Briggs wrote: > > On 2022-02-09 16:18, Paul Moore wrote: > > On Wed, Feb 9, 2022 at 10:57 AM 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. > > > > I haven't heard anything from Richard so I put together a patch which > > should fix the problem (link below). It's currently untested, but > > I've got a kernel building now with the patch ... > > Well, the day wasn't over yet... I've compiled and tested it. Yes, I tested my patch too and everything looks good on my end. For future reference, while I didn't explicitly ask you to acknowledge this thread and that you were working on a patch (I probably should have), it would have been nice if you could have sent a quick note to the list. -- paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit