Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2300149pxb; Wed, 9 Feb 2022 15:33:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7W+/ueMMKLZczdcxhj/LPprf3FsnncWEXhI3uPvaO/NvvwGnJW86ruMk8hyx4RpfmGmc9 X-Received: by 2002:a17:90a:a385:: with SMTP id x5mr6139764pjp.129.1644449626758; Wed, 09 Feb 2022 15:33:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644449626; cv=none; d=google.com; s=arc-20160816; b=rq1lEne6MgYau3ZVJSr8XrcHG23jp2RuWqRCx8+WQ5MGX81J9CFU/4s4QwvW74rJ6t hAzgsYKPqQexvlzBhHm3lm6kFhXanm+4kVQOjAUbEyZKBImCxNCIE3qhKGmU1TG7fsjQ pXMEmA/CyHClKhvSl1jMzNN8sNZSisLsQzTHSxu3bir0yCJwJOplX1IAhdj08lgmu+G1 MokniIMQKFuzrA6PDzSaeJvA8I5x33l7F9jg/VTqJluOD5LrmFd60Sa+4pCx2tzBGwx2 TdqDsjbpz6NI4P6d1yABcbqchO0cEdgZ4GB9BYvfVPT5IpPayCcWGtjO3aROsvi2fo31 Zwyg== 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=gY7hhO1bC5lbho8ZpFz/uvNbjMguzN7sAedEp2sBebU=; b=EZdkxnw2m60Oawg+f96KN/DeGTKlXBTgOF5cb+iPzM1fDISowh0HqDSWcAiG7n/jB1 JcXCTTHDuB2n+Pj7AkqxzrtUpL1oV9c+n2s3rTYGRfF9e2FuiYT2L+uqaQMi5mWJjYAR qCmkLyb3+9MmFHgathl22KO6BIUxO1CtcOoZW3AOuh7V3zQlCGzdDxyXujOzDXkTlVIW KGMJp5Er/HXzsHbUaDoJvRLxSE9mr2A2k0f8ysNZ2NH5wyW2ytkr3isOTxfulBhBfyTL 8Ycpu4YP4udRtjrzEtH7INZeNzy/7eJgDG470m6pF8QLvFXtQcxTiIcvzwm6cn12o0P4 7qFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b="rssUS/ac"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z205si2335482pfc.176.2022.02.09.15.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 15:33:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b="rssUS/ac"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 A408FE07FCC3; Wed, 9 Feb 2022 15:22:34 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235970AbiBIWbz (ORCPT + 99 others); Wed, 9 Feb 2022 17:31:55 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:42698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235873AbiBIWbw (ORCPT ); Wed, 9 Feb 2022 17:31:52 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC049E0186D9 for ; Wed, 9 Feb 2022 14:31:50 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id f17so7942000edd.2 for ; Wed, 09 Feb 2022 14:31:50 -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=gY7hhO1bC5lbho8ZpFz/uvNbjMguzN7sAedEp2sBebU=; b=rssUS/acb+BxW1zvWepfle4TqIv68o7OqDJBLW54+XnxrX6lIoxQqMMLaak5tJLF3j IC2BJ9Y2G9PEcNX//DaHZug3E+XVSsLMxZ9cSVpfqVA4GukP6YhgJYxraSnEKcUgeC71 EBT3275a/kRyY0HyocxQ2m5b7XsVxvvC8Bkkxz4bxDOJ40RvYmmKe+8KohJacm4gLbsu gAUmEoxHIoP5RPOfNI9f0u1stWph8rcNdIWZHBKCguVKqI1KmbakVLelmZlX2Oqm+soo 2fwvodZm4ZZEPCmbc4bWqQfPV+fSyQwFWRwObaLiVgFjZKH682bDblTKRPCMf2iIw9ux 2dag== 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=JrVoyQT1TWfohERLG1YYlHF/zGIp/4XVG0dxokhFUdv/0A/WRzkdo9g3KlHyx+tbIc HcU0nkkoic40nrlAxoriZuvhRxGxy4VGJcZEXcPAMY3HdyOWCLatbuGA32WL/AgXCKco tG3/BvuAAkekfLeeDI2BBt1x5+HdoTXxSQLQ3NprXbRkmkqM4wykA5KQ5XLzC85cZRJ2 sZk/D9Mr8iTzMtAJ+TywAvkGONjfkZwOSqzfIQbCRTDil6R8OJusC35jIgnKMD+BPkko /PG7Dus5LofT9E3785YE2CKmS3ROep6yfL4lF7jLAjYHeiFHiM0fWzBs+sbSzb24xHcU yTgw== X-Gm-Message-State: AOAM530s/2005VfIb+3U85I1vQwqKrWyaoIMISowrlXapCUxQ1HESXjL LpIomlaCyIvamv5LcCWKWLTFZoHCZyfcUm9CMfcL 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 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 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