[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220809155737.GA39351@sequoia>
Date: Tue, 9 Aug 2022 10:57:50 -0500
From: Tyler Hicks <code@...icks.com>
To: Deven Bowers <deven.desai@...ux.microsoft.com>
Cc: corbet@....net, zohar@...ux.ibm.com, jmorris@...ei.org,
serge@...lyn.com, tytso@....edu, ebiggers@...nel.org,
axboe@...nel.dk, agk@...hat.com, snitzer@...nel.org,
eparis@...hat.com, paul@...l-moore.com, dm-devel@...hat.com,
linux-doc@...r.kernel.org, roberto.sassu@...wei.com,
linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-block@...r.kernel.org,
linux-fscrypt@...r.kernel.org, linux-audit@...hat.com,
linux-integrity@...r.kernel.org
Subject: Re: [RFC PATCH v8 07/17] ipe: add auditing support
On 2022-06-08 12:01:19, Deven Bowers wrote:
> +/**
> + * getaudit: Read handler for the securityfs node, "ipe/success_audit"
> + * @f: Supplies a file structure representing the securityfs node.
> + * @data: Supplies a buffer passed to the read syscall
> + * @len: Supplies the length of @data
> + * @offset: unused.
> + *
> + * Return:
> + * >0 - Success, Length of buffer written
> + * <0 - Error
> + */
> +static ssize_t getaudit(struct file *f, char __user *data,
> + size_t len, loff_t *offset)
> +{
> + const char *result;
> + struct ipe_context *ctx;
> +
> + ctx = ipe_current_ctx();
> +
> + rcu_read_lock();
> + result = ((READ_ONCE(ctx->success_audit)) ? "1" : "0");
> + rcu_read_unlock();
> +
> + ipe_put_ctx(ctx);
> + return simple_read_from_buffer(data, len, offset, result, 2);
While doing some internal testing, I noticed that some of the IPE files
in securityfs (ipe/audit, ipe/enforce, and ipe/policies/*/active) are
including the NULL terminator (size of 2) in the securityfs file
contents. This is not common to do and this busybox build that my test
machine is using even has some trouble when displaying those files with
cat. I see all three instances of this pattern with this command:
$ git grep simple_read_from_buffer\(.*,\ 2\) security/ipe
I think going to a length of 1 would be best.
Tyler
Powered by blists - more mailing lists