In the very unlikely chance that a seq_operations didn't get initialized,
we wouldn't want them calling some random location. As a first example
user of __require_explicit_initialization, annotate them so a missing
initializer is a compile-time warning.

Every seq_operations in the tree already sets all four, so no new warnings
are added.

Signed-off-by: Kees Cook <[email protected]>
---
 include/linux/seq_file.h | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index dc0e8c62d9e0..f0e7e52a0905 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -28,11 +28,16 @@ struct seq_file {
        void *private;
 };
 
+/* All four are called without checking for NULL. */
 struct seq_operations {
-       void * (*start) (struct seq_file *m, loff_t *pos);
-       void (*stop) (struct seq_file *m, void *v);
-       void * (*next) (struct seq_file *m, void *v, loff_t *pos);
-       int (*show) (struct seq_file *m, void *v);
+       void *(*start)(struct seq_file *m, loff_t *pos)
+               __require_explicit_initialization;
+       void (*stop)(struct seq_file *m, void *v)
+               __require_explicit_initialization;
+       void *(*next)(struct seq_file *m, void *v, loff_t *pos)
+               __require_explicit_initialization;
+       int (*show)(struct seq_file *m, void *v)
+               __require_explicit_initialization;
 };
 
 #define SEQ_SKIP 1
-- 
2.55.0


Reply via email to