Re: [PATCH V6 01/16] rv: Add Runtime Verification (RV) interface

From: Steven Rostedt
Date: Wed Jul 20 2022 - 11:21:15 EST


On Tue, 19 Jul 2022 19:27:06 +0200
Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:

> +/*
> + * enabled_monitors interface.
> + */


Doesn't the rv_monitors_list need to be protected by the rv_interface_lock
mutex?

> +static void disable_all_monitors(void)
> +{
> + struct rv_monitor_def *mdef;
> +

I think you need:

mutex_lock(&rv_interface_lock);

> + list_for_each_entry(mdef, &rv_monitors_list, list)
> + disable_monitor(mdef);

mutex_unlock(&rv_interface_lock);

> +}
> +
> +static int enabled_monitors_open(struct inode *inode, struct file *file)
> +{

As this gets called directly from the open system call.

> + if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC))
> + disable_all_monitors();
> +
> + return seq_open(file, &enabled_monitors_seq_ops);
> +};
> +

[..]

> +
> +static const struct file_operations enabled_monitors_ops = {
> + .open = enabled_monitors_open,

Here.

-- Steve

> + .read = seq_read,
> + .write = enabled_monitors_write,
> + .llseek = seq_lseek,
> + .release = seq_release,
> +};