Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1586221pxa; Thu, 6 Aug 2020 10:55:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI27wt3goO+V0a9SZx6bUgMicrBd0oHy/DID9xCa/F/9bGHnLSBkvMt9ftqB7mqQYNTASr X-Received: by 2002:a17:906:248d:: with SMTP id e13mr5327596ejb.169.1596736519996; Thu, 06 Aug 2020 10:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596736519; cv=none; d=google.com; s=arc-20160816; b=uQXE3NttHN/K2XeaWnkFap/ZZAAMQLbiTM6TzgIR//qd0b1YLlkNnbJdC2uWPnwiUZ 78Qx0uj6trDGLjTF690zKSLwZGOi0+GBSPX2p68fPbZqcha+Wvu+KHSPyR1bkeucoIvh 6Y/Vau9Zq1FHAwq5+WxsHQNvD/Vt9jzFkxbHjpBNqGXYdWm2cV0QotsIntQ+McJsp4vW nj+fQ091wvPhJmzlI6tUT/bFioDQojqKym/0o0am+YizG+yqdlu/nJOw6yCMm2WV2UJJ u4Yje3nJJIPCFnOMkWwGO665S0tGVYcAA+UgINDE3Pt7+CMtsJYWFI0GtgDiTge5A/Xj DYvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=R97zMI60ksjPa7U2NZwa0+iTW68IrGB7I77fbWe6eP4=; b=EOOTSm7qogTvhqhQlj35hRW7NUSYZAOFiFGyocJwvi0O+BRObd5RJdZnJPCw+q1oFz 7OjeQjz2eUeriV0fZav8mT5/sesdjWMFeL9LmHO5TSC9darMfQYkyD2/V9qdDE7p+2yh BBwyjbWsGSUpDBBxTTuCiMvgZl4kyXxHLU4kDvrjlAwzb4CAH7V32At8K/qb+wyYL9gB xX2YPp0D6BZ21nbV0/ZF5BxYVW8G72YykFXbaYeNyHj9iUTUOSvelXlgJqnesyNNC+oD su239pM3mjfloC6qS1rqvHPShTSgI7DSwI16dNGBe000LyDPXm+bcmUmjW/dqPZNbumj xFiQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sony.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w23si3653537edu.32.2020.08.06.10.54.57; Thu, 06 Aug 2020 10:55:19 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sony.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730338AbgHFRwd convert rfc822-to-8bit (ORCPT + 99 others); Thu, 6 Aug 2020 13:52:33 -0400 Received: from seldsegrel01.sonyericsson.com ([37.139.156.29]:8045 "EHLO SELDSEGREL01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728399AbgHFQbU (ORCPT ); Thu, 6 Aug 2020 12:31:20 -0400 Subject: Re: [PATCH 2/2] selinux: add attributes to avc tracepoint To: Stephen Smalley , =?UTF-8?Q?Thi=c3=a9baud_Weksteen?= , Paul Moore CC: Nick Kralevich , Eric Paris , Steven Rostedt , Ingo Molnar , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Arnd Bergmann , linux-kernel , SElinux list References: <20200806080358.3124505-1-tweek@google.com> <20200806080358.3124505-2-tweek@google.com> <89d23362-39b9-79e5-84f1-d7b89204ef38@gmail.com> <8627d780-0e19-6755-0de5-c686deb0f5de@sony.com> <971592b6-5d5f-05d8-d243-b521fe65577d@gmail.com> <07e2c48d-3918-6ceb-a6b2-4e2f18f9ea01@gmail.com> From: peter enderborg Message-ID: Date: Thu, 6 Aug 2020 16:51:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT Content-Language: en-GB X-SEG-SpamProfiler-Analysis: v=2.3 cv=frmim2wf c=1 sm=1 tr=0 a=kIrCkORFHx6JeP9rmF/Kww==:117 a=IkcTkHD0fZMA:10 a=y4yBn9ojGxQA:10 a=pGLkceISAAAA:8 a=z6gsHLkEAAAA:8 a=Fbti1pkVs00Xad8lyQgA:9 a=QEXdDO2ut3YA:10 a=d-OLMTCWyvARjPbQ-enb:22 X-SEG-SpamProfiler-Score: 0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/6/20 3:49 PM, Stephen Smalley wrote: > On Thu, Aug 6, 2020 at 9:45 AM Stephen Smalley > wrote: >> On 8/6/20 8:32 AM, Stephen Smalley wrote: >> >>> On 8/6/20 8:24 AM, peter enderborg wrote: >>> >>>> On 8/6/20 2:11 PM, Stephen Smalley wrote: >>>>> On 8/6/20 4:03 AM, Thiébaud Weksteen wrote: >>>>> >>>>>> From: Peter Enderborg >>>>>> >>>>>> Add further attributes to filter the trace events from AVC. >>>>> Please include sample usage and output in the description. >>>>> >>>>> >>>> Im not sure where you want it to be. >>>> >>>> In the commit message or in a Documentation/trace/events-avc.rst ? >>> I was just asking for it in the commit message / patch description. I >>> don't know what is typical for Documentation/trace. >> For example, I just took the patches for a spin, running the >> selinux-testsuite under perf like so: >> >> sudo perf record -e avc:selinux_audited -g make test >> >> and then ran: >> >> sudo perf report -g >> >> and a snippet of sample output included: >> >> 6.40% 6.40% requested=0x800000 denied=0x800000 >> audited=0x800000 result=-13 ssid=922 tsid=922 >> scontext=unconfined_u:unconfined_r:test_binder_mgr_t:s0-s0:c0.c1023 >> tcontext=unconfined_u:unconfined_r:test_binder_mgr_t:s0-s0:c0.c1023 >> tclass=capability > So then the question becomes how do you use the above information, > e.g. is that sufficient to correlate it to an actual avc: denied > message, how do you decode the requested/denied/audited fields (or > should the code do that for you and just report the string name(s) of > the permission(s), do you need all three of those fields separately, > is it useful to log the ssid/tsid at all given that you have the > contexts and sids are dynamically assigned, etc. > >> | >> ---0x495641000028933d >> __libc_start_main >> | >> |--4.60%--__GI___ioctl >> | entry_SYSCALL_64 >> | do_syscall_64 >> | __x64_sys_ioctl >> | ksys_ioctl >> | binder_ioctl >> | binder_set_nice >> | can_nice >> | capable >> | security_capable >> | cred_has_capability.isra.0 >> | slow_avc_audit >> | common_lsm_audit >> | avc_audit_post_callback >> | avc_audit_post_callback The real cool thing happen when you enable "user-stack-trace" too.            <...>-4820  [007] .... 85878.897553: selinux_audited: requested=0x4000000 denied=0x4000000 audited=0x4000000 result=-13 ssid=341 tsid=61 scontext=system_u:system_r:ntpd_t:s0 tcontext=system_u:object_r:bin_t:s0 tclass=file            <...>-4820  [007] .... 85878.897572:  =>  <00007f07d99bb45b>  =>  <0000555ecd89ca57> The fields are useful for filter what you what to see and what you can ignore.  Having the ssid and text was from the part where it is called. The numeric can be used for two things. When you dont have any context. Same same reason as in post_callback. We need to be static in format so it need  be there if it ever can happen. And it is also useful for faster filtering. You can do "ssid!=42 && ssid!=43 && tsid==666".  From my view it would be good to have all fields there. But they need to right typed to be able to use the filter mechanism. There must me some trade-off too where the argument filtering get bigger than the processing, but I think we can add a lot more before we reach that threshold.