* [PATCH v1 1/1] genirq: Bump the size of the local variable for sprintf()
@ 2025-05-15 8:55 Andy Shevchenko
2025-05-15 14:33 ` [tip: irq/core] " tip-bot2 for Andy Shevchenko
2025-05-16 4:45 ` [PATCH v1 1/1] " Jiri Slaby
0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-05-15 8:55 UTC (permalink / raw)
To: Thomas Gleixner, linux-kernel; +Cc: Andy Shevchenko, kernel test robot
GCC is not happy about sprintf() call on a buffer that might be too small for
the given formatting string.
kernel/irq/debugfs.c:233:26: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
Fix this by bumping the size of the local variable for sprintf().
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202505151057.xbyXAbEn-lkp@intel.com/
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/irq/debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index 3d6a5b3cfaf3..3527defd2890 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -225,7 +225,7 @@ void irq_debugfs_copy_devname(int irq, struct device *dev)
void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
{
- char name [10];
+ char name [12];
if (!irq_dir || !desc || desc->debugfs_file)
return;
--
2.47.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [tip: irq/core] genirq: Bump the size of the local variable for sprintf()
2025-05-15 8:55 [PATCH v1 1/1] genirq: Bump the size of the local variable for sprintf() Andy Shevchenko
@ 2025-05-15 14:33 ` tip-bot2 for Andy Shevchenko
2025-05-16 4:45 ` [PATCH v1 1/1] " Jiri Slaby
1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Andy Shevchenko @ 2025-05-15 14:33 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Andy Shevchenko, Thomas Gleixner, x86,
linux-kernel, maz
The following commit has been merged into the irq/core branch of tip:
Commit-ID: a4a39c81e1043b153bde3ef5cb3cf94222ffd918
Gitweb: https://git.kernel.org/tip/a4a39c81e1043b153bde3ef5cb3cf94222ffd918
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Thu, 15 May 2025 11:55:16 +03:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 15 May 2025 16:28:09 +02:00
genirq: Bump the size of the local variable for sprintf()
GCC is not happy about a sprintf() call on a buffer that might be too small
for the given formatting string.
kernel/irq/debugfs.c:233:26: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
Fix this by bumping the size of the local variable for sprintf().
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250515085516.2913290-1-andriy.shevchenko@linux.intel.com
Closes: https://lore.kernel.org/oe-kbuild-all/202505151057.xbyXAbEn-lkp@intel.com/
---
kernel/irq/debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index 3d6a5b3..3527def 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -225,7 +225,7 @@ void irq_debugfs_copy_devname(int irq, struct device *dev)
void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
{
- char name [10];
+ char name [12];
if (!irq_dir || !desc || desc->debugfs_file)
return;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] genirq: Bump the size of the local variable for sprintf()
2025-05-15 8:55 [PATCH v1 1/1] genirq: Bump the size of the local variable for sprintf() Andy Shevchenko
2025-05-15 14:33 ` [tip: irq/core] " tip-bot2 for Andy Shevchenko
@ 2025-05-16 4:45 ` Jiri Slaby
2025-05-16 9:07 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2025-05-16 4:45 UTC (permalink / raw)
To: Andy Shevchenko, Thomas Gleixner, linux-kernel; +Cc: kernel test robot
On 15. 05. 25, 10:55, Andy Shevchenko wrote:
> GCC is not happy about sprintf() call on a buffer that might be too small for
> the given formatting string.
>
> kernel/irq/debugfs.c:233:26: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
>
> Fix this by bumping the size of the local variable for sprintf().
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202505151057.xbyXAbEn-lkp@intel.com/
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> kernel/irq/debugfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
> index 3d6a5b3cfaf3..3527defd2890 100644
> --- a/kernel/irq/debugfs.c
> +++ b/kernel/irq/debugfs.c
> @@ -225,7 +225,7 @@ void irq_debugfs_copy_devname(int irq, struct device *dev)
>
> void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
> {
> - char name [10];
> + char name [12];
The max irq is ~ 512000, if I am counting correctly, so 7 B should be
actually enough for everybody ;).
But well, can we silence the warning in a better way? I doubt that...
>
> if (!irq_dir || !desc || desc->debugfs_file)
> return;
--
js
suse labs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] genirq: Bump the size of the local variable for sprintf()
2025-05-16 4:45 ` [PATCH v1 1/1] " Jiri Slaby
@ 2025-05-16 9:07 ` Andy Shevchenko
2025-05-16 10:23 ` Jiri Slaby
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-05-16 9:07 UTC (permalink / raw)
To: Jiri Slaby; +Cc: Thomas Gleixner, linux-kernel, kernel test robot
On Fri, May 16, 2025 at 06:45:04AM +0200, Jiri Slaby wrote:
> On 15. 05. 25, 10:55, Andy Shevchenko wrote:
...
> > - char name [10];
> > + char name [12];
>
> The max irq is ~ 512000, if I am counting correctly, so 7 B should be
> actually enough for everybody ;).
GCC can't proved it. And FWIW, on current Debian unstable (GCC 14?) I can't
reproduce this. In any case this doesn't increase stack usage AFAICT, the array
already have reserved 12 or 16 bytes.
> But well, can we silence the warning in a better way? I doubt that...
With the above said, I think it's pretty much close to the best way.
But if you find anything better, I also would like to learn.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] genirq: Bump the size of the local variable for sprintf()
2025-05-16 9:07 ` Andy Shevchenko
@ 2025-05-16 10:23 ` Jiri Slaby
2025-05-17 16:35 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2025-05-16 10:23 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Thomas Gleixner, linux-kernel, kernel test robot
On 16. 05. 25, 11:07, Andy Shevchenko wrote:
> On Fri, May 16, 2025 at 06:45:04AM +0200, Jiri Slaby wrote:
>> On 15. 05. 25, 10:55, Andy Shevchenko wrote:
>
> ...
>
>>> - char name [10];
>>> + char name [12];
>>
>> The max irq is ~ 512000, if I am counting correctly, so 7 B should be
>> actually enough for everybody ;).
>
> GCC can't proved it. And FWIW, on current Debian unstable (GCC 14?) I can't
> reproduce this. In any case this doesn't increase stack usage AFAICT, the array
> already have reserved 12 or 16 bytes.
Yes, sure, I am not disputing the fix.
>> But well, can we silence the warning in a better way? I doubt that...
>
> With the above said, I think it's pretty much close to the best way.
> But if you find anything better, I also would like to learn.
Perhaps next in row would be using snprintf(), but dunno if it's better
at all.
--
js
suse labs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] genirq: Bump the size of the local variable for sprintf()
2025-05-16 10:23 ` Jiri Slaby
@ 2025-05-17 16:35 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-05-17 16:35 UTC (permalink / raw)
To: Jiri Slaby; +Cc: Thomas Gleixner, linux-kernel, kernel test robot
On Fri, May 16, 2025 at 12:23:17PM +0200, Jiri Slaby wrote:
> On 16. 05. 25, 11:07, Andy Shevchenko wrote:
> > On Fri, May 16, 2025 at 06:45:04AM +0200, Jiri Slaby wrote:
> > > On 15. 05. 25, 10:55, Andy Shevchenko wrote:
...
> > > > - char name [10];
> > > > + char name [12];
> > >
> > > The max irq is ~ 512000, if I am counting correctly, so 7 B should be
> > > actually enough for everybody ;).
> >
> > GCC can't proved it. And FWIW, on current Debian unstable (GCC 14?) I can't
> > reproduce this. In any case this doesn't increase stack usage AFAICT, the array
> > already have reserved 12 or 16 bytes.
>
> Yes, sure, I am not disputing the fix.
>
> > > But well, can we silence the warning in a better way? I doubt that...
> >
> > With the above said, I think it's pretty much close to the best way.
> > But if you find anything better, I also would like to learn.
>
> Perhaps next in row would be using snprintf(), but dunno if it's better at
> all.
Try it. I believe you will get the same result. The problem is not in 'n' or
'n'-less variant, the problem is that GCC can't prove the limits of the input
value.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-17 16:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15 8:55 [PATCH v1 1/1] genirq: Bump the size of the local variable for sprintf() Andy Shevchenko
2025-05-15 14:33 ` [tip: irq/core] " tip-bot2 for Andy Shevchenko
2025-05-16 4:45 ` [PATCH v1 1/1] " Jiri Slaby
2025-05-16 9:07 ` Andy Shevchenko
2025-05-16 10:23 ` Jiri Slaby
2025-05-17 16:35 ` Andy Shevchenko
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).