linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sctp: Fix COMM_LOST/CANT_STR_ASSOC err reporting on big-endian platforms
@ 2020-10-30 13:26 Petr Malat
  2020-11-02 13:27 ` Marcelo Ricardo Leitner
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Malat @ 2020-10-30 13:26 UTC (permalink / raw)
  To: linux-sctp
  Cc: Petr Malat, Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S. Miller, Jakub Kicinski, netdev, linux-kernel

Commit 978aa0474115 ("sctp: fix some type cast warnings introduced since
very beginning")' broke err reading from sctp_arg, because it reads the
value as 32-bit integer, although the value is stored as 16-bit integer.
Later this value is passed to the userspace in 16-bit variable, thus the
user always gets 0 on big-endian platforms. Fix it by reading the __u16
field of sctp_arg union, as reading err field would produce a sparse
warning.

Signed-off-by: Petr Malat <oss@malat.biz>
---
 net/sctp/sm_sideeffect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index aa821e71f05e..813d30767204 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -1601,12 +1601,12 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type,
 			break;
 
 		case SCTP_CMD_INIT_FAILED:
-			sctp_cmd_init_failed(commands, asoc, cmd->obj.u32);
+			sctp_cmd_init_failed(commands, asoc, cmd->obj.u16);
 			break;
 
 		case SCTP_CMD_ASSOC_FAILED:
 			sctp_cmd_assoc_failed(commands, asoc, event_type,
-					      subtype, chunk, cmd->obj.u32);
+					      subtype, chunk, cmd->obj.u16);
 			break;
 
 		case SCTP_CMD_INIT_COUNTER_INC:
-- 
2.20.1


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

* Re: [PATCH] sctp: Fix COMM_LOST/CANT_STR_ASSOC err reporting on big-endian platforms
  2020-10-30 13:26 [PATCH] sctp: Fix COMM_LOST/CANT_STR_ASSOC err reporting on big-endian platforms Petr Malat
@ 2020-11-02 13:27 ` Marcelo Ricardo Leitner
  2020-11-02 23:05   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-11-02 13:27 UTC (permalink / raw)
  To: Petr Malat
  Cc: linux-sctp, Vlad Yasevich, Neil Horman, David S. Miller,
	Jakub Kicinski, netdev, linux-kernel

On Fri, Oct 30, 2020 at 02:26:33PM +0100, Petr Malat wrote:
> Commit 978aa0474115 ("sctp: fix some type cast warnings introduced since
> very beginning")' broke err reading from sctp_arg, because it reads the
> value as 32-bit integer, although the value is stored as 16-bit integer.
> Later this value is passed to the userspace in 16-bit variable, thus the
> user always gets 0 on big-endian platforms. Fix it by reading the __u16
> field of sctp_arg union, as reading err field would produce a sparse
> warning.

Makes sense.

> 
> Signed-off-by: Petr Malat <oss@malat.biz>

Then, it also needs:
Fixes: 978aa0474115 ("sctp: fix some type cast warnings introduced since very beginning")'

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
(If the maintainers can't add the Fixes tag above, please keep the ack
on the v2)

Thanks.

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

* Re: [PATCH] sctp: Fix COMM_LOST/CANT_STR_ASSOC err reporting on big-endian platforms
  2020-11-02 13:27 ` Marcelo Ricardo Leitner
@ 2020-11-02 23:05   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2020-11-02 23:05 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: Petr Malat, linux-sctp, Vlad Yasevich, Neil Horman,
	David S. Miller, netdev, linux-kernel

On Mon, 2 Nov 2020 10:27:17 -0300 Marcelo Ricardo Leitner wrote:
> On Fri, Oct 30, 2020 at 02:26:33PM +0100, Petr Malat wrote:
> > Commit 978aa0474115 ("sctp: fix some type cast warnings introduced since
> > very beginning")' broke err reading from sctp_arg, because it reads the
> > value as 32-bit integer, although the value is stored as 16-bit integer.
> > Later this value is passed to the userspace in 16-bit variable, thus the
> > user always gets 0 on big-endian platforms. Fix it by reading the __u16
> > field of sctp_arg union, as reading err field would produce a sparse
> > warning.  
> 
> Makes sense.
> 
> > 
> > Signed-off-by: Petr Malat <oss@malat.biz>  
> 
> Then, it also needs:
> Fixes: 978aa0474115 ("sctp: fix some type cast warnings introduced since very beginning")'
> 
> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> (If the maintainers can't add the Fixes tag above, please keep the ack
> on the v2)

Applied, thanks!

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

end of thread, other threads:[~2020-11-02 23:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30 13:26 [PATCH] sctp: Fix COMM_LOST/CANT_STR_ASSOC err reporting on big-endian platforms Petr Malat
2020-11-02 13:27 ` Marcelo Ricardo Leitner
2020-11-02 23:05   ` 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).