[PATCH][next] sctp: Fix out-of-bounds warning in sctp_process_asconf_param()

Subsystems: networking [general], sctp protocol, the rest

STALE1971d

4 messages, 4 authors, 2021-04-16 · open the first message on its own page

[PATCH][next] sctp: Fix out-of-bounds warning in sctp_process_asconf_param()

From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Date: 2021-04-16 19:12:33

Fix the following out-of-bounds warning:

net/sctp/sm_make_chunk.c:3150:4: warning: 'memcpy' offset [17, 28] from the object at 'addr' is out of the bounds of referenced subobject 'v4' with type 'struct sockaddr_in' at offset 0 [-Warray-bounds]

This helps with the ongoing efforts to globally enable -Warray-bounds
and get us closer to being able to tighten the FORTIFY_SOURCE routines
on memcpy().

Link: https://github.com/KSPP/linux/issues/109
Reported-by: kernel test robot <redacted>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 net/sctp/sm_make_chunk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 54e6a708d06e..5f9a7c028274 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -3147,7 +3147,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
 		 * primary.
 		 */
 		if (af->is_any(&addr))
-			memcpy(&addr.v4, sctp_source(asconf), sizeof(addr));
+			memcpy(&addr, sctp_source(asconf), sizeof(addr));
 
 		if (security_sctp_bind_connect(asoc->ep->base.sk,
 					       SCTP_PARAM_SET_PRIMARY,
-- 
2.27.0

Re: [PATCH][next] sctp: Fix out-of-bounds warning in sctp_process_asconf_param()

From: Kees Cook <hidden>
Date: 2021-04-16 19:53:58

On Fri, Apr 16, 2021 at 02:12:36PM -0500, Gustavo A. R. Silva wrote:
Fix the following out-of-bounds warning:

net/sctp/sm_make_chunk.c:3150:4: warning: 'memcpy' offset [17, 28] from the object at 'addr' is out of the bounds of referenced subobject 'v4' with type 'struct sockaddr_in' at offset 0 [-Warray-bounds]

This helps with the ongoing efforts to globally enable -Warray-bounds
and get us closer to being able to tighten the FORTIFY_SOURCE routines
on memcpy().

Link: https://github.com/KSPP/linux/issues/109
Reported-by: kernel test robot <redacted>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Yup!

Reviewed-by: Kees Cook <redacted>

-- 
Kees Cook

Re: [PATCH][next] sctp: Fix out-of-bounds warning in sctp_process_asconf_param()

From: Gustavo A. R. Silva <hidden>
Date: 2021-04-16 20:16:31


On 4/16/21 14:53, Kees Cook wrote:
On Fri, Apr 16, 2021 at 02:12:36PM -0500, Gustavo A. R. Silva wrote:
quoted
Fix the following out-of-bounds warning:

net/sctp/sm_make_chunk.c:3150:4: warning: 'memcpy' offset [17, 28] from the object at 'addr' is out of the bounds of referenced subobject 'v4' with type 'struct sockaddr_in' at offset 0 [-Warray-bounds]

This helps with the ongoing efforts to globally enable -Warray-bounds
and get us closer to being able to tighten the FORTIFY_SOURCE routines
on memcpy().

Link: https://github.com/KSPP/linux/issues/109
Reported-by: kernel test robot <redacted>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Yup!
:)
Reviewed-by: Kees Cook <redacted>
Thanks, Kees.

--
Gustavo

Re: [PATCH][next] sctp: Fix out-of-bounds warning in sctp_process_asconf_param()

From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Date: 2021-04-16 21:12:47

On Fri, Apr 16, 2021 at 02:12:36PM -0500, Gustavo A. R. Silva wrote:
Fix the following out-of-bounds warning:

net/sctp/sm_make_chunk.c:3150:4: warning: 'memcpy' offset [17, 28] from the object at 'addr' is out of the bounds of referenced subobject 'v4' with type 'struct sockaddr_in' at offset 0 [-Warray-bounds]

This helps with the ongoing efforts to globally enable -Warray-bounds
and get us closer to being able to tighten the FORTIFY_SOURCE routines
on memcpy().

Link: https://github.com/KSPP/linux/issues/109
Reported-by: kernel test robot <redacted>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help