Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1370835 > unrolled thread
| Started by | Kees Cook <keescook@chromium.org> |
|---|---|
| First post | 2016-04-04 21:40 +0200 |
| Last post | 2016-04-05 01:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v2 5/5] LSM: LoadPin for kernel file loading restrictions Kees Cook <keescook@chromium.org> - 2016-04-04 21:40 +0200
Re: [PATCH v2 5/5] LSM: LoadPin for kernel file loading restrictions Mimi Zohar <zohar@linux.vnet.ibm.com> - 2016-04-05 01:10 +0200
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2016-04-04 21:40 +0200 |
| Subject | Re: [PATCH v2 5/5] LSM: LoadPin for kernel file loading restrictions |
| Message-ID | <rkivU-86a-15@gated-at.bofh.it> |
On Thu, Mar 31, 2016 at 2:24 PM, Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> On Mon, 2016-03-28 at 14:14 -0700, Kees Cook wrote:
>
>> +static const char *id_str[READING_MAX_ID] = {
>> + [READING_FIRMWARE] = "firmware",
>> + [READING_MODULE] = "kernel module",
>> + [READING_KEXEC_IMAGE] = "kexec image",
>> + [READING_KEXEC_INITRAMFS] = "kexec initramfs",
>> + [READING_POLICY] = "security policy",
>> +};
>> +
>> +static int loadpin_read_file(struct file *file, enum kernel_read_file_id id)
>> +{
>> + struct super_block *load_root;
>> + const char *origin;
>> +
>> + if (id < 0 || id >= READING_MAX_ID)
>> + return -EINVAL;
>> +
>
> The kernel_read_file_id enumeration starts at 1.
Yeah, I noticed that but decided that since I didn't have a named
value to mark the start, and negative value enums are extremely
unliked, I'd just check against "0" since missing id_str entries will
be correctly identified as "unknown" in the case where id_str and
READING_* enum is out of sync.
>> + origin = id_str[id];
>> + if (!origin) {
>> + origin = "unknown";
>
> Right, all the entries in the kernel_read_file_id enumeration are
> currently listed in id_str. Checking origin is needed for when id_str[]
> isn't kept in sync with the enumeration.
I wonder if there should be a function that returns a const string for
each kernel_read_file_id enum so users of the enum don't need to do
it?
> Looks good!
Thanks! I'll be sending an updated version shortly...
-Kees
--
Kees Cook
Chrome OS & Brillo Security
[toc] | [next] | [standalone]
| From | Mimi Zohar <zohar@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-04-05 01:10 +0200 |
| Message-ID | <rklN8-24A-31@gated-at.bofh.it> |
| In reply to | #1370835 |
On Mon, 2016-04-04 at 12:31 -0700, Kees Cook wrote:
> On Thu, Mar 31, 2016 at 2:24 PM, Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> > On Mon, 2016-03-28 at 14:14 -0700, Kees Cook wrote:
> >
> >> +static const char *id_str[READING_MAX_ID] = {
> >> + [READING_FIRMWARE] = "firmware",
> >> + [READING_MODULE] = "kernel module",
> >> + [READING_KEXEC_IMAGE] = "kexec image",
> >> + [READING_KEXEC_INITRAMFS] = "kexec initramfs",
> >> + [READING_POLICY] = "security policy",
> >> +};
> >> +
> I wonder if there should be a function that returns a const string for
> each kernel_read_file_id enum so users of the enum don't need to do
> it?
Right, having a single, corresponding, string array would be good. Some
of the strings in id_str[] have blanks, which might be problematic for
the audit subsystem, and would need to be replaced with a hyphen or
underscore.
Mimi
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web