linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yuan Can <yuancan@huawei.com>
To: <ysato@users.sourceforge.jp>, <dalias@libc.org>,
	<lethal@linux-sh.org>, <linux-sh@vger.kernel.org>
Cc: <yuancan@huawei.com>
Subject: [PATCH 2/2] sh: intc: Fix possible UAF in register_intc_controller()
Date: Fri, 18 Nov 2022 02:46:11 +0000	[thread overview]
Message-ID: <20221118024611.112732-3-yuancan@huawei.com> (raw)
In-Reply-To: <20221118024611.112732-1-yuancan@huawei.com>

If the allocation of d->window failed in register_intc_controller(), it
will goto err1 and d will be freed, but d->list will not be removed from
intc_list, then list traversal may cause UAF, fix it.

Fixes: 2be6bb0c79c7 ("sh: intc: Split up the INTC code.")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
 drivers/sh/intc/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 4a4ad10de758..98079a3ebe8a 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -387,6 +387,7 @@ int __init register_intc_controller(struct intc_desc *desc)
 
 	kfree(d->window);
 err1:
+	list_del(&d->list);
 	kfree(d);
 err0:
 	pr_err("unable to allocate INTC memory\n");
-- 
2.17.1


      parent reply	other threads:[~2022-11-18  2:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18  2:46 [PATCH 0/2] sh: intc: Fix UAF and compile error problems Yuan Can
2022-11-18  2:46 ` [PATCH 1/2] sh: intc: Fix compile errors about casting Yuan Can
2022-11-18  2:46 ` Yuan Can [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=20221118024611.112732-3-yuancan@huawei.com \
    --to=yuancan@huawei.com \
    --cc=dalias@libc.org \
    --cc=lethal@linux-sh.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=ysato@users.sourceforge.jp \
    /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;
as well as URLs for NNTP newsgroup(s).