Linux Hardening
 help / color / mirror / Atom feed
* [PATCH] landlock: Drop __counted_by from landlock_domain.layers
       [not found] <6ac91e98.bbc4c7f9.15faa7.0023.GAE@google.com>
@ 2026-10-10 16:44 ` Nguyen Ngoc Thang
  2026-10-10 18:05   ` Alejandro Colomar
  2026-10-11 13:11   ` Günther Noack
  0 siblings, 2 replies; 8+ messages in thread
From: Nguyen Ngoc Thang @ 2026-10-10 16:44 UTC (permalink / raw)
  To: Mickaël Salaün, Günther Noack, Tingmao Wang
  Cc: linux-security-module, Kees Cook, linux-hardening, llvm,
	syzbot+a0eecb22de4d821a9e5d

With clang 22 and CONFIG_FORTIFY_SOURCE, the second
landlock_restrict_self() call hits a bogus fortify report in
inherit_ruleset():

  memcpy: detected buffer overflow: 16 byte read of buffer size 0
  Call Trace:
   __fortify_panic
   landlock_merge_ruleset+0xc46/0xc90
   __se_sys_landlock_restrict_self+0x2bc/0xd40

layers[] lives in an anonymous struct inside the anonymous union
that overlays work_free.  For such a flexible array, clang computes the
address of the __counted_by counter as the start of the array instead of
&num_layers.  The bound is then read from layers[0], i.e. from
the first layer's configuration, which is not a count.  The same layout
crashes clang itself in a standalone test.

The annotation was added as documentation, so drop it rather than
restructure the union.  Keep the information in the member comment.

Reported-by: syzbot+a0eecb22de4d821a9e5d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a0eecb22de4d821a9e5d
Fixes: bd3a19800dd1 ("landlock: Add counted_by in landlock_domain")
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
---
Reproduced with clang 22.1.8 and FORTIFY_SOURCE on mic/next (64b9e6eff524):
the second landlock_restrict_self() hits the report, while 16 nested
restricts run clean with this patch.  Mickaël, if you prefer to just drop
bd3a19800dd1 from next, that works as well.
 security/landlock/domain.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/security/landlock/domain.h b/security/landlock/domain.h
index 60e8eb2d6ac2..4bf1555a4349 100644
--- a/security/landlock/domain.h
+++ b/security/landlock/domain.h
@@ -246,8 +246,12 @@ struct landlock_domain {
 			 * properly handle merged rulesets without overlapping
 			 * access rights.  These layers are set once and never
 			 * changed for the lifetime of the domain.
+			 *
+			 * Not annotated with __counted_by(@num_layers): clang
+			 * miscomputes the counter address for a FAM nested in an
+			 * anonymous struct within a union, which trips FORTIFY.
 			 */
-			struct layer_config layers[] __counted_by(num_layers);
+			struct layer_config layers[];
 		};
 	};
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] landlock: Drop __counted_by from landlock_domain.layers
  2026-10-10 16:44 ` [PATCH] landlock: Drop __counted_by from landlock_domain.layers Nguyen Ngoc Thang
@ 2026-10-10 18:05   ` Alejandro Colomar
  2026-10-10 18:46     ` Nathan Chancellor
  2026-10-11 13:11   ` Günther Noack
  1 sibling, 1 reply; 8+ messages in thread
From: Alejandro Colomar @ 2026-10-10 18:05 UTC (permalink / raw)
  To: Nguyen Ngoc Thang
  Cc: Mickaël Salaün, Günther Noack, Tingmao Wang,
	linux-security-module, Kees Cook, linux-hardening, llvm,
	syzbot+a0eecb22de4d821a9e5d

[-- Attachment #1: Type: text/plain, Size: 2747 bytes --]

Hello Nguyen,

> Date: 2026-10-10 23:44:49+0700
> From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
>
> With clang 22 and CONFIG_FORTIFY_SOURCE, the second
> landlock_restrict_self() call hits a bogus fortify report in
> inherit_ruleset():
> 
>   memcpy: detected buffer overflow: 16 byte read of buffer size 0
>   Call Trace:
>    __fortify_panic
>    landlock_merge_ruleset+0xc46/0xc90
>    __se_sys_landlock_restrict_self+0x2bc/0xd40
> 
> layers[] lives in an anonymous struct inside the anonymous union
> that overlays work_free.  For such a flexible array, clang computes the
> address of the __counted_by counter as the start of the array instead of
> &num_layers.  The bound is then read from layers[0], i.e. from
> the first layer's configuration, which is not a count.  The same layout
> crashes clang itself in a standalone test.
> 
> The annotation was added as documentation, so drop it rather than
> restructure the union.  Keep the information in the member comment.
> 
> Reported-by: syzbot+a0eecb22de4d821a9e5d@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a0eecb22de4d821a9e5d
> Fixes: bd3a19800dd1 ("landlock: Add counted_by in landlock_domain")
> Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> ---
> Reproduced with clang 22.1.8 and FORTIFY_SOURCE on mic/next (64b9e6eff524):
> the second landlock_restrict_self() hits the report, while 16 nested
> restricts run clean with this patch.  Mickaël, if you prefer to just drop
> bd3a19800dd1 from next, that works as well.

Is this reproducible with Clang 23 or later?

Should __counted_by() expand to nothing for bogus versions of Clang?
That would allow using it, and just ignore Clang when it's broken,
rather than not using safety features.


Have a lovely day!
Alex

>  security/landlock/domain.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/security/landlock/domain.h b/security/landlock/domain.h
> index 60e8eb2d6ac2..4bf1555a4349 100644
> --- a/security/landlock/domain.h
> +++ b/security/landlock/domain.h
> @@ -246,8 +246,12 @@ struct landlock_domain {
>  			 * properly handle merged rulesets without overlapping
>  			 * access rights.  These layers are set once and never
>  			 * changed for the lifetime of the domain.
> +			 *
> +			 * Not annotated with __counted_by(@num_layers): clang
> +			 * miscomputes the counter address for a FAM nested in an
> +			 * anonymous struct within a union, which trips FORTIFY.
>  			 */
> -			struct layer_config layers[] __counted_by(num_layers);
> +			struct layer_config layers[];
>  		};
>  	};
>  };
> -- 
> 2.43.0
> 
> 

-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] landlock: Drop __counted_by from landlock_domain.layers
  2026-10-10 18:05   ` Alejandro Colomar
@ 2026-10-10 18:46     ` Nathan Chancellor
  2026-10-11  2:57       ` Nguyen Ngoc Thang
  0 siblings, 1 reply; 8+ messages in thread
From: Nathan Chancellor @ 2026-10-10 18:46 UTC (permalink / raw)
  To: Alejandro Colomar
  Cc: Nguyen Ngoc Thang, Mickaël Salaün, Günther Noack,
	Tingmao Wang, linux-security-module, Kees Cook, linux-hardening,
	llvm, syzbot+a0eecb22de4d821a9e5d

On Sat, Oct 10, 2026 at 08:05:48PM +0200, Alejandro Colomar wrote:
> Hello Nguyen,
> 
> > Date: 2026-10-10 23:44:49+0700
> > From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> >
> > With clang 22 and CONFIG_FORTIFY_SOURCE, the second
> > landlock_restrict_self() call hits a bogus fortify report in
> > inherit_ruleset():
> > 
> >   memcpy: detected buffer overflow: 16 byte read of buffer size 0
> >   Call Trace:
> >    __fortify_panic
> >    landlock_merge_ruleset+0xc46/0xc90
> >    __se_sys_landlock_restrict_self+0x2bc/0xd40
> > 
> > layers[] lives in an anonymous struct inside the anonymous union
> > that overlays work_free.  For such a flexible array, clang computes the
> > address of the __counted_by counter as the start of the array instead of
> > &num_layers.  The bound is then read from layers[0], i.e. from
> > the first layer's configuration, which is not a count.  The same layout
> > crashes clang itself in a standalone test.
> > 
> > The annotation was added as documentation, so drop it rather than
> > restructure the union.  Keep the information in the member comment.
> > 
> > Reported-by: syzbot+a0eecb22de4d821a9e5d@syzkaller.appspotmail.com
> > Closes: https://syzkaller.appspot.com/bug?extid=a0eecb22de4d821a9e5d
> > Fixes: bd3a19800dd1 ("landlock: Add counted_by in landlock_domain")
> > Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> > ---
> > Reproduced with clang 22.1.8 and FORTIFY_SOURCE on mic/next (64b9e6eff524):
> > the second landlock_restrict_self() hits the report, while 16 nested
> > restricts run clean with this patch.  Mickaël, if you prefer to just drop
> > bd3a19800dd1 from next, that works as well.
> 
> Is this reproducible with Clang 23 or later?
> 
> Should __counted_by() expand to nothing for bogus versions of Clang?
> That would allow using it, and just ignore Clang when it's broken,
> rather than not using safety features.

This is actively being discussed/investigated in another thread but yes,
we will be marking clang versions affected by this problem as broken for
__counted_by:

  https://lore.kernel.org/20261007-b4-landlock-fix-domain-fortify-panic-v1-1-042e9108f5f8@oss.qualcomm.com/

> >  security/landlock/domain.h | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/security/landlock/domain.h b/security/landlock/domain.h
> > index 60e8eb2d6ac2..4bf1555a4349 100644
> > --- a/security/landlock/domain.h
> > +++ b/security/landlock/domain.h
> > @@ -246,8 +246,12 @@ struct landlock_domain {
> >  			 * properly handle merged rulesets without overlapping
> >  			 * access rights.  These layers are set once and never
> >  			 * changed for the lifetime of the domain.
> > +			 *
> > +			 * Not annotated with __counted_by(@num_layers): clang
> > +			 * miscomputes the counter address for a FAM nested in an
> > +			 * anonymous struct within a union, which trips FORTIFY.
> >  			 */
> > -			struct layer_config layers[] __counted_by(num_layers);
> > +			struct layer_config layers[];
> >  		};
> >  	};
> >  };
> > -- 
> > 2.43.0
> > 
> > 
> 
> -- 
> <https://www.alejandro-colomar.es>



-- 
Cheers,
Nathan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] landlock: Drop __counted_by from landlock_domain.layers
  2026-10-10 18:46     ` Nathan Chancellor
@ 2026-10-11  2:57       ` Nguyen Ngoc Thang
  0 siblings, 0 replies; 8+ messages in thread
From: Nguyen Ngoc Thang @ 2026-10-11  2:57 UTC (permalink / raw)
  To: Nathan Chancellor, Alejandro Colomar
  Cc: Mickaël Salaün, Günther Noack, Tingmao Wang,
	linux-security-module, Kees Cook, linux-hardening, llvm,
	syzbot+a0eecb22de4d821a9e5d

Hi Nathan, Alex,

Thanks for the pointers. I wasn't aware of the earlier thread, so please
disregard my patch in favor of the one from Qualcomm and the Clang
version gating of __counted_by.

To answer Alex's question: I only tested with Clang 22.1.8 (Debian
22.1.8-1~deb13u4, same as the syzbot build). I did not try Clang 23 or
later, so I can't say whether it is fixed there.

Thanks,
Nguyen

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] landlock: Drop __counted_by from landlock_domain.layers
  2026-10-10 16:44 ` [PATCH] landlock: Drop __counted_by from landlock_domain.layers Nguyen Ngoc Thang
  2026-10-10 18:05   ` Alejandro Colomar
@ 2026-10-11 13:11   ` Günther Noack
  2026-10-11 14:31     ` Mickaël Salaün
  1 sibling, 1 reply; 8+ messages in thread
From: Günther Noack @ 2026-10-11 13:11 UTC (permalink / raw)
  To: Nguyen Ngoc Thang
  Cc: Mickaël Salaün, Günther Noack, Tingmao Wang,
	linux-security-module, Kees Cook, linux-hardening, llvm,
	syzbot+a0eecb22de4d821a9e5d

On Sat, Oct 10, 2026 at 11:44:49PM +0700, Nguyen Ngoc Thang wrote:
> With clang 22 and CONFIG_FORTIFY_SOURCE, the second
> landlock_restrict_self() call hits a bogus fortify report in
> inherit_ruleset():
> 
>   memcpy: detected buffer overflow: 16 byte read of buffer size 0
>   Call Trace:
>    __fortify_panic
>    landlock_merge_ruleset+0xc46/0xc90
>    __se_sys_landlock_restrict_self+0x2bc/0xd40
> 
> layers[] lives in an anonymous struct inside the anonymous union
> that overlays work_free.  For such a flexible array, clang computes the
> address of the __counted_by counter as the start of the array instead of
> &num_layers.  The bound is then read from layers[0], i.e. from
> the first layer's configuration, which is not a count.  The same layout
> crashes clang itself in a standalone test.
> 
> The annotation was added as documentation, so drop it rather than
> restructure the union.  Keep the information in the member comment.
> 
> Reported-by: syzbot+a0eecb22de4d821a9e5d@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a0eecb22de4d821a9e5d
> Fixes: bd3a19800dd1 ("landlock: Add counted_by in landlock_domain")
> Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> ---
> Reproduced with clang 22.1.8 and FORTIFY_SOURCE on mic/next (64b9e6eff524):
> the second landlock_restrict_self() hits the report, while 16 nested
> restricts run clean with this patch.  Mickaël, if you prefer to just drop
> bd3a19800dd1 from next, that works as well.
>  security/landlock/domain.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/security/landlock/domain.h b/security/landlock/domain.h
> index 60e8eb2d6ac2..4bf1555a4349 100644
> --- a/security/landlock/domain.h
> +++ b/security/landlock/domain.h
> @@ -246,8 +246,12 @@ struct landlock_domain {
>  			 * properly handle merged rulesets without overlapping
>  			 * access rights.  These layers are set once and never
>  			 * changed for the lifetime of the domain.
> +			 *
> +			 * Not annotated with __counted_by(@num_layers): clang
> +			 * miscomputes the counter address for a FAM nested in an
> +			 * anonymous struct within a union, which trips FORTIFY.
>  			 */
> -			struct layer_config layers[] __counted_by(num_layers);
> +			struct layer_config layers[];
>  		};
>  	};
>  };
> -- 
> 2.43.0
> 

Reviewed-by: Günther Noack <gnoack3000@gmail.com>

I agree - it seems better to drop the __counted_by rather than
restructuring the entire struct for that.

Thanks also for adding a comment about it.  The __counted_by() has
only been added very recently in September, in commit bd3a19800dd1
("landlock: Add counted_by in landlock_domain").  Better to have a
note about it so that we don't accidentally add it back. :)

–Günther

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] landlock: Drop __counted_by from landlock_domain.layers
  2026-10-11 13:11   ` Günther Noack
@ 2026-10-11 14:31     ` Mickaël Salaün
  2026-10-11 15:59       ` Nguyen Ngoc Thang
  2026-10-11 16:16       ` Mickaël Salaün
  0 siblings, 2 replies; 8+ messages in thread
From: Mickaël Salaün @ 2026-10-11 14:31 UTC (permalink / raw)
  To: Günther Noack
  Cc: Nguyen Ngoc Thang, Günther Noack, Tingmao Wang,
	linux-security-module, Kees Cook, linux-hardening, llvm,
	syzbot+a0eecb22de4d821a9e5d

On Sun, Oct 11, 2026 at 03:11:12PM +0200, Günther Noack wrote:
> On Sat, Oct 10, 2026 at 11:44:49PM +0700, Nguyen Ngoc Thang wrote:
> > With clang 22 and CONFIG_FORTIFY_SOURCE, the second
> > landlock_restrict_self() call hits a bogus fortify report in
> > inherit_ruleset():
> > 
> >   memcpy: detected buffer overflow: 16 byte read of buffer size 0
> >   Call Trace:
> >    __fortify_panic
> >    landlock_merge_ruleset+0xc46/0xc90
> >    __se_sys_landlock_restrict_self+0x2bc/0xd40
> > 
> > layers[] lives in an anonymous struct inside the anonymous union
> > that overlays work_free.  For such a flexible array, clang computes the
> > address of the __counted_by counter as the start of the array instead of
> > &num_layers.  The bound is then read from layers[0], i.e. from
> > the first layer's configuration, which is not a count.  The same layout
> > crashes clang itself in a standalone test.
> > 
> > The annotation was added as documentation, so drop it rather than
> > restructure the union.  Keep the information in the member comment.
> > 
> > Reported-by: syzbot+a0eecb22de4d821a9e5d@syzkaller.appspotmail.com
> > Closes: https://syzkaller.appspot.com/bug?extid=a0eecb22de4d821a9e5d
> > Fixes: bd3a19800dd1 ("landlock: Add counted_by in landlock_domain")
> > Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>

Thanks for the patch.

> > ---
> > Reproduced with clang 22.1.8 and FORTIFY_SOURCE on mic/next (64b9e6eff524):
> > the second landlock_restrict_self() hits the report, while 16 nested
> > restricts run clean with this patch.  Mickaël, if you prefer to just drop
> > bd3a19800dd1 from next, that works as well.
> >  security/landlock/domain.h | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/security/landlock/domain.h b/security/landlock/domain.h
> > index 60e8eb2d6ac2..4bf1555a4349 100644
> > --- a/security/landlock/domain.h
> > +++ b/security/landlock/domain.h
> > @@ -246,8 +246,12 @@ struct landlock_domain {
> >  			 * properly handle merged rulesets without overlapping
> >  			 * access rights.  These layers are set once and never
> >  			 * changed for the lifetime of the domain.
> > +			 *
> > +			 * Not annotated with __counted_by(@num_layers): clang
> > +			 * miscomputes the counter address for a FAM nested in an
> > +			 * anonymous struct within a union, which trips FORTIFY.
> >  			 */
> > -			struct layer_config layers[] __counted_by(num_layers);
> > +			struct layer_config layers[];
> >  		};
> >  	};
> >  };
> > -- 
> > 2.43.0
> > 
> 
> Reviewed-by: Günther Noack <gnoack3000@gmail.com>
> 
> I agree - it seems better to drop the __counted_by rather than
> restructuring the entire struct for that.
> 
> Thanks also for adding a comment about it.  The __counted_by() has
> only been added very recently in September, in commit bd3a19800dd1
> ("landlock: Add counted_by in landlock_domain").  Better to have a
> note about it so that we don't accidentally add it back. :)

Actually, I independently wrote a quite similar patch (while traveling),
but it applies to v7.3-rc5 instead of mic/next.  I removed the patch
series that I applied on mic/next because it conflicts with my patch and
I need to send a new version anyway.  If you don't mind, I'll keep
Günther's Reviewed-by tag and credit other contributors in my patch.
I'll propose it for v7.3-rc7 (today) because it is trivial and will help
new patches on top of that.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] landlock: Drop __counted_by from landlock_domain.layers
  2026-10-11 14:31     ` Mickaël Salaün
@ 2026-10-11 15:59       ` Nguyen Ngoc Thang
  2026-10-11 16:16       ` Mickaël Salaün
  1 sibling, 0 replies; 8+ messages in thread
From: Nguyen Ngoc Thang @ 2026-10-11 15:59 UTC (permalink / raw)
  To: mic
  Cc: gnoack3000, m, linux-security-module, kees, linux-hardening, llvm,
	syzbot+a0eecb22de4d821a9e5d

Hi Mickaël, Günther,

Sounds good, no problem at all. Thanks for the quick review, and
happy for you to take your version for v7.3-rc7.

Thanks,
Thang

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] landlock: Drop __counted_by from landlock_domain.layers
  2026-10-11 14:31     ` Mickaël Salaün
  2026-10-11 15:59       ` Nguyen Ngoc Thang
@ 2026-10-11 16:16       ` Mickaël Salaün
  1 sibling, 0 replies; 8+ messages in thread
From: Mickaël Salaün @ 2026-10-11 16:16 UTC (permalink / raw)
  To: Günther Noack
  Cc: Nguyen Ngoc Thang, Günther Noack, Tingmao Wang,
	linux-security-module, Kees Cook, linux-hardening, llvm,
	syzbot+a0eecb22de4d821a9e5d

On Sun, Oct 11, 2026 at 04:32:05PM +0200, Mickaël Salaün wrote:
> On Sun, Oct 11, 2026 at 03:11:12PM +0200, Günther Noack wrote:
> > On Sat, Oct 10, 2026 at 11:44:49PM +0700, Nguyen Ngoc Thang wrote:
> > > With clang 22 and CONFIG_FORTIFY_SOURCE, the second
> > > landlock_restrict_self() call hits a bogus fortify report in
> > > inherit_ruleset():
> > > 
> > >   memcpy: detected buffer overflow: 16 byte read of buffer size 0
> > >   Call Trace:
> > >    __fortify_panic
> > >    landlock_merge_ruleset+0xc46/0xc90
> > >    __se_sys_landlock_restrict_self+0x2bc/0xd40
> > > 
> > > layers[] lives in an anonymous struct inside the anonymous union
> > > that overlays work_free.  For such a flexible array, clang computes the
> > > address of the __counted_by counter as the start of the array instead of
> > > &num_layers.  The bound is then read from layers[0], i.e. from
> > > the first layer's configuration, which is not a count.  The same layout
> > > crashes clang itself in a standalone test.
> > > 
> > > The annotation was added as documentation, so drop it rather than
> > > restructure the union.  Keep the information in the member comment.
> > > 
> > > Reported-by: syzbot+a0eecb22de4d821a9e5d@syzkaller.appspotmail.com
> > > Closes: https://syzkaller.appspot.com/bug?extid=a0eecb22de4d821a9e5d
> > > Fixes: bd3a19800dd1 ("landlock: Add counted_by in landlock_domain")
> > > Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> 
> Thanks for the patch.
> 
> > > ---
> > > Reproduced with clang 22.1.8 and FORTIFY_SOURCE on mic/next (64b9e6eff524):
> > > the second landlock_restrict_self() hits the report, while 16 nested
> > > restricts run clean with this patch.  Mickaël, if you prefer to just drop
> > > bd3a19800dd1 from next, that works as well.
> > >  security/landlock/domain.h | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/security/landlock/domain.h b/security/landlock/domain.h
> > > index 60e8eb2d6ac2..4bf1555a4349 100644
> > > --- a/security/landlock/domain.h
> > > +++ b/security/landlock/domain.h
> > > @@ -246,8 +246,12 @@ struct landlock_domain {
> > >  			 * properly handle merged rulesets without overlapping
> > >  			 * access rights.  These layers are set once and never
> > >  			 * changed for the lifetime of the domain.
> > > +			 *
> > > +			 * Not annotated with __counted_by(@num_layers): clang
> > > +			 * miscomputes the counter address for a FAM nested in an
> > > +			 * anonymous struct within a union, which trips FORTIFY.
> > >  			 */
> > > -			struct layer_config layers[] __counted_by(num_layers);
> > > +			struct layer_config layers[];
> > >  		};
> > >  	};
> > >  };
> > > -- 
> > > 2.43.0
> > > 
> > 
> > Reviewed-by: Günther Noack <gnoack3000@gmail.com>
> > 
> > I agree - it seems better to drop the __counted_by rather than
> > restructuring the entire struct for that.
> > 
> > Thanks also for adding a comment about it.  The __counted_by() has
> > only been added very recently in September, in commit bd3a19800dd1
> > ("landlock: Add counted_by in landlock_domain").  Better to have a
> > note about it so that we don't accidentally add it back. :)
> 
> Actually, I independently wrote a quite similar patch (while traveling),
> but it applies to v7.3-rc5 instead of mic/next.  I removed the patch
> series that I applied on mic/next because it conflicts with my patch and
> I need to send a new version anyway.  If you don't mind, I'll keep
> Günther's Reviewed-by tag and credit other contributors in my patch.
> I'll propose it for v7.3-rc7 (today) because it is trivial and will help
> new patches on top of that.

Here is my rebase:
https://git.kernel.org/mic/c/3d8cc52db2f86b624308321c58513019f6b21eec

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-11 16:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <6ac91e98.bbc4c7f9.15faa7.0023.GAE@google.com>
2026-10-10 16:44 ` [PATCH] landlock: Drop __counted_by from landlock_domain.layers Nguyen Ngoc Thang
2026-10-10 18:05   ` Alejandro Colomar
2026-10-10 18:46     ` Nathan Chancellor
2026-10-11  2:57       ` Nguyen Ngoc Thang
2026-10-11 13:11   ` Günther Noack
2026-10-11 14:31     ` Mickaël Salaün
2026-10-11 15:59       ` Nguyen Ngoc Thang
2026-10-11 16:16       ` Mickaël Salaün

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox