* [PATCH] net: benet: use snprintf instead sprintf and IFNAMSIZ instead hardcoded constant.
@ 2022-10-04 9:50 Peter Kosyh
2022-10-04 15:29 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Peter Kosyh @ 2022-10-04 9:50 UTC (permalink / raw)
To: Ajit Khaparde
Cc: Peter Kosyh, Sriharsha Basavapatna, Somnath Kotur,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel, lvc-project
printf to array 'eqo->desc' of size 32 may cause buffer overflow when
using non-standard IFNAMSIZ.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
---
drivers/net/ethernet/emulex/benet/be.h | 2 +-
drivers/net/ethernet/emulex/benet/be_main.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 61fe9625bed1..857a25f45fc8 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -179,7 +179,7 @@ static inline void queue_tail_inc(struct be_queue_info *q)
struct be_eq_obj {
struct be_queue_info q;
- char desc[32];
+ char desc[IFNAMSIZ+16];
struct be_adapter *adapter;
struct napi_struct napi;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 414362febbb9..8e75a14da595 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -3485,7 +3485,7 @@ static int be_msix_register(struct be_adapter *adapter)
int status, i, vec;
for_all_evt_queues(adapter, eqo, i) {
- sprintf(eqo->desc, "%s-q%d", netdev->name, i);
+ snprintf(eqo->desc, sizeof(eqo->desc), "%s-q%d", netdev->name, i);
vec = be_msix_vec_get(adapter, eqo);
status = request_irq(vec, be_msix, 0, eqo->desc, eqo);
if (status)
--
2.37.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: benet: use snprintf instead sprintf and IFNAMSIZ instead hardcoded constant.
2022-10-04 9:50 [PATCH] net: benet: use snprintf instead sprintf and IFNAMSIZ instead hardcoded constant Peter Kosyh
@ 2022-10-04 15:29 ` Stephen Hemminger
2022-10-05 0:30 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2022-10-04 15:29 UTC (permalink / raw)
To: Peter Kosyh
Cc: Ajit Khaparde, Sriharsha Basavapatna, Somnath Kotur,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel, lvc-project
On Tue, 4 Oct 2022 12:50:34 +0300
Peter Kosyh <pkosyh@yandex.ru> wrote:
> printf to array 'eqo->desc' of size 32 may cause buffer overflow when
> using non-standard IFNAMSIZ.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
NACK
Non-standard IFNAMSIZ will break uapi and many things.
I see no reason for kernel or tools like iproute2 to support or
fix those related bugs.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: benet: use snprintf instead sprintf and IFNAMSIZ instead hardcoded constant.
2022-10-04 15:29 ` Stephen Hemminger
@ 2022-10-05 0:30 ` Jakub Kicinski
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2022-10-05 0:30 UTC (permalink / raw)
To: Stephen Hemminger, Peter Kosyh
Cc: Ajit Khaparde, Sriharsha Basavapatna, Somnath Kotur,
David S. Miller, Eric Dumazet, Paolo Abeni, netdev, linux-kernel,
lvc-project
On Tue, 4 Oct 2022 08:29:36 -0700 Stephen Hemminger wrote:
> On Tue, 4 Oct 2022 12:50:34 +0300
> Peter Kosyh <pkosyh@yandex.ru> wrote:
>
> > printf to array 'eqo->desc' of size 32 may cause buffer overflow when
> > using non-standard IFNAMSIZ.
> >
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
> >
> > Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
>
> NACK
> Non-standard IFNAMSIZ will break uapi and many things.
> I see no reason for kernel or tools like iproute2 to support or
> fix those related bugs.
I think the commit message is missing the point, but the warning
may be legit.
Pater please read the requirements for sending patches based on
automated checkers:
Documentation/process/researcher-guidelines.rst
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-05 0:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-04 9:50 [PATCH] net: benet: use snprintf instead sprintf and IFNAMSIZ instead hardcoded constant Peter Kosyh
2022-10-04 15:29 ` Stephen Hemminger
2022-10-05 0:30 ` Jakub Kicinski
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).