Re: [PATCH v3] of: overlay: user space synchronization

From: Geert Uytterhoeven
Date: Fri Oct 19 2018 - 03:09:09 EST


Hi Frank,

On Fri, Oct 19, 2018 at 2:06 AM Frank Rowand <frowand.list@xxxxxxxxx> wrote:
> On 10/18/18 12:32, Rob Herring wrote:
> > On Tue, Oct 16, 2018 at 05:34:26PM -0700, frowand.list@xxxxxxxxx wrote:
> >> Provide a sysfs file, /sys/firmware/devicetree/tree_version, to allow
> >> user space to determine if the live devicetree has remained unchanged
> >> while a series of one or more accesses of /proc/device-tree/ occur.
> >>
> >> The use of both (1) dynamic devicetree modifications and (2) overlay
> >> apply and removal are not supported during the same boot cycle. Thus
> >> non-overlay dynamic modifications are not reflected in the value of
> >> tree_version.
> >
> > I'd prefer to see some sort of information on overlays exported and user
> > space can check if that changed. IIRC, Pantelis had a series to do that
> > along with a kill switch to prevent further modifications. At least some
> > of that series only had minor issues to fix.
>
> The kill switch addresses a different concern, which was from the security
> community. The kill switch is on my todo list.
>
> I don't remember exactly what info the overlay information export patch
> provided. I'll have to go find it and re-read it.

I'm still forward porting the overlay configfs interface, cfr.
https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/log/?h=topic/renesas-overlays

E.g. after loading r8a7791-koelsch-exio-b-scifa3.dtbo, it changes like:

--- tree /sys/firmware/devicetree old 2018-10-19 08:49:24.073441000 +0200
+++ tree /sys/firmware/devicetree new 2018-10-19 08:49:33.173397000 +0200
@@ -1237,6 +1237,11 @@
â â â â âââ groups
â â â â âââ name
â â â â âââ phandle
+â â â âââ scifa3
+â â â â âââ function
+â â â â âââ groups
+â â â â âââ name
+â â â â âââ phandle
â â â âââ scif_clk
â â â â âââ function
â â â â âââ groups
@@ -1510,6 +1515,8 @@
â â â âââ interrupts
â â â âââ name
â â â âââ phandle
+â â â âââ pinctrl-0
+â â â âââ pinctrl-names
â â â âââ power-domains
â â â âââ reg
â â â âââ resets
@@ -2277,6 +2284,7 @@
â â âââ scifa1
â â âââ scifa2
â â âââ scifa3
+â â âââ scifa3_pins
â â âââ scifa4
â â âââ scifa5
â â âââ scifb0

The above hunks are for /sys/firmware/devicetree/base/.

@@ -2778,6 +2786,14 @@
â â âââ target
â âââ __symbols__
â âââ target
+ âââ 2
+ â âââ can_remove
+ â âââ fragment@0
+ â â âââ target
+ â âââ fragment@1
+ â â âââ target
+ â âââ __symbols__
+ â âââ target
âââ enable

The above hunk is for /sys/firmware/devicetree/overlays/

# ls -l /sys/firmware/devicetree/overlays/
total 0
drwxr-xr-x 6 root root 0 okt 19 08:49 1
drwxr-xr-x 5 root root 0 okt 19 08:49 2
-rw-r--r-- 1 root root 4096 okt 19 08:49 enable

1 is from the DT unit tests,
2 is from r8a7791-koelsch-exio-b-scifa3.dtbo,
enable is the kill switch.

Note that after removing overlay 2, and loading a new overlay, the new one is
again called number 2. But the subdir date is newer.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds