linux-audit.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Steve Grubb <sgrubb@redhat.com>
Cc: Jan Kara <jack@suse.cz>, Amir Goldstein <amir73il@gmail.com>,
	linux-audit@redhat.com, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/3] fanotify: define bit map fields to hold response decision  context
Date: Thu, 1 Oct 2020 12:24:19 +0200	[thread overview]
Message-ID: <20201001102419.GF17860@quack2.suse.cz> (raw)
In-Reply-To: <20201001101219.GE17860@quack2.suse.cz>

On Thu 01-10-20 12:12:19, Jan Kara wrote:
> On Wed 30-09-20 12:12:28, Steve Grubb wrote:
> > This patch defines 2 bit maps within the response variable returned from
> > user space on a permission event. The first field is 3 bits for the context
> > type. The context type will describe what the meaning is of the second bit
> > field. The default is none. The patch defines one additional context type
> > which means that the second field is a rule number. This will allow for the
> > creation of 6 other context types in the future if other users of the API
> > identify different needs. The second field is 10 bits wide and can be used
> > to pass along the data described by the context. Neither of these bit maps
> > are directly adjacent and could be expanded if the need arises.
> > 
> > To support this, several macros were created to facilitate storing and
> > retrieving the values. There is also a macro for user space to check that
> > the data being sent is valid. Of course, without this check, anything that
> > overflows the bit field will trigger an EINVAL based on the use of
> > of INVALID_RESPONSE_MASK in process_access_response().
> > 
> > Signed-off-by: Steve Grubb <sgrubb@redhat.com>
> 
> So how likely do you find other context types are or that you'd need to
> further expand the information passed from userspace? Because if there are
> decent changes the expansion will be needed then I'd rather do something
> like:
> 
> struct fanotify_response {
> 	__s32 fd;
> 	__u16 response;
> 	__u16 extra_info_type;
> };
> 
> which is also backwards compatible and then userspace can set extra_info_type
> and based on the type we'd know how much more bytes we need to copy from
> buf to get additional information for that info type. 
> 
> This is much more flexible than what you propose and not that complex to
> implement, you get type safety for extra information and don't need to use
> macros to cram everything in u32 etc. Overall cleaner interface I'd say.
> 
> So in your case you'd then have something like:
> 
> #define FAN_RESPONSE_INFO_AUDIT_RULE 1
> 
> struct fanotify_response_audit_rule {
> 	__u32 rule;
> };

Now I realized we need to propagate the extra information through fanotify
permission event to audit - that can be also done relatively easily. Just
add '__u16 extra_info_type' to fanotify_perm_event and 'char
extra_info_buf[FANOTIFY_MAX_RESPONSE_EXTRA_LEN]' for now for the data. If
we ever grow larger extra info structures, we can always change this to
dynamic allocation but that will be only internal fanotify change,
userspace facing API can stay the same.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

--
Linux-audit mailing list
Linux-audit@redhat.com
https://www.redhat.com/mailman/listinfo/linux-audit


  reply	other threads:[~2020-10-01 12:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30 16:12 [PATCH 2/3] fanotify: define bit map fields to hold response decision context Steve Grubb
2020-10-01 10:12 ` Jan Kara
2020-10-01 10:24   ` Jan Kara [this message]
2020-10-01 20:33     ` Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201001102419.GF17860@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sgrubb@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).