Archive-only list for patches
 help / color / mirror / Atom feed
From: <gregkh@linuxfoundation.org>
To: davem@davemloft.net,edumazet@google.com,gregkh@linuxfoundation.org,jhs@mojatatu.com,jiri@resnulli.us,nmanthey@amazon.de,patches@lists.linux.dev,ptyadav@amazon.de,syzkaller@googlegroups.com,vladbu@mellanox.com,xiyou.wangcong@gmail.com,zsm@google.com
Cc: <stable-commits@vger.kernel.org>
Subject: Patch "net_sched: prevent NULL dereference if default qdisc setup failed" has been added to the 5.4-stable tree
Date: Tue, 11 Apr 2023 15:14:16 +0200	[thread overview]
Message-ID: <2023041116-sessions-storable-e8dd@gregkh> (raw)
In-Reply-To: <20230411130210.113555-1-ptyadav@amazon.de>


This is a note to let you know that I've just added the patch titled

    net_sched: prevent NULL dereference if default qdisc setup failed

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net_sched-prevent-null-dereference-if-default-qdisc-setup-failed.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From ptyadav@amazon.de  Tue Apr 11 15:12:32 2023
From: Pratyush Yadav <ptyadav@amazon.de>
Date: Tue, 11 Apr 2023 15:02:10 +0200
Subject: net_sched: prevent NULL dereference if default qdisc setup failed
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Pratyush Yadav <ptyadav@amazon.de>, <stable@vger.kernel.org>, <patches@lists.linux.dev>, Eric Dumazet <edumazet@google.com>, Vlad Buslov <vladbu@mellanox.com>, syzbot <syzkaller@googlegroups.com>, Jamal Hadi Salim <jhs@mojatatu.com>, Cong Wang <xiyou.wangcong@gmail.com>, Jiri Pirko <jiri@resnulli.us>, "David S. Miller" <davem@davemloft.net>, Zubin Mithra <zsm@google.com>, Norbert Manthey <nmanthey@amazon.de>
Message-ID: <20230411130210.113555-1-ptyadav@amazon.de>

From: Pratyush Yadav <ptyadav@amazon.de>

If qdisc_create_dflt() fails, it returns NULL. With CONFIG_NET_SCHED
enabled, the check qdisc != &noop_qdisc passes and qdisc will be passed
to qdisc_hash_add(), which dereferences it.

This assignment was present in the upstream commit 5891cd5ec46c2
("net_sched: add __rcu annotation to netdev->qdisc") but was missed in
the backport 22d95b5449249 ("net_sched: add __rcu annotation to
netdev->qdisc"), perhaps due to merge conflicts.  dev->qdisc is
&noop_qdisc by default and if qdisc_create_dflt() fails, this assignment
will make sure qdisc == &noop_qdisc and no NULL dereference will take
place.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: 22d95b5449249 ("net_sched: add __rcu annotation to netdev->qdisc")
Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/sched/sch_generic.c |    1 +
 1 file changed, 1 insertion(+)

--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -1116,6 +1116,7 @@ static void attach_default_qdiscs(struct
 			qdisc->ops->attach(qdisc);
 		}
 	}
+	qdisc = rtnl_dereference(dev->qdisc);
 
 #ifdef CONFIG_NET_SCHED
 	if (qdisc != &noop_qdisc)


Patches currently in stable-queue which might be from ptyadav@amazon.de are

queue-5.4/net_sched-prevent-null-dereference-if-default-qdisc-setup-failed.patch
queue-5.4/smb3-fix-problem-with-null-cifs-super-block-with-previous-patch.patch

      reply	other threads:[~2023-04-11 13:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 13:02 [PATCH 5.4] net_sched: prevent NULL dereference if default qdisc setup failed Pratyush Yadav
2023-04-11 13:14 ` gregkh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2023041116-sessions-storable-e8dd@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=nmanthey@amazon.de \
    --cc=patches@lists.linux.dev \
    --cc=ptyadav@amazon.de \
    --cc=stable-commits@vger.kernel.org \
    --cc=syzkaller@googlegroups.com \
    --cc=vladbu@mellanox.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=zsm@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox