public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Khazhismel Kumykov <khazhy@chromium.org>
To: stable@vger.kernel.org
Cc: linux-block@vger.kernel.org, Yu Kuai <yukuai3@huawei.com>,
	Yi Zhang <yi.zhang@redhat.com>, Jens Axboe <axboe@kernel.dk>,
	Sasha Levin <sashal@kernel.org>,
	Khazhismel Kumykov <khazhy@google.com>
Subject: [PATCH v5.10 2/5] block, bfq: fix uaf for bfqq in bfq_exit_icq_bfqq
Date: Mon, 13 Mar 2023 15:27:54 -0700	[thread overview]
Message-ID: <20230313222757.1103179-3-khazhy@google.com> (raw)
In-Reply-To: <20230313222757.1103179-1-khazhy@google.com>

From: Yu Kuai <yukuai3@huawei.com>

[ Upstream commit 246cf66e300b76099b5dbd3fdd39e9a5dbc53f02 ]

Commit 64dc8c732f5c ("block, bfq: fix possible uaf for 'bfqq->bic'")
will access 'bic->bfqq' in bic_set_bfqq(), however, bfq_exit_icq_bfqq()
can free bfqq first, and then call bic_set_bfqq(), which will cause uaf.

Fix the problem by moving bfq_exit_bfqq() behind bic_set_bfqq().

Fixes: 64dc8c732f5c ("block, bfq: fix possible uaf for 'bfqq->bic'")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20221226030605.1437081-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
---
 block/bfq-iosched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index afaededb3c49..0a53b653a7e2 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -4983,8 +4983,8 @@ static void bfq_exit_icq_bfqq(struct bfq_io_cq *bic, bool is_sync)
 		unsigned long flags;
 
 		spin_lock_irqsave(&bfqd->lock, flags);
-		bfq_exit_bfqq(bfqd, bfqq);
 		bic_set_bfqq(bic, NULL, is_sync);
+		bfq_exit_bfqq(bfqd, bfqq);
 		spin_unlock_irqrestore(&bfqd->lock, flags);
 	}
 }
-- 
2.40.0.rc1.284.g88254d51c5-goog


  parent reply	other threads:[~2023-03-13 22:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 22:27 [PATCH v5.10 0/5] bfq bic/cgroup interaction uaf fixes Khazhismel Kumykov
2023-03-13 22:27 ` [PATCH v5.10 1/5] block, bfq: fix possible uaf for 'bfqq->bic' Khazhismel Kumykov
2023-03-13 22:27 ` Khazhismel Kumykov [this message]
2023-03-13 22:27 ` [PATCH v5.10 3/5] block/bfq-iosched.c: use "false" rather than "BLK_RW_ASYNC" Khazhismel Kumykov
2023-03-13 22:27 ` [PATCH v5.10 4/5] block, bfq: replace 0/1 with false/true in bic apis Khazhismel Kumykov
2023-03-13 22:27 ` [PATCH v5.10 5/5] block, bfq: fix uaf for bfqq in bic_set_bfqq() Khazhismel Kumykov
2023-03-14  2:17 ` [PATCH v5.10 0/5] bfq bic/cgroup interaction uaf fixes Sasha Levin

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=20230313222757.1103179-3-khazhy@google.com \
    --to=khazhy@chromium.org \
    --cc=axboe@kernel.dk \
    --cc=khazhy@google.com \
    --cc=linux-block@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yi.zhang@redhat.com \
    --cc=yukuai3@huawei.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