* [PATCH] nfsd: Move strlen declaration in nfsd4_encode_components_esc()
@ 2025-09-25 12:14 Nathan Chancellor
2025-09-25 13:43 ` Chuck Lever
0 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2025-09-25 12:14 UTC (permalink / raw)
To: Chuck Lever, Jeff Layton, Anna Schumaker
Cc: NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey, Simon Horman,
linux-nfs, patches, Nathan Chancellor
There is an error building nfs4xdr.c with CONFIG_SUNRPC_DEBUG_TRACE=y
and CONFIG_FORTIFY_SOURCE=n due to the local variable strlen conflicting
with the function strlen():
In file included from include/linux/cpumask.h:11,
from arch/x86/include/asm/paravirt.h:21,
from arch/x86/include/asm/irqflags.h:102,
from include/linux/irqflags.h:18,
from include/linux/spinlock.h:59,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/slab.h:16,
from fs/nfsd/nfs4xdr.c:37:
fs/nfsd/nfs4xdr.c: In function 'nfsd4_encode_components_esc':
include/linux/kernel.h:321:46: error: called object 'strlen' is not a function or function pointer
321 | __trace_puts(_THIS_IP_, str, strlen(str)); \
| ^~~~~~
include/linux/kernel.h:265:17: note: in expansion of macro 'trace_puts'
265 | trace_puts(fmt); \
| ^~~~~~~~~~
include/linux/sunrpc/debug.h:34:41: note: in expansion of macro 'trace_printk'
34 | # define __sunrpc_printk(fmt, ...) trace_printk(fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~~
include/linux/sunrpc/debug.h:42:17: note: in expansion of macro '__sunrpc_printk'
42 | __sunrpc_printk(fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~~~~~
include/linux/sunrpc/debug.h:25:9: note: in expansion of macro 'dfprintk'
25 | dfprintk(FACILITY, fmt, ##__VA_ARGS__)
| ^~~~~~~~
fs/nfsd/nfs4xdr.c:2646:9: note: in expansion of macro 'dprintk'
2646 | dprintk("nfsd4_encode_components(%s)\n", components);
| ^~~~~~~
fs/nfsd/nfs4xdr.c:2643:13: note: declared here
2643 | int strlen, count=0;
| ^~~~~~
Move the declaration of strlen into the while loop (as that is the only
place where it is used), which is after the call to dprintk, to clear up
the error.
Fixes: ec7d8e68ef0e ("sunrpc: add a Kconfig option to redirect dfprintk() output to trace buffer")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
This solution may be too subtle but given that dprintk() seems to be on
its way out, maybe it is fine. An alternative would be a rename such as
str_len but there is some symmetry with pathlen so I opted for this one
up front.
---
fs/nfsd/nfs4xdr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index ea91bad4eee2..580bfa8011c7 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2640,7 +2640,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
__be32 *p;
__be32 pathlen;
int pathlen_offset;
- int strlen, count=0;
+ int count=0;
char *str, *end, *next;
dprintk("nfsd4_encode_components(%s)\n", components);
@@ -2654,6 +2654,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
end = str = components;
while (*end) {
bool found_esc = false;
+ int strlen;
/* try to parse as esc_start, ..., esc_end, sep */
if (*str == esc_enter) {
---
base-commit: 3fadfaec904dffab02ebf63dd9c2ae8fa15c6d32
change-id: 20250925-nfsd-fix-trace-printk-strlen-error-2a24413eb186
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] nfsd: Move strlen declaration in nfsd4_encode_components_esc()
2025-09-25 12:14 [PATCH] nfsd: Move strlen declaration in nfsd4_encode_components_esc() Nathan Chancellor
@ 2025-09-25 13:43 ` Chuck Lever
2025-09-25 16:52 ` Jeff Layton
0 siblings, 1 reply; 6+ messages in thread
From: Chuck Lever @ 2025-09-25 13:43 UTC (permalink / raw)
To: Nathan Chancellor
Cc: NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey, Simon Horman,
linux-nfs, patches, Jeff Layton, Anna Schumaker
On 9/25/25 5:14 AM, Nathan Chancellor wrote:
> There is an error building nfs4xdr.c with CONFIG_SUNRPC_DEBUG_TRACE=y
> and CONFIG_FORTIFY_SOURCE=n due to the local variable strlen conflicting
> with the function strlen():
>
> In file included from include/linux/cpumask.h:11,
> from arch/x86/include/asm/paravirt.h:21,
> from arch/x86/include/asm/irqflags.h:102,
> from include/linux/irqflags.h:18,
> from include/linux/spinlock.h:59,
> from include/linux/mmzone.h:8,
> from include/linux/gfp.h:7,
> from include/linux/slab.h:16,
> from fs/nfsd/nfs4xdr.c:37:
> fs/nfsd/nfs4xdr.c: In function 'nfsd4_encode_components_esc':
> include/linux/kernel.h:321:46: error: called object 'strlen' is not a function or function pointer
> 321 | __trace_puts(_THIS_IP_, str, strlen(str)); \
> | ^~~~~~
> include/linux/kernel.h:265:17: note: in expansion of macro 'trace_puts'
> 265 | trace_puts(fmt); \
> | ^~~~~~~~~~
> include/linux/sunrpc/debug.h:34:41: note: in expansion of macro 'trace_printk'
> 34 | # define __sunrpc_printk(fmt, ...) trace_printk(fmt, ##__VA_ARGS__)
> | ^~~~~~~~~~~~
> include/linux/sunrpc/debug.h:42:17: note: in expansion of macro '__sunrpc_printk'
> 42 | __sunrpc_printk(fmt, ##__VA_ARGS__); \
> | ^~~~~~~~~~~~~~~
> include/linux/sunrpc/debug.h:25:9: note: in expansion of macro 'dfprintk'
> 25 | dfprintk(FACILITY, fmt, ##__VA_ARGS__)
> | ^~~~~~~~
> fs/nfsd/nfs4xdr.c:2646:9: note: in expansion of macro 'dprintk'
> 2646 | dprintk("nfsd4_encode_components(%s)\n", components);
> | ^~~~~~~
> fs/nfsd/nfs4xdr.c:2643:13: note: declared here
> 2643 | int strlen, count=0;
> | ^~~~~~
>
> Move the declaration of strlen into the while loop (as that is the only
> place where it is used), which is after the call to dprintk, to clear up
> the error.
>
> Fixes: ec7d8e68ef0e ("sunrpc: add a Kconfig option to redirect dfprintk() output to trace buffer")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> This solution may be too subtle but given that dprintk() seems to be on
> its way out, maybe it is fine. An alternative would be a rename such as
> str_len but there is some symmetry with pathlen so I opted for this one
> up front.
> ---
> fs/nfsd/nfs4xdr.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index ea91bad4eee2..580bfa8011c7 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -2640,7 +2640,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
> __be32 *p;
> __be32 pathlen;
> int pathlen_offset;
> - int strlen, count=0;
> + int count=0;
> char *str, *end, *next;
>
> dprintk("nfsd4_encode_components(%s)\n", components);
> @@ -2654,6 +2654,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
> end = str = components;
> while (*end) {
> bool found_esc = false;
> + int strlen;
>
> /* try to parse as esc_start, ..., esc_end, sep */
> if (*str == esc_enter) {
>
> ---
> base-commit: 3fadfaec904dffab02ebf63dd9c2ae8fa15c6d32
> change-id: 20250925-nfsd-fix-trace-printk-strlen-error-2a24413eb186
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
Would anyone be heartbroken if this patch removed the dprintk call site?
I think renaming the strlen variable to a name with a lower collision
risk would be sensible as well.
--
Chuck Lever
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] nfsd: Move strlen declaration in nfsd4_encode_components_esc()
2025-09-25 13:43 ` Chuck Lever
@ 2025-09-25 16:52 ` Jeff Layton
2025-09-25 20:32 ` Nathan Chancellor
0 siblings, 1 reply; 6+ messages in thread
From: Jeff Layton @ 2025-09-25 16:52 UTC (permalink / raw)
To: Chuck Lever, Nathan Chancellor
Cc: NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey, Simon Horman,
linux-nfs, patches, Anna Schumaker
On Thu, 2025-09-25 at 09:43 -0400, Chuck Lever wrote:
> On 9/25/25 5:14 AM, Nathan Chancellor wrote:
> > There is an error building nfs4xdr.c with CONFIG_SUNRPC_DEBUG_TRACE=y
> > and CONFIG_FORTIFY_SOURCE=n due to the local variable strlen conflicting
> > with the function strlen():
> >
> > In file included from include/linux/cpumask.h:11,
> > from arch/x86/include/asm/paravirt.h:21,
> > from arch/x86/include/asm/irqflags.h:102,
> > from include/linux/irqflags.h:18,
> > from include/linux/spinlock.h:59,
> > from include/linux/mmzone.h:8,
> > from include/linux/gfp.h:7,
> > from include/linux/slab.h:16,
> > from fs/nfsd/nfs4xdr.c:37:
> > fs/nfsd/nfs4xdr.c: In function 'nfsd4_encode_components_esc':
> > include/linux/kernel.h:321:46: error: called object 'strlen' is not a function or function pointer
> > 321 | __trace_puts(_THIS_IP_, str, strlen(str)); \
> > | ^~~~~~
> > include/linux/kernel.h:265:17: note: in expansion of macro 'trace_puts'
> > 265 | trace_puts(fmt); \
> > | ^~~~~~~~~~
> > include/linux/sunrpc/debug.h:34:41: note: in expansion of macro 'trace_printk'
> > 34 | # define __sunrpc_printk(fmt, ...) trace_printk(fmt, ##__VA_ARGS__)
> > | ^~~~~~~~~~~~
> > include/linux/sunrpc/debug.h:42:17: note: in expansion of macro '__sunrpc_printk'
> > 42 | __sunrpc_printk(fmt, ##__VA_ARGS__); \
> > | ^~~~~~~~~~~~~~~
> > include/linux/sunrpc/debug.h:25:9: note: in expansion of macro 'dfprintk'
> > 25 | dfprintk(FACILITY, fmt, ##__VA_ARGS__)
> > | ^~~~~~~~
> > fs/nfsd/nfs4xdr.c:2646:9: note: in expansion of macro 'dprintk'
> > 2646 | dprintk("nfsd4_encode_components(%s)\n", components);
> > | ^~~~~~~
> > fs/nfsd/nfs4xdr.c:2643:13: note: declared here
> > 2643 | int strlen, count=0;
> > | ^~~~~~
> >
> > Move the declaration of strlen into the while loop (as that is the only
> > place where it is used), which is after the call to dprintk, to clear up
> > the error.
> >
> > Fixes: ec7d8e68ef0e ("sunrpc: add a Kconfig option to redirect dfprintk() output to trace buffer")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > This solution may be too subtle but given that dprintk() seems to be on
> > its way out, maybe it is fine. An alternative would be a rename such as
> > str_len but there is some symmetry with pathlen so I opted for this one
> > up front.
> > ---
> > fs/nfsd/nfs4xdr.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> > index ea91bad4eee2..580bfa8011c7 100644
> > --- a/fs/nfsd/nfs4xdr.c
> > +++ b/fs/nfsd/nfs4xdr.c
> > @@ -2640,7 +2640,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
> > __be32 *p;
> > __be32 pathlen;
> > int pathlen_offset;
> > - int strlen, count=0;
> > + int count=0;
> > char *str, *end, *next;
> >
> > dprintk("nfsd4_encode_components(%s)\n", components);
> > @@ -2654,6 +2654,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep,
> > end = str = components;
> > while (*end) {
> > bool found_esc = false;
> > + int strlen;
> >
> > /* try to parse as esc_start, ..., esc_end, sep */
> > if (*str == esc_enter) {
> >
> > ---
> > base-commit: 3fadfaec904dffab02ebf63dd9c2ae8fa15c6d32
> > change-id: 20250925-nfsd-fix-trace-printk-strlen-error-2a24413eb186
> >
> > Best regards,
> > --
> > Nathan Chancellor <nathan@kernel.org>
> >
>
> Would anyone be heartbroken if this patch removed the dprintk call site?
>
> I think renaming the strlen variable to a name with a lower collision
> risk would be sensible as well.
>
Fine with me on both counts. No point in overloading a well known
function name here.
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] nfsd: Move strlen declaration in nfsd4_encode_components_esc()
2025-09-25 16:52 ` Jeff Layton
@ 2025-09-25 20:32 ` Nathan Chancellor
2025-09-26 13:13 ` Chuck Lever
0 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2025-09-25 20:32 UTC (permalink / raw)
To: Jeff Layton
Cc: Chuck Lever, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
Simon Horman, linux-nfs, patches, Anna Schumaker
On Thu, Sep 25, 2025 at 12:52:10PM -0400, Jeff Layton wrote:
> On Thu, 2025-09-25 at 09:43 -0400, Chuck Lever wrote:
> > Would anyone be heartbroken if this patch removed the dprintk call site?
Yeah, I had figured this print may be low value and worth removing as a
fix.
> > I think renaming the strlen variable to a name with a lower collision
> > risk would be sensible as well.
> >
>
> Fine with me on both counts. No point in overloading a well known
> function name here.
Agreed. Should I send a patch or does someone else want to?
Cheers,
Nathan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nfsd: Move strlen declaration in nfsd4_encode_components_esc()
2025-09-25 20:32 ` Nathan Chancellor
@ 2025-09-26 13:13 ` Chuck Lever
2025-09-28 19:22 ` Nathan Chancellor
0 siblings, 1 reply; 6+ messages in thread
From: Chuck Lever @ 2025-09-26 13:13 UTC (permalink / raw)
To: Nathan Chancellor, Jeff Layton
Cc: NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey, Simon Horman,
linux-nfs, patches, Anna Schumaker
On 9/25/25 1:32 PM, Nathan Chancellor wrote:
> On Thu, Sep 25, 2025 at 12:52:10PM -0400, Jeff Layton wrote:
>> On Thu, 2025-09-25 at 09:43 -0400, Chuck Lever wrote:
>>> Would anyone be heartbroken if this patch removed the dprintk call site?
>
> Yeah, I had figured this print may be low value and worth removing as a
> fix.
>
>>> I think renaming the strlen variable to a name with a lower collision
>>> risk would be sensible as well.
>>>
>>
>> Fine with me on both counts. No point in overloading a well known
>> function name here.
>
> Agreed. Should I send a patch or does someone else want to?
I was hoping that the modifications I requested would be
straightforward enough that it would take you only a few minutes
to resend. If it's going to be more difficult than that, I can take
it from here.
--
Chuck Lever
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nfsd: Move strlen declaration in nfsd4_encode_components_esc()
2025-09-26 13:13 ` Chuck Lever
@ 2025-09-28 19:22 ` Nathan Chancellor
0 siblings, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2025-09-28 19:22 UTC (permalink / raw)
To: Chuck Lever
Cc: Jeff Layton, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
Simon Horman, linux-nfs, patches, Anna Schumaker
On Fri, Sep 26, 2025 at 09:13:59AM -0400, Chuck Lever wrote:
> I was hoping that the modifications I requested would be
> straightforward enough that it would take you only a few minutes
> to resend. If it's going to be more difficult than that, I can take
> it from here.
Yeah, it was no problem at all, it was more about finding those few
minutes :) I have sent an updated patch that will hopefully be
acceptable:
https://lore.kernel.org/20250928-nfsd-fix-trace-printk-strlen-error-v2-1-108def6ff41c@kernel.org/
Cheers,
Nathan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-28 19:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-25 12:14 [PATCH] nfsd: Move strlen declaration in nfsd4_encode_components_esc() Nathan Chancellor
2025-09-25 13:43 ` Chuck Lever
2025-09-25 16:52 ` Jeff Layton
2025-09-25 20:32 ` Nathan Chancellor
2025-09-26 13:13 ` Chuck Lever
2025-09-28 19:22 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).