Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2026222ybg; Thu, 30 Jul 2020 08:33:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoZ5EXihmoGyvCSWvBSs/S8sqUjVcji8r3o3rUZ1f6PAZ7dDysfTJpf3rKJy9C/qFe9cNe X-Received: by 2002:a17:906:374f:: with SMTP id e15mr2989759ejc.528.1596123236816; Thu, 30 Jul 2020 08:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596123236; cv=none; d=google.com; s=arc-20160816; b=NR7sfjDUfirV01Jhmw2Bla8ChC862OmLxiYVjMwwZzOtFaO36DRKeE/SkMuHAHqdC/ 2oNkK4dPgHLNyXlofafB98vXrsHXyzbtG1vvzBj5Qs+wHThOWa8PL1zcT+sB8nnoSZYd iD97zHUb6GfU2nqrWTxQFpKdSAnAqf0I5vHW2fE93HswzPKMhXCmBF5SwuibAoUocPyh o41zMxOqbpucfwpFa2wi6Woh/pieHUV5TM81u1yZMtVUKLnZ8oB1xn3MPwl4+ljs722e oSMTR5quIvhXFel9YUUTBJ+Hq7GzBop1yWI1AWEg8Y+hgsfY8tCSp5tZTutmoE9PDhCt 2KtA== 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=WGzr76y/k7pdPdZt/ozEfSgpvrVuRg/44pJ8M6zoDAU=; b=WSvQt5WtYtCa0pgvPqamdAzaXNATYoXwqdD/ImkkWjmO9hs+NlHVEX/pLbfJUDfoHs sb20ygCyzBhyaP8yfnm68ANWeVbJ2YVeG/u3QBZ+m6s9UWeTRwV6TzkdpDguU9xiVidX +b7Lr1Cc8Vo29Fw/fICMWV/H+RyRx45Yd33aaswe9FtreNeBPb7lsANImZel1Xld56tx 4EYSZiIF962x7tWiLKLDhxwzDEOn8MkdIuHs5B3lexhVklumzRP7IDXFp1QRDCsPu8nJ T6A41ImAprA99GjHGZdsbI4C4QkdrKj93x7OAqNeCO8RS21sJrhNulhypb+eLI7rvAcC ZkNw== 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 a90si3436399edf.486.2020.07.30.08.33.30; Thu, 30 Jul 2020 08:33:56 -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 S1729696AbgG3PbV convert rfc822-to-8bit (ORCPT + 99 others); Thu, 30 Jul 2020 11:31:21 -0400 Received: from seldsegrel01.sonyericsson.com ([37.139.156.29]:8915 "EHLO SELDSEGREL01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728447AbgG3PbV (ORCPT ); Thu, 30 Jul 2020 11:31:21 -0400 Subject: Re: [PATCH] RFC: selinux avc trace To: Steven Rostedt CC: =?UTF-8?Q?Thi=c3=a9baud_Weksteen?= , Paul Moore , Nick Kralevich , Joel Fernandes , Stephen Smalley , Eric Paris , Ingo Molnar , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , , References: <20200724091520.880211-1-tweek@google.com> <20200724095232.5f9d3f17@oasis.local.home> <80a23580-5067-93b0-53fa-3bd53253c056@sony.com> <20200730110459.5bf0b0df@oasis.local.home> From: peter enderborg Message-ID: <6f1262fc-21ad-f872-5460-e78d4685c9c4@sony.com> Date: Thu, 30 Jul 2020 17:31:17 +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: <20200730110459.5bf0b0df@oasis.local.home> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT Content-Language: en-GB X-SEG-SpamProfiler-Analysis: v=2.3 cv=DrAoB13+ c=1 sm=1 tr=0 a=kIrCkORFHx6JeP9rmF/Kww==:117 a=IkcTkHD0fZMA:10 a=_RQrkK6FrEwA:10 a=z6gsHLkEAAAA:8 a=5h1WKlBXYhE9TN685y0A: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 7/30/20 5:04 PM, Steven Rostedt wrote: > On Thu, 30 Jul 2020 16:29:12 +0200 > peter enderborg wrote: > >> +#undef TRACE_SYSTEM >> +#define TRACE_SYSTEM avc >> + >> +#if !defined(_TRACE_AVC_H) || defined(TRACE_HEADER_MULTI_READ) >> +#define _TRACE_AVC_H >> + >> +#include >> +TRACE_EVENT(avc_data, >> +        TP_PROTO(u32 requested, >> +             u32 denied, >> +             u32 audited, >> +             int result, >> +             const char *msg >> +             ), >> + >> +        TP_ARGS(requested, denied, audited, result,msg), >> + >> +        TP_STRUCT__entry( >> +             __field(u32, requested) >> +             __field(u32, denied) >> +             __field(u32, audited) >> +             __field(int, result) >> +             __array(char, msg, 255) > You want to use __string() here, otherwise you are wasting a lot of > buffer space. > > __string( msg, msg) It should be a full structure with a lot of sub strings.  But that make is even more relevant. > >> +                 ), >> + >> +        TP_fast_assign( >> +               __entry->requested    = requested; >> +               __entry->denied    = denied; >> +               __entry->audited    = audited; >> +               __entry->result    = result; >> +               memcpy(__entry->msg, msg, 255); > Not to mention, the above is a bug. As the msg being passed in, is > highly unlikely to be 255 bytes. You just leaked all that memory after > the sting to user space. > > Where you want here: > > __assign_str( msg, msg ); Directly in to the code. Was more in to get in to discussion on how complex we should have the trace data. There is a lot of fields. Not all is always present. Is there any good way to handle that? Like "something= somethingelse=42" or "something=nil somthingelse=42" > > -- Steve > > > >> +    ), >> + >> +        TP_printk("requested=0x%x denied=%d audited=%d result=%d >> msg=%s", >> +              __entry->requested, __entry->denied, __entry->audited, >> __entry->result, __entry->msg >> +              )