linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] SCSI: fusion: mpi_ioc.h: Replace one-element array with flexible-array member
@ 2021-03-24 23:00 Gustavo A. R. Silva
  2021-04-06  4:53 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2021-03-24 23:00 UTC (permalink / raw)
  To: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani
  Cc: MPT-FusionLinux.pdl, linux-scsi, linux-kernel,
	Gustavo A. R. Silva, linux-hardening

There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].

Also, this helps with the ongoing efforts to enable -Warray-bounds by
fixing the following warning:

drivers/message/fusion/mptbase.c: In function ‘mptbase_reply’:
drivers/message/fusion/mptbase.c:7747:62: warning: array subscript 1 is above array bounds of ‘U32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
 7747 |     ioc->events[idx].data[ii] = le32_to_cpu(pEventReply->Data[ii]);
./include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro ‘__le32_to_cpu’
   34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
      |                                                   ^
drivers/message/fusion/mptbase.c:7747:33: note: in expansion of macro ‘le32_to_cpu’
 7747 |     ioc->events[idx].data[ii] = le32_to_cpu(pEventReply->Data[ii]);
      | 

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/message/fusion/lsi/mpi_ioc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/message/fusion/lsi/mpi_ioc.h b/drivers/message/fusion/lsi/mpi_ioc.h
index c249f2994fc1..1534460fd5b1 100644
--- a/drivers/message/fusion/lsi/mpi_ioc.h
+++ b/drivers/message/fusion/lsi/mpi_ioc.h
@@ -448,7 +448,7 @@ typedef struct _MSG_EVENT_NOTIFY_REPLY
      U32                    IOCLogInfo;                 /* 10h */
      U32                    Event;                      /* 14h */
      U32                    EventContext;               /* 18h */
-     U32                    Data[1];                    /* 1Ch */
+     U32                    Data[];			/* 1Ch */
 } MSG_EVENT_NOTIFY_REPLY, MPI_POINTER PTR_MSG_EVENT_NOTIFY_REPLY,
   EventNotificationReply_t, MPI_POINTER pEventNotificationReply_t;
 
-- 
2.27.0


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

* Re: [PATCH][next] SCSI: fusion: mpi_ioc.h: Replace one-element array with flexible-array member
  2021-03-24 23:00 [PATCH][next] SCSI: fusion: mpi_ioc.h: Replace one-element array with flexible-array member Gustavo A. R. Silva
@ 2021-04-06  4:53 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-04-06  4:53 UTC (permalink / raw)
  To: Suganath Prabu Subramani, Sathya Prakash, Gustavo A. R. Silva,
	Sreekanth Reddy
  Cc: Martin K . Petersen, linux-scsi, linux-kernel, linux-hardening,
	MPT-FusionLinux.pdl

On Wed, 24 Mar 2021 18:00:36 -0500, Gustavo A. R. Silva wrote:

> There is a regular need in the kernel to provide a way to declare having
> a dynamically sized set of trailing elements in a structure. Kernel code
> should always use “flexible array members”[1] for these cases. The older
> style of one-element or zero-length arrays should no longer be used[2].
> 
> Also, this helps with the ongoing efforts to enable -Warray-bounds by
> fixing the following warning:
> 
> [...]

Applied to 5.13/scsi-queue, thanks!

[1/1] SCSI: fusion: mpi_ioc.h: Replace one-element array with flexible-array member
      https://git.kernel.org/mkp/scsi/c/ed46ccc7fe76

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2021-04-06  4:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 23:00 [PATCH][next] SCSI: fusion: mpi_ioc.h: Replace one-element array with flexible-array member Gustavo A. R. Silva
2021-04-06  4:53 ` Martin K. Petersen

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).