kernel_netdev_priv: track netdev priv data
commitfe1cd9dcfd0233ab2bb457cbffa4148fbbc20033
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 27 Jun 2023 08:16:06 +0000 (27 11:16 +0300)
committerDan Carpenter <dan.carpenter@linaro.org>
Tue, 27 Jun 2023 08:16:06 +0000 (27 11:16 +0300)
tree59a4c604b01ca345abc5f832f2a874026d82134e
parentc76c12ffe38367257a82c1cdde52b64914c0f37a
kernel_netdev_priv: track netdev priv data

How net devices work is you allocate a netdevice but then you specify the
amount of private data that you need for the driver and that gets allocated
on the end of the netdevice struct.  It's all allocated as one big buffer
but you need to call "my_data = netdev_priv();" to access your data.

Smatch wants to track what size a buffer is and what the struct members
are etc.  But this format is not normal so Smatch doesn't know how to
handle it.

What we can do is re-use the container_of param mapper code to and create
a new format which tracks netdev_priv().

I wrote this code to warn about a specific CVE that someone reported.  I
did manage to generate a warning for the CVE, but didn't find anything
else.  I don't think there was any major issues with this code either.
At the time, I was quite worried this would make the database too large,
but it's fine.  And recently I fixed a bug with the too common functions
and that made the DB smaller again.

I wrote this code some time back.  Hopefully, I've merged all the required
bits.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Makefile
check_list.h
smatch.h
smatch_kernel_netdev_priv.c [new file with mode: 0644]
smatch_param_key.c