From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: ** X-Spam-Status: No, score=2.3 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21189C433DB for ; Mon, 1 Mar 2021 10:25:23 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5607064DBD for ; Mon, 1 Mar 2021 10:25:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5607064DBD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=linux-audit-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-obvmMzVoO0ewjtRRJzFe5g-1; Mon, 01 Mar 2021 05:25:19 -0500 X-MC-Unique: obvmMzVoO0ewjtRRJzFe5g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58FDF87498A; Mon, 1 Mar 2021 10:25:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 719731F05E; Mon, 1 Mar 2021 10:25:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 635AB4E58D; Mon, 1 Mar 2021 10:25:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 121APATt018044 for ; Mon, 1 Mar 2021 05:25:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id BFAF1203B7A1; Mon, 1 Mar 2021 10:25:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9DEA203B7A0 for ; Mon, 1 Mar 2021 10:25:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 663ED85A5A6 for ; Mon, 1 Mar 2021 10:25:08 +0000 (UTC) Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-384-GL7VTAC6P1y3dre40BDDiQ-1; Mon, 01 Mar 2021 05:25:03 -0500 X-MC-Unique: GL7VTAC6P1y3dre40BDDiQ-1 Received: by mail-ej1-f46.google.com with SMTP id mj10so7087761ejb.5; Mon, 01 Mar 2021 02:25:03 -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=UJyKOUT1QOF4+8j1ckmI0TckBT4FFtirudA4EDxiYT0=; b=byyN93jRjqQiDBu+76yJsbWOnwtC/5KCpOOnpf/hHV3S3SmkmmxS9WJqer7o/wLtCC 6mAKjZaVxgK9QN2CpV9UtpXLX7Dhz9z4ct7HjObbAc0IbBTzP+x55xS0uQCBa2DpTiSq FveZulTDxFA4dV0qcn8EFiaxSkJk6b1w91Q9upD5UGzJz6BuoH/zcGGRD9U0TgLxVsuk CFY0fPmZQtVZ2f3Htjhb4fCjYA9hdWpuqsTUfXTfMR//0d0HS9ZzDNFeB/XfFN0tMw4Y nsI5ka8yT2h+aDUQCN+l5ltizBugJ78A+Mi71oCJQwuXp1feSksikEc0BSnusU7nwXg+ ru1g== X-Gm-Message-State: AOAM533P0ncc8QCeA5mHsbtertJKV4ZR1PFuXxeKuiJPp617XHJpNU9i dzN6YAiCVRkpPY1K0J1xsoNuvx0hjCowdNdBVWQqVEr8yC30Dw== X-Google-Smtp-Source: ABdhPJyVMdV89FHG7tkwYGzR0BHpRy/2ZqJ/avOA8EVHjMXmD8GT8hsDqRCRKpMc5hNC7IlIhZ8EpA0KzmagSQEuiR0= X-Received: by 2002:a17:906:758:: with SMTP id z24mr14723685ejb.406.1614594301806; Mon, 01 Mar 2021 02:25:01 -0800 (PST) MIME-Version: 1.0 References: <20210227214432.GT2015948@madcap2.tricolour.ca> In-Reply-To: <20210227214432.GT2015948@madcap2.tricolour.ca> From: Alan Evangelista Date: Mon, 1 Mar 2021 07:24:50 -0300 Message-ID: Subject: Re: Getting the value of a syscall's memory address argument - setxattr To: Richard Guy Briggs X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: linux-audit@redhat.com Cc: linux-audit@redhat.com X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="===============0193295935364517027==" --===============0193295935364517027== Content-Type: multipart/alternative; boundary="000000000000d0ceca05bc770764" --000000000000d0ceca05bc770764 Content-Type: text/plain; charset="UTF-8" > They would not be safe to access from userspace after the syscall has > finished. audit records the values of a number of specific syscall > parameters in special records so this would most likely need a new > special record to add to the audit syscall event to record those pointer > contents. AFAIK, that would require a patch to the kernel part of the Linux Audit framework? > This use case adds and additional challenge. Since this is a filesystem > that is changed remotely, you may not have a record of the remote user > who made the change, but only the server daemon locally that brokered > the change unless that information is in those pointers. I know. The username is not a problem because I have Windows/Linux users mapped with Centrify. If I can get the extended attributes updated on the Linux side, I'm hoping my code can infer the equivalent operations on the Windows side. On Sat, Feb 27, 2021 at 6:44 PM Richard Guy Briggs wrote: > On 2021-02-26 22:17, Alan Evangelista wrote: > > Each syscall has some arguments and the Linux Audit framework logs each > > pointer argument as a memory address instead of its values. For instance, > > when tracking the setxattr syscall, I get its arguments in the following > > format: > > > > "a0":"55f3604ba000" > > "a1":"7f1b0bd342fd" > > "a2":"55f3604d9b20" > > "a3":"38" > > > > According to https://man7.org/linux/man-pages/man2/setxattr.2.html, a0 > is > > the file path's starting memory address, a1 is the extended attribute > > name's starting memory address, a2 is the extended attribute > > value's starting memory address and a3 is the size in bytes of the > extended > > attribute value. > > > > Is it safe to access those memory addresses in order to get their > values? I > > guess not because their content may have been overwritten between the > time > > the syscall log entry was generated by the kernel and the time it's > > consumed by a Linux Audit client. If indeed it's unsafe to access these > > memory addresses, is there any other way to get the extended attribute > > name/value in the setxattr syscall using the Linux Audit framework? > > They would not be safe to access from userspace after the syscall has > finished. audit records the values of a number of specific syscall > parameters in special records so this would most likely need a new > special record to add to the audit syscall event to record those pointer > contents. > > > My specific use case: I'm using Auditbeat/Linux Audit to track permission > > changes done to a disk partition which is mounted by Samba on a Windows > > Server box. When a Windows user changes permissions of a file in the > Samba > > mount, Linux Audit records a setxattr event and Auditbeat (connected to > the > > kernel's Audit framework via netlink) notifies me of the event. I need to > > know what permission changes the user has done in the file and AFAIK > > parsing the ext attrib name/value is the only way to do that. > > This use case adds and additional challenge. Since this is a filesystem > that is changed remotely, you may not have a record of the remote user > who made the change, but only the server daemon locally that brokered > the change unless that information is in those pointers. > > > Thanks in advance. > > - RGB > > -- > Richard Guy Briggs > Sr. S/W Engineer, Kernel Security, Base Operating Systems > Remote, Ottawa, Red Hat Canada > IRC: rgb, SunRaycer > Voice: +1.647.777.2635, Internal: (81) 32635 > > --000000000000d0ceca05bc770764 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> They would not be safe to access from userspace after= the syscall has
> finished.=C2=A0 audit records the values of a num= ber of specific syscall
> parameters in special records so thi= s would most likely need a new
> special record to add to the audit s= yscall event to record those pointer
> contents.

AFAIK, that would require a patch to the kernel part of the Linux Audit = framework?

> This use case adds and addit= ional challenge.=C2=A0 Since this is a filesystem
> that is changed r= emotely, you may not have a record of the remote user
> who made the = change, but only the server daemon locally that brokered
> the change= unless that information is in those pointers.

I know. The username is not a problem because I have Windows/Linux users
mapped with Centrify. If I can get the extended attributes=C2=A0up= dated on the Linux=C2=A0
side, I'm hoping my code can infer t= he equivalent operations on the Windows side.

On Sat, Feb 27, 2021 at = 6:44 PM Richard Guy Briggs <rgb@redhat= .com> wrote:
On 2021-02-26 22:17, Alan Evangelista wrote:
> Each syscall has some arguments and the Linux Audit framework logs eac= h
> pointer argument as a memory address instead of its values. For instan= ce,
> when tracking the setxattr syscall, I get its arguments in the followi= ng
> format:
>
> "a0":"55f3604ba000"
> "a1":"7f1b0bd342fd"
> "a2":"55f3604d9b20"
> "a3":"38"
>
> According to https://man7.org/linux/man-pa= ges/man2/setxattr.2.html, a0 is
> the file path's starting memory address, a1 is the extended attrib= ute
> name's starting memory address, a2 is the extended attribute
> value's starting memory address and a3 is the size in bytes of the= extended
> attribute value.
>
> Is it safe to access those memory addresses in order to get their valu= es? I
> guess not because their content may have been overwritten between the = time
> the syscall log entry was generated by the kernel and the time it'= s
> consumed by a Linux Audit client. If indeed it's unsafe to access = these
> memory addresses, is there any other way to get the extended attribute=
> name/value in the setxattr syscall using the Linux Audit framework?
They would not be safe to access from userspace after the syscall has
finished.=C2=A0 audit records the values of a number of specific syscall parameters in special records so this would most likely need a new
special record to add to the audit syscall event to record those pointer contents.

> My specific use case: I'm using Auditbeat/Linux Audit to track per= mission
> changes done to a disk partition which is mounted by Samba on a Window= s
> Server box. When a Windows user changes permissions of a file in the S= amba
> mount, Linux Audit records a setxattr event and Auditbeat (connected t= o the
> kernel's Audit framework via netlink) notifies me of the event. I = need to
> know what permission changes the user has done in the file and AFAIK > parsing the ext attrib name/value is the only way to do that.

This use case adds and additional challenge.=C2=A0 Since this is a filesyst= em
that is changed remotely, you may not have a record of the remote user
who made the change, but only the server daemon locally that brokered
the change unless that information is in those pointers.

> Thanks in advance.

- RGB

--
Richard Guy Briggs <= rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

--000000000000d0ceca05bc770764-- --===============0193295935364517027== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit --===============0193295935364517027==--