* [PATCH] sctp: avoid NULL pointer dereference in sctp_sf_violation
@ 2021-11-02 20:27 Alexey Khoroshilov
2021-11-03 12:43 ` Xin Long
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Khoroshilov @ 2021-11-02 20:27 UTC (permalink / raw)
To: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner, David S. Miller
Cc: Jakub Kicinski, Xin Long, linux-sctp, netdev, linux-kernel,
ldv-project, Alexey Khoroshilov
Some callers (e.g. sctp_sf_violation_chunk) passes NULL to
asoc argument of sctp_sf_violation. So, it should check it
before calling sctp_vtag_verify().
Probably it could be exploited by a malicious SCTP packet
to cause NULL pointer dereference.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Fixes: aa0f697e4528 ("sctp: add vtag check in sctp_sf_violation")
---
net/sctp/sm_statefuns.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index fb3da4d8f4a3..77f3cd6c516e 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -4669,7 +4669,7 @@ enum sctp_disposition sctp_sf_violation(struct net *net,
{
struct sctp_chunk *chunk = arg;
- if (!sctp_vtag_verify(chunk, asoc))
+ if (asoc && !sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
/* Make sure that the chunk has a valid length. */
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] sctp: avoid NULL pointer dereference in sctp_sf_violation
2021-11-02 20:27 [PATCH] sctp: avoid NULL pointer dereference in sctp_sf_violation Alexey Khoroshilov
@ 2021-11-03 12:43 ` Xin Long
2021-11-05 17:30 ` [PATCH] sctp: remove unreachable code from sctp_sf_violation_chunk() Alexey Khoroshilov
0 siblings, 1 reply; 4+ messages in thread
From: Xin Long @ 2021-11-03 12:43 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
David S. Miller, Jakub Kicinski,
linux-sctp @ vger . kernel . org, network dev, LKML, ldv-project
On Tue, Nov 2, 2021 at 4:27 PM Alexey Khoroshilov <khoroshilov@ispras.ru> wrote:
>
> Some callers (e.g. sctp_sf_violation_chunk) passes NULL to
> asoc argument of sctp_sf_violation. So, it should check it
> before calling sctp_vtag_verify().
>
> Probably it could be exploited by a malicious SCTP packet
> to cause NULL pointer dereference.
I don't think asoc can be NULL in here, did you see any call trace
caused by it?
If this was found by a tool, please remove the unnecessary call from
sctp_sf_violation_chunk() instead:
@@ -4893,9 +4893,6 @@ static enum sctp_disposition sctp_sf_violation_chunk(
{
static const char err_str[] = "The following chunk violates protocol:";
- if (!asoc)
- return sctp_sf_violation(net, ep, asoc, type, arg, commands);
-
Thanks.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> Fixes: aa0f697e4528 ("sctp: add vtag check in sctp_sf_violation")
> ---
> net/sctp/sm_statefuns.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index fb3da4d8f4a3..77f3cd6c516e 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -4669,7 +4669,7 @@ enum sctp_disposition sctp_sf_violation(struct net *net,
> {
> struct sctp_chunk *chunk = arg;
>
> - if (!sctp_vtag_verify(chunk, asoc))
> + if (asoc && !sctp_vtag_verify(chunk, asoc))
> return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
>
> /* Make sure that the chunk has a valid length. */
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] sctp: remove unreachable code from sctp_sf_violation_chunk()
2021-11-03 12:43 ` Xin Long
@ 2021-11-05 17:30 ` Alexey Khoroshilov
2021-11-07 19:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Khoroshilov @ 2021-11-05 17:30 UTC (permalink / raw)
To: Xin Long
Cc: Alexey Khoroshilov, Vlad Yasevich, Neil Horman,
Marcelo Ricardo Leitner, David S. Miller, linux-sctp, netdev,
linux-kernel, ldv-project
sctp_sf_violation_chunk() is not called with asoc argument equal to NULL,
but if that happens it would lead to NULL pointer dereference
in sctp_vtag_verify().
The patch removes code that handles NULL asoc in sctp_sf_violation_chunk().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Proposed-by: Xin Long <lucien.xin@gmail.com>
---
net/sctp/sm_statefuns.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index fb3da4d8f4a3..ec8561dd7e76 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -4893,9 +4893,6 @@ static enum sctp_disposition sctp_sf_violation_chunk(
{
static const char err_str[] = "The following chunk violates protocol:";
- if (!asoc)
- return sctp_sf_violation(net, ep, asoc, type, arg, commands);
-
return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str,
sizeof(err_str));
}
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] sctp: remove unreachable code from sctp_sf_violation_chunk()
2021-11-05 17:30 ` [PATCH] sctp: remove unreachable code from sctp_sf_violation_chunk() Alexey Khoroshilov
@ 2021-11-07 19:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-11-07 19:40 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: lucien.xin, vyasevich, nhorman, marcelo.leitner, davem,
linux-sctp, netdev, linux-kernel, ldv-project
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Fri, 5 Nov 2021 20:30:27 +0300 you wrote:
> sctp_sf_violation_chunk() is not called with asoc argument equal to NULL,
> but if that happens it would lead to NULL pointer dereference
> in sctp_vtag_verify().
>
> The patch removes code that handles NULL asoc in sctp_sf_violation_chunk().
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> [...]
Here is the summary with links:
- sctp: remove unreachable code from sctp_sf_violation_chunk()
https://git.kernel.org/netdev/net/c/e7ea51cd879c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-07 19:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 20:27 [PATCH] sctp: avoid NULL pointer dereference in sctp_sf_violation Alexey Khoroshilov
2021-11-03 12:43 ` Xin Long
2021-11-05 17:30 ` [PATCH] sctp: remove unreachable code from sctp_sf_violation_chunk() Alexey Khoroshilov
2021-11-07 19:40 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.