Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp728612pxb; Tue, 2 Feb 2021 16:54:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxro1F89W5WNzovvh7cq5t+bpPBdlaz3350VOHA6N5KTzjogkc9B8tlSjcrIKv/f3WDPFI5 X-Received: by 2002:a17:906:ada:: with SMTP id z26mr632596ejf.218.1612313697342; Tue, 02 Feb 2021 16:54:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313697; cv=none; d=google.com; s=arc-20160816; b=bZVGO+eIWbuxd3q6K4JvwOcf1CkgLamQHjSUaHYxG+hLxiFCfwnQLAIZLBl7Nekp0m px9v1xCsj4pfnR/bB10iF1ULRatHfELOTJbY6dKB6U6Gg8cDHVpJJ5xICTTlL1AKboi5 lA4RfrgOv6ACt+2ReGmP18SCcWaXkV1ZWESGHZHYA/IzW7Y9QV31xUmBJrVF8fGvr5z7 v5Hrqhc0HL6RhFoWOhvoaaAhSCPHXgHprwzk9Q49NMF4sVZfY7kxzg7m/PtdP84ZtpCW HLkSaInxSRsOFJvRWaqhEXhwy6wB5+BaksVO7gLAQOpmfpplW5RrCMA9S7d7hUsOyZFE Y7WQ== 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=VpgWM/abuu0TQrIRbjQU0gPGa4Gz1AqWL2PjDpQS6SU=; b=qxtWolc113HV47/JvYPeZJ4hs22vIS92iDI1VrretfXApYH6CP9k+9moGTsR53i/Pg DJizM/gP3Ei9PtMqyZcoIOCA0AmQZkbG+hWln/lsc/2xQwHFN76BnH/T96UOsjWXs4TG Y6ysMqbOUfqmv4iWKhGNF1P2hiiYiQVdwDIMpFrGxvBhomVIpG1kZs+ZXdTe7LsmAZAB gB5W/hSPu7ZGFw3ZsbGzmec3UeNIi767BAHYl0Jr7EfanmhHT9XNy7G0GPDfpaPSDGtR g4XaA5rcFx50pMJU1wtKqwjPsvheL6tgaMiyZmlPvmYRkESHCPYdittrvgRJPv8V1B5M Wp8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pp8rJhwC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si312343ejt.185.2021.02.02.16.54.33; Tue, 02 Feb 2021 16:54:57 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=Pp8rJhwC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234724AbhBBWNN (ORCPT + 99 others); Tue, 2 Feb 2021 17:13:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50313 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233881AbhBBWM5 (ORCPT ); Tue, 2 Feb 2021 17:12:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612303888; 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=VpgWM/abuu0TQrIRbjQU0gPGa4Gz1AqWL2PjDpQS6SU=; b=Pp8rJhwCttizwYg4JapspQrGK+NknQgcSTuj6NDRMOlerNESeRQNb2GcNPvfangsmZfTv5 0j0HtuFs88joc1Q11yavv+vkibhg7/hU3lkBRyb6Rb2BVM5qbjG5oRU2uAZPOFDOprxKng Xu+bxuXbHvHDb4thAEP81/2pJA0Q//0= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-sRyKq4FUPamPGOdz3tGQuA-1; Tue, 02 Feb 2021 17:11:26 -0500 X-MC-Unique: sRyKq4FUPamPGOdz3tGQuA-1 Received: by mail-lf1-f69.google.com with SMTP id k5so4995880lfo.19 for ; Tue, 02 Feb 2021 14:11:26 -0800 (PST) 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; bh=VpgWM/abuu0TQrIRbjQU0gPGa4Gz1AqWL2PjDpQS6SU=; b=ZIj1vM4TcfC5QLhSf9jTsCQVmd33PyWqdb5oTPIPP8sJrt6Xj+sbHRQ77yrJXI60Yq Ec4A2ExKD9tLiFbaSoYZw7r9ybvEXmsk8QKVdnTwAfv/BHSWtFSQlZ5TbeTncOWiD44K CKQZNXcEG/rlkIAhMrGcRAlyo6C31uzJDcIC3gQ1ZVuOOQZGKHz7sIDO3ABEvqOsuGq4 blML1GTMZvdFOwDbU5QT00cjH3MKgRCnbbzaAq5MQy2oLTTGmyrtCs8KzKoatrSLGLFc Ez1sOkllV9uFiC5g3ewa2gC1vOMHVtSHyDsJ1kLOSe+WBtko1FShuJcFKrDNnbOFbpgD 8aaA== X-Gm-Message-State: AOAM530zf41XZFhN4HMoyFN3e/hEOodT7cLtNOOwxsGouB5lPpKDWZyx fxzGYOCAoLVNCGhU3wsy8W794J6vCSFG+wq9Ky+1ViufmwQXQtXXmdvEkHkxoPrUntYd0uwo/lc YUUrseeIhV9BH9UcPKP4gotVnOvJICv7Xe1zW6eOG X-Received: by 2002:a19:7403:: with SMTP id v3mr28324lfe.67.1612303885022; Tue, 02 Feb 2021 14:11:25 -0800 (PST) X-Received: by 2002:a19:7403:: with SMTP id v3mr28269lfe.67.1612303883741; Tue, 02 Feb 2021 14:11:23 -0800 (PST) MIME-Version: 1.0 References: <20210202212930.18845-1-danielwa@cisco.com> <20210202214357.GD3710@zorba> In-Reply-To: From: Ondrej Mosnacek Date: Tue, 2 Feb 2021 23:11:12 +0100 Message-ID: Subject: Re: [PATCH 1/2] audit: show user land backtrace as part of audit context messages To: Paul Moore Cc: "Daniel Walker (danielwa)" , "Victor Kamensky (kamensky)" , "Ruslan Bilovol -X (rbilovol - GLOBALLOGIC INC at Cisco)" , "linux-kernel@vger.kernel.org" , "linux-audit@redhat.com" , "xe-linux-external(mailer list)" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 2, 2021 at 10:46 PM Paul Moore wrote: > On Tue, Feb 2, 2021 at 4:44 PM Daniel Walker (danielwa) > wrote: > > On Tue, Feb 02, 2021 at 04:35:42PM -0500, Paul Moore wrote: > > > On Tue, Feb 2, 2021 at 4:29 PM Daniel Walker wrote: > > > > From: Victor Kamensky > > > > > > > > To efficiently find out where SELinux AVC denial is comming from > > > > take backtrace of user land process and display it as type=UBACKTRACE > > > > message that comes as audit context for SELinux AVC and other audit > > > > messages ... > > > > > > Have you tried the new perf tracepoint for SELinux AVC decisions that > > > trigger an audit event? It's a new feature for v5.10 and looks to > > > accomplish most of what you are looking for with this patch. > > > > > > * https://www.paul-moore.com/blog/d/2020/12/linux_v510.html > > > > We haven't tried it, but I can look into it. We're not using v5.10 extensively > > yet. > > Let us know if that works for you, and if it doesn't, let us know what > might be missing. I hate seeing the kernel grow multiple features > which do the same thing. I agree - I played around with this new tracepoint recently and you can use it to achieve what you want quite easily: # collect traces for denials (just interrupt/kill the sleep process when done) - will create a perf.data file you can analyze later perf record -a -e avc:selinux_audited -g --call-graph=dwarf sleep infinity # dump all collected backtraces from the perf.data file perf script It's a bit complicated if you want to have it running in the background permanently as a service (you need to tell perf to dump the recorded data before you can read it), but perf already has some command-line options to help with that use case. -- Ondrej Mosnacek Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.