Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp888062pxb; Thu, 26 Aug 2021 17:56:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMzvFF58ivprfo9UZMUGryDtA2kbcMgjQ6X3tHeLu9OX4BK9L46gzUc4WiIZWqNhb1ISN+ X-Received: by 2002:a05:6402:1395:: with SMTP id b21mr6977265edv.119.1630025780607; Thu, 26 Aug 2021 17:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630025780; cv=none; d=google.com; s=arc-20160816; b=gaKA5YXWVLedyMbSLZHOzCMZW+QCqHuubCv1w4dJeSacOaaAUq3XA3QaQd+gdgJ7Tl mFQ/mUzSmPIgAnh5aSWlI6TtEzp8ecJ0+KP0Y1gbrvNtTzRUcdlhzZ+0XAJ56fW+M4U5 7CtUhiriUdLuGHr7brmp+4fQcEC+FF8mTxZW3bg6jbgvilzDb7QgsZrWND7cApo6zfIJ DHVpX7eWIJoNFmzIxsOQ4GY/SjVpJF9L+7L2+dLRMvSnsR7SyRytM1QhdlImynlOLx1A p2RYGXa3kGwBAU81syshiPnD2etVVBRT3qqG902W1qQTqgKekSs0nW+1xzj9PsrBAmX1 bUUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kcZjG66xtA/jY29pBRQOPOds6aYeDhJ8jQhY1pZY80A=; b=d1ILQ27/vs3p8sPjIDPyzGWBJzSGwuLWCxrMardb+3cL91kFDnaEEimrfTTk/u/SuJ tbh4x1Ef6pPzFisng0kqe6z+Nl31OWCWg93lHc//UQPwIO/+IckeVGQHkl3hQQlVGay5 3pwTcOQ227JKENpzXEDoctqrTUNh5xM5sNJO4nxSiB+B/NTU6GXcznFjfNrPVlL0IorJ KDG/kJSZxpiwIBDTgg7IPuJi4M3wcRVTtjvjz1cdYcbUdPjJqyTjAP+/CvbocWQfLAPm GmFSCHnrQMeC+EfvGdfJMMg1bi+unZ8nv3zAYvtu3pi6MUHDs5Ko46DQ2W49r+Md8KDz N+Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=bk6vfNTo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 11si4666956edw.187.2021.08.26.17.55.57; Thu, 26 Aug 2021 17:56:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=bk6vfNTo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243877AbhH0AxS (ORCPT + 99 others); Thu, 26 Aug 2021 20:53:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243811AbhH0AxS (ORCPT ); Thu, 26 Aug 2021 20:53:18 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9F74C061757 for ; Thu, 26 Aug 2021 17:52:29 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id x11so10318973ejv.0 for ; Thu, 26 Aug 2021 17:52:29 -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:content-transfer-encoding; bh=kcZjG66xtA/jY29pBRQOPOds6aYeDhJ8jQhY1pZY80A=; b=bk6vfNTov+ymNHAHaSlYzg+pXn1z2h9fT4GVPYxh4e4SQY71Z+fwbcXFztimoz1hRx zAwLQ1RSvbuz4IRt0ig1e+XVKOZaaMxfKyoyq+Rt6S6gaf9zftZdOG7AxEarsGi3Il2O B2czlprwtwo/7hHgL6EAXw4s6UpUrMvEmls2ejoH8ChoWFOu5CcXvRH1ZJUhmrh9yCov QOr+bT67MTqhZcIxXeHriyMGroLP6PBDJJ+Q5AMb/5W8KyTeBJVKeIQpy0xmNRi/FRsH yEHvmu62DIMfdmj7f4Y5VDYPjELEslbXVqjS0Z6fIHLehadImqvThpAD+b0KDXV31pA/ hGag== 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:content-transfer-encoding; bh=kcZjG66xtA/jY29pBRQOPOds6aYeDhJ8jQhY1pZY80A=; b=IXYGGot1fRI8K26um5hlrKYwaEXwwDk/zvXJFWW0+FSftkBkR3tpci4bIsoSNijCIc p8gwXLG8NvE9qEbFrJGL/RLBmyY5G4zONJaRuj1hEQXGIs0YwMOMgquguzyy2C5vqaXP YR2oRbxFV3pp3HieV4GootgUeD9Boap8rUZD4vq/lEOdoTTNk1Fq/fFAB9lMgOYwjWbO yTnzamU5cqk8wpxCZYjNQbaCb2zKHq8nEj8RVumpNmgLO6uaWsmx0pqg+4TDvuKV0bYd dRjw40DHisD14f8KoLCABEgHvGZC9qVL8SpmV4Ve3jd0yAFGOrwKGCy31wSOxO0L1FMf z7YA== X-Gm-Message-State: AOAM531EQSpgKQBCovXzxV98cq35VRTpidIjRDrLejvzPpfswBPiKYyQ Z/m4tDqTKLRiG0FIyYYwYGsNK1P0535kgF3VQOXE X-Received: by 2002:a17:906:1d59:: with SMTP id o25mr7136046ejh.431.1630025548172; Thu, 26 Aug 2021 17:52:28 -0700 (PDT) MIME-Version: 1.0 References: <5a2692b6-5077-21b4-8ebf-73b1c2b83a40@csgroup.eu> <87tujc9srr.fsf@mpe.ellerman.id.au> In-Reply-To: <87tujc9srr.fsf@mpe.ellerman.id.au> From: Paul Moore Date: Thu, 26 Aug 2021 20:52:17 -0400 Message-ID: Subject: Re: [PATCH v2 RESEND] powerpc/audit: Convert powerpc to AUDIT_ARCH_COMPAT_GENERIC To: Michael Ellerman , rgb@redhat.com Cc: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Eric Paris , linux-audit@redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 26, 2021 at 10:37 AM Michael Ellerman wrot= e: > Paul Moore writes: > > On Tue, Aug 24, 2021 at 1:11 PM Christophe Leroy > > wrote: > >> Le 24/08/2021 =C3=A0 16:47, Paul Moore a =C3=A9crit : > >> > On Tue, Aug 24, 2021 at 9:36 AM Christophe Leroy > >> > wrote: > >> >> > >> >> Commit e65e1fc2d24b ("[PATCH] syscall class hookup for all normal > >> >> targets") added generic support for AUDIT but that didn't include > >> >> support for bi-arch like powerpc. > >> >> > >> >> Commit 4b58841149dc ("audit: Add generic compat syscall support") > >> >> added generic support for bi-arch. > >> >> > >> >> Convert powerpc to that bi-arch generic audit support. > >> >> > >> >> Cc: Paul Moore > >> >> Cc: Eric Paris > >> >> Signed-off-by: Christophe Leroy > >> >> --- > >> >> Resending v2 with Audit people in Cc > >> >> > >> >> v2: > >> >> - Missing 'git add' for arch/powerpc/include/asm/unistd32.h > >> >> - Finalised commit description > >> >> --- > >> >> arch/powerpc/Kconfig | 5 +- > >> >> arch/powerpc/include/asm/unistd32.h | 7 +++ > >> >> arch/powerpc/kernel/Makefile | 3 -- > >> >> arch/powerpc/kernel/audit.c | 84 ------------------------= ----- > >> >> arch/powerpc/kernel/compat_audit.c | 44 --------------- > >> >> 5 files changed, 8 insertions(+), 135 deletions(-) > >> >> create mode 100644 arch/powerpc/include/asm/unistd32.h > >> >> delete mode 100644 arch/powerpc/kernel/audit.c > >> >> delete mode 100644 arch/powerpc/kernel/compat_audit.c > >> > > >> > Can you explain, in detail please, the testing you have done to veri= fy > >> > this patch? > >> > > >> > >> I built ppc64_defconfig and checked that the generated code is functio= nnaly equivalent. > >> > >> ppc32_classify_syscall() is exactly the same as audit_classify_compat_= syscall() except that the > >> later takes the syscall as second argument (ie in r4) whereas the form= er takes it as first argument > >> (ie in r3). > >> > >> audit_classify_arch() and powerpc audit_classify_syscall() are slightl= y different between the > >> powerpc version and the generic version because the powerpc version ch= ecks whether it is > >> AUDIT_ARCH_PPC or not (ie value 20), while the generic one checks whet= her it has bit > >> __AUDIT_ARCH_64BIT set or not (__AUDIT_ARCH_64BIT is the sign bit of a= word), but taking into > >> account that the abi is either AUDIT_ARCH_PPC, AUDIT_ARCH_PPC64 or AUD= IT_ARCH_PPC64LE, the result is > >> the same. > >> > >> If you are asking I guess you saw something wrong ? > > > > I was asking because I didn't see any mention of testing, and when you > > are enabling something significant like this it is nice to see that it > > has been verified to work :) > > > > While binary dumps and comparisons are nice, it is always good to see > > verification from a test suite. I don't have access to the necessary > > hardware to test this, but could you verify that the audit-testsuite > > passes on your test system with your patches applied? > > > > * https://github.com/linux-audit/audit-testsuite > > I tested on ppc64le. Both before and after the patch I get the result > below. > > So I guess the patch is OK, but maybe we have some existing issue. > > I had a bit of a look at the test code, but my perl is limited. I think > it was running the command below, and it returned "", but > not really sure what that means. If it makes you feel any better, my perl is *very* limited; thankfully this isn't my first time looking at that test :) It's a little odd, but after some basic sanity tests at the top, the test sets a watch on a file, /tmp/, and tells the kernel to generate audit records for any syscall that operates on that file. It then creates, and removes, a series of exclude audit filters to check if the exclude filtering is working as expected, e.g. when syscall filtering is excluded there should be no syscall records in the audit log. In the case you describe, it looks like it looks like the audit exclude filter is removed (that's what line 147 does), the /tmp/ file is removed (line 152), and then we check to see if any syscall records exist (line 164, and yes, there should be *something* there for the unlink/rm). It may be of little consolation, but this test works just fine on recent kernels running on both x86_64 and aarch64. I don't have access to a powerpc system of any vintage, but I added Richard to the To line above in case he has easier access to a test system (I suspect the RH/IBM linkage should help in this regard). Otherwise I would suggest starting to debug this by simply doing some basic tests using auditctl to create rules and exclude rules to see what is working, and what isn't; that might provide some clues. Sorry I'm not much more help at this point :/ > $ sudo ausearch -i -m SYSCALL -p 216440 -ui 0 -gi 0 -ul 0 -su unconfine= d _u:unconfined_r:unconfined_t:s0-s0:c0.c1023 -ts recent > > > cheers > > > > Running as user root > with context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c102= 3 > on system Fedora > > backlog_wait_time_actual_reset/test .. ok > exec_execve/test ..................... ok > exec_name/test ....................... ok > file_create/test ..................... ok > file_delete/test ..................... ok > file_rename/test ..................... ok > filter_exclude/test .................. 1/21 > # Test 20 got: "256" (filter_exclude/test at line 167) > # Expected: "0" > # filter_exclude/test line 167 is: ok( $result, 0 ); > # Test 21 got: "0" (filter_exclude/test at line 179) > # Expected: "1" > # filter_exclude/test line 179 is: ok( $found_msg, 1 ); > filter_exclude/test .................. Failed 2/21 subtests > filter_saddr_fam/test ................ ok > filter_sessionid/test ................ ok > login_tty/test ....................... ok > lost_reset/test ...................... ok > netfilter_pkt/test ................... ok > syscalls_file/test ................... ok > syscall_module/test .................. ok > time_change/test ..................... ok > user_msg/test ........................ ok > fanotify/test ........................ ok > bpf/test ............................. ok > > Test Summary Report > ------------------- > filter_exclude/test (Wstat: 0 Tests: 21 Failed: 2) > Failed tests: 20-21 > Files=3D18, Tests=3D202, 45 wallclock secs ( 0.18 usr 0.03 sys + 20.15 c= usr 0.92 csys =3D 21.28 CPU) > Result: FAIL > Failed 1/18 test programs. 2/202 subtests failed. --=20 paul moore www.paul-moore.com