Re: [PATCH V4 00/20] The Runtime Verification (RV) interface

From: Song Liu
Date: Thu Jun 23 2022 - 14:54:51 EST


On Thu, Jun 23, 2022 at 9:42 AM Daniel Bristot de Oliveira
<bristot@xxxxxxxxxx> wrote:
>
> On 6/22/22 09:24, Song Liu wrote:
> > This is interesting work!
> >
> > I applied the series on top of commit 78ca55889a549a9a194c6ec666836329b774ab6d
> > in upstream. Then, I got some compile/link error for CONFIG_RV_MON_WIP and
> > CONFIG_RV_MON_SAFE_WTD. I was able to compile the kernel with these two
> > configs disabled.
>
> I rebased the code and... it compiled. Maybe it was missing some
> config options that I forgot to set as "depends on" in the Kconfig.
>
> Can you check if it was the same problem automatically reported?
>
> Any further information here would help. I will revisit this.

Here are the error messages I got: https://pastebin.com/zJxMA6RK , and
attached is the config file I used.

>
> However, I hit the some issue with monitors/wwnr/enabled :
> >
> > [root@eth50-1 ~]# cd /sys/kernel/debug/tracing/rv/
> > [root@eth50-1 rv]# cat available_monitors
> > wwnr
> > [root@eth50-1 rv]# echo wwnr > enabled_monitors
> > [root@eth50-1 rv]# cd monitors/
> > [root@eth50-1 monitors]# cd wwnr/
> > [root@eth50-1 wwnr]# ls
> > desc enable reactors
> > [root@eth50-1 wwnr]# cat enable
> > 1
> > [root@eth50-1 wwnr]# echo 0 > enable <<< hangs
> >
> > The last echo command hangs forever on a qemu vm. I haven't figured out why
> > this happens though.
>
> I could reproduce it. It is an error in the return code of monitor_enable_write_data(),
> I fixed it locally (return retval ? retval : count; // needs more test), and
> will add it to the next version. Thanks!
>
> > I also have a more general question: can we do RV with BPF and simplify the
> > work? AFAICT, the idea of RV is to maintain a state machine based on events.
> > If something unexpected happens, call the reactor.
> >
> > IIUC, BPF has most of these building blocks ready for use. With BPF, we
> > can ship many RV monitors without much kernel changes.
>
> I am aware of bpftrace and bpf + libbpf, and I have a PoC tool doing most of the
> work I do in C/kernel in C/bpf.
>
> From the cover letter:
>
> "Things kept for a second moment (after this patchset):
> [...]
> - dot2bpf"
>
> The point is that there are use-cases in which the users need the code in
> C. One of those is the work being done in the Linux Foundation Elisa group.
> There will be more formalism, like timed automata... which will require
> infra-structure that is easily accessible in C... including synchronization,
> and reactors that are available only in C on "per use-cases" basis - for
> example on embedded devices.

Where can I find more information about the constraints of these use cases?
I am asking because there are multiple ways to load a BPF program to the
system. If the constraint is that we cannot have bpftrace or bcc in the system,
maybe it is ok to run a standalone binary (written in C, compiled on a different
system). Or maybe we can load BPF programs in a kernel module, or compile
the BPF programs into the kernel? (Yes, we can do it now, check
kernel/bpf/preload). If any of these works, we can benefit from the good
properties of BPF. For example, we can update the RV models without
rebooting the system; and we can reuse various BPF maps, so we don't
need to add union rv_task_monitor to task_struct.

Of course, we are out of luck if these systems cannot enable CONFIG_BPF
at all. But I guess this is not common for modern embedded systems?

Thanks,
Song

Attachment: rv.config
Description: Binary data