* [PATCH] apparmor: use the condition in AA_BUG_FMT even with debug disabled
@ 2025-01-27 20:54 Mateusz Guzik
2025-01-27 20:59 ` Ryan Lee
2025-01-29 11:46 ` John Johansen
0 siblings, 2 replies; 4+ messages in thread
From: Mateusz Guzik @ 2025-01-27 20:54 UTC (permalink / raw)
To: john.johansen
Cc: paul, linux-kernel, apparmor, linux-security-module, Mateusz Guzik
This follows the established practice and fixes a build failure for me:
security/apparmor/file.c: In function ‘__file_sock_perm’:
security/apparmor/file.c:544:24: error: unused variable ‘sock’ [-Werror=unused-variable]
544 | struct socket *sock = (struct socket *) file->private_data;
| ^~~~
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
Plausibly the sock var wants to be eliminated altogether, but I just
want this to build.
security/apparmor/include/lib.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
index 256f4577c653..d947998262b2 100644
--- a/security/apparmor/include/lib.h
+++ b/security/apparmor/include/lib.h
@@ -60,7 +60,11 @@ do { \
#define AA_BUG_FMT(X, fmt, args...) \
WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)
#else
-#define AA_BUG_FMT(X, fmt, args...) no_printk(fmt, ##args)
+#define AA_BUG_FMT(X, fmt, args...) \
+ do { \
+ BUILD_BUG_ON_INVALID(X); \
+ no_printk(fmt, ##args); \
+ } while (0)
#endif
int aa_parse_debug_params(const char *str);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] apparmor: use the condition in AA_BUG_FMT even with debug disabled
2025-01-27 20:54 [PATCH] apparmor: use the condition in AA_BUG_FMT even with debug disabled Mateusz Guzik
@ 2025-01-27 20:59 ` Ryan Lee
2025-01-27 21:07 ` Mateusz Guzik
2025-01-29 11:46 ` John Johansen
1 sibling, 1 reply; 4+ messages in thread
From: Ryan Lee @ 2025-01-27 20:59 UTC (permalink / raw)
To: Mateusz Guzik
Cc: john.johansen, paul, linux-kernel, apparmor, linux-security-module
For the record, a previous patch that removes the sock variable was
previously accepted:
https://lists.ubuntu.com/archives/apparmor/2025-January/013449.html
(patch) and https://lists.ubuntu.com/archives/apparmor/2025-January/013463.html
(ack from John Johansen)
On Mon, Jan 27, 2025 at 12:54 PM Mateusz Guzik <mjguzik@gmail.com> wrote:
>
> This follows the established practice and fixes a build failure for me:
> security/apparmor/file.c: In function ‘__file_sock_perm’:
> security/apparmor/file.c:544:24: error: unused variable ‘sock’ [-Werror=unused-variable]
> 544 | struct socket *sock = (struct socket *) file->private_data;
> | ^~~~
>
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
> ---
>
> Plausibly the sock var wants to be eliminated altogether, but I just
> want this to build.
>
> security/apparmor/include/lib.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
> index 256f4577c653..d947998262b2 100644
> --- a/security/apparmor/include/lib.h
> +++ b/security/apparmor/include/lib.h
> @@ -60,7 +60,11 @@ do { \
> #define AA_BUG_FMT(X, fmt, args...) \
> WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)
> #else
> -#define AA_BUG_FMT(X, fmt, args...) no_printk(fmt, ##args)
> +#define AA_BUG_FMT(X, fmt, args...) \
> + do { \
> + BUILD_BUG_ON_INVALID(X); \
> + no_printk(fmt, ##args); \
> + } while (0)
> #endif
>
> int aa_parse_debug_params(const char *str);
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] apparmor: use the condition in AA_BUG_FMT even with debug disabled
2025-01-27 20:59 ` Ryan Lee
@ 2025-01-27 21:07 ` Mateusz Guzik
0 siblings, 0 replies; 4+ messages in thread
From: Mateusz Guzik @ 2025-01-27 21:07 UTC (permalink / raw)
To: Ryan Lee
Cc: john.johansen, paul, linux-kernel, apparmor, linux-security-module
On Mon, Jan 27, 2025 at 9:59 PM Ryan Lee <ryan.lee@canonical.com> wrote:
>
> For the record, a previous patch that removes the sock variable was
> previously accepted:
> https://lists.ubuntu.com/archives/apparmor/2025-January/013449.html
> (patch) and https://lists.ubuntu.com/archives/apparmor/2025-January/013463.html
> (ack from John Johansen)
>
That makes sense, but imo the posted patch is still warranted -- all
other debug macros (WARN_ON, VM_WARN_ON etc.) are expected to evaluate
the condition.
--
Mateusz Guzik <mjguzik gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] apparmor: use the condition in AA_BUG_FMT even with debug disabled
2025-01-27 20:54 [PATCH] apparmor: use the condition in AA_BUG_FMT even with debug disabled Mateusz Guzik
2025-01-27 20:59 ` Ryan Lee
@ 2025-01-29 11:46 ` John Johansen
1 sibling, 0 replies; 4+ messages in thread
From: John Johansen @ 2025-01-29 11:46 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: paul, linux-kernel, apparmor, linux-security-module
On 1/27/25 12:54, Mateusz Guzik wrote:
> This follows the established practice and fixes a build failure for me:
> security/apparmor/file.c: In function ‘__file_sock_perm’:
> security/apparmor/file.c:544:24: error: unused variable ‘sock’ [-Werror=unused-variable]
> 544 | struct socket *sock = (struct socket *) file->private_data;
> | ^~~~
>
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Acked-by: John Johansen <john.johansen@canonical.com>
thanks, I have pulled this into my tree
> ---
>
> Plausibly the sock var wants to be eliminated altogether, but I just
> want this to build.
>
> security/apparmor/include/lib.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
> index 256f4577c653..d947998262b2 100644
> --- a/security/apparmor/include/lib.h
> +++ b/security/apparmor/include/lib.h
> @@ -60,7 +60,11 @@ do { \
> #define AA_BUG_FMT(X, fmt, args...) \
> WARN((X), "AppArmor WARN %s: (" #X "): " fmt, __func__, ##args)
> #else
> -#define AA_BUG_FMT(X, fmt, args...) no_printk(fmt, ##args)
> +#define AA_BUG_FMT(X, fmt, args...) \
> + do { \
> + BUILD_BUG_ON_INVALID(X); \
> + no_printk(fmt, ##args); \
> + } while (0)
> #endif
>
> int aa_parse_debug_params(const char *str);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-29 11:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-27 20:54 [PATCH] apparmor: use the condition in AA_BUG_FMT even with debug disabled Mateusz Guzik
2025-01-27 20:59 ` Ryan Lee
2025-01-27 21:07 ` Mateusz Guzik
2025-01-29 11:46 ` John Johansen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®