Thread (8 messages) 8 messages, 3 authors, 2024-05-09

Re: [PATCH v3] batman-adv: Add flex array to struct batadv_tvlv_tt_data

From: Kees Cook <hidden>
Date: 2024-05-06 16:29:44
Also in: batman, linux-hardening, lkml, llvm

On Sun, May 05, 2024 at 05:22:10PM +0200, Sven Eckelmann wrote:
On Saturday, 4 May 2024 19:08:39 CEST Erick Archer wrote:
[...]
quoted
quoted
Thanks for the updates. But I can't accept this at the moment because 
__counted_by_be is used in an uapi header without it being defined
include/uapi/linux/stddef.h (and this file is also not included in this 
header).

See commit c8248faf3ca2 ("Compiler Attributes: counted_by: Adjust name and 
identifier expansion") as an example for the similar __counted_by macro.
If I understand correctly, the following changes are also needed because
the annotated struct is defined in a "uapi" header. Sorry if it's a stupid
question, but I'm new to these topics.
No, it is absolutely no stupid question.
quoted
diff --git a/include/uapi/linux/batadv_packet.h b/include/uapi/linux/batadv_packet.h
index 6e25753015df..41f39d7661c9 100644
--- a/include/uapi/linux/batadv_packet.h
+++ b/include/uapi/linux/batadv_packet.h
@@ -9,6 +9,7 @@

 #include <asm/byteorder.h>
 #include <linux/if_ether.h>
+#include <linux/stddef.h>
 #include <linux/types.h>

 /**
This must definitely go into your "original" patch
quoted
diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h
index 2ec6f35cda32..58154117d9b0 100644
--- a/include/uapi/linux/stddef.h
+++ b/include/uapi/linux/stddef.h
@@ -55,4 +55,12 @@
 #define __counted_by(m)
 #endif

+#ifndef __counted_by_le
+#define __counted_by_le(m)
+#endif
If you want to add this (for completeness) then please put it in an extra 
patch. It is simply not used by batman-adv and I would not be able to find any 
justification why it should be part of the batman-adv patch.
quoted
+
+#ifndef __counted_by_be
+#define __counted_by_be(m)
+#endif
+
This part can be either:

* in the batman-adv patch
* or together with the __counted_by_le change in an additional patch which is 
  "in front" of the batman-adv patch (in the patch series).

From my perspective, it is for you to decide - but of course, other 
maintainers might have a different opinion about it.
quoted
 #endif /* _UAPI_LINUX_STDDEF_H */

If this is the right path, can these changes be merged into a
single patch or is it better to add a previous patch to define
__counted_by{le,be}?
I don't have a perfect answer here. See the comments above. The file 
include/uapi/linux/stddef.h doesn't have a specific maintainer (according to 
./scripts/get_maintainer.pl) - so it should be fine to get modified through 
the net-next tree.

But maybe Kees Cook has a different opinion about it. At least there are a lot 
of Signed-off-bys for this file by Kees.
FWIW, I'm also fine with the UAPI going in via netdev. It's the most
likely place to use the be/le variants. Is netdev still open for
patches? Whatever the path, we should get it into this coming merge
window so we can use it elsewhere too if we need it.

-- 
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help