From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E15B3A3E75 for ; Tue, 17 Mar 2026 12:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773752261; cv=none; b=rqqs5DZLWRnILyfQahwYW2YW1msPvfXIGOSEgCixPPcfgrV4xmPAIOVKWYOwDodgjlq0utLBocDPsZ8qDIq9EMf2ACXYnt4ScY5OL4O1iVtM7pGT+MBgxuTHlG15HgLa5Tp2nCyG7pF8LkhA8XycU3knAN9iZEHAUAiFqAZClbk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773752261; c=relaxed/simple; bh=bVHmalt+5kdzqXltQ07gEhkgsYHI1Qh8FFKIHiMtV7Q=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=gYGHfoEP++wcirs2Ks5iwvaWv3uN60un5n2LeO4EQF5kusi19WS2TUWdyTQjDOQJDubreqXkGjY8w2OFAM+kDLp5bVAGpUWFMPvrop1B9pHUJ8PFJrOGpbjuNTbr4Vru53JGaiSUuT8AhO7bdRSgwwFzH68j0FKqA5xN8aq+m5M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Q11V0LS9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Q11V0LS9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01D10C4CEF7; Tue, 17 Mar 2026 12:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773752260; bh=bVHmalt+5kdzqXltQ07gEhkgsYHI1Qh8FFKIHiMtV7Q=; h=Subject:To:Cc:From:Date:From; b=Q11V0LS9n/Ds4oasCL/PbdO45IPvGJptjLmVs1zaEnNH25j1yB2wPNO56CGdIhaVy 35QiXSiD+jZIparF+e9quRTiMJ15KqdhJE7dTC6/lP8HSZ9HT/fUSCF3YPSCb2z/WH WDS2DuBrRAa+dKMMCfMd661cRBfz7d4y3FMNO2YM= Subject: FAILED: patch "[PATCH] ublk: fix NULL pointer dereference in ublk_ctrl_set_size()" failed to apply to 6.18-stable tree To: mehulrao@gmail.com,axboe@kernel.dk,ming.lei@redhat.com Cc: From: Date: Tue, 17 Mar 2026 13:57:28 +0100 Message-ID: <2026031728-bunch-limelight-a7e5@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y git checkout FETCH_HEAD git cherry-pick -x 25966fc097691e5c925ad080f64a2f19c5fd940a # git commit -s git send-email --to '' --in-reply-to '2026031728-bunch-limelight-a7e5@gregkh' --subject-prefix 'PATCH 6.18.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 25966fc097691e5c925ad080f64a2f19c5fd940a Mon Sep 17 00:00:00 2001 From: Mehul Rao Date: Thu, 5 Mar 2026 14:31:46 -0500 Subject: [PATCH] ublk: fix NULL pointer dereference in ublk_ctrl_set_size() ublk_ctrl_set_size() unconditionally dereferences ub->ub_disk via set_capacity_and_notify() without checking if it is NULL. ub->ub_disk is NULL before UBLK_CMD_START_DEV completes (it is only assigned in ublk_ctrl_start_dev()) and after UBLK_CMD_STOP_DEV runs (ublk_detach_disk() sets it to NULL). Since the UBLK_CMD_UPDATE_SIZE handler performs no state validation, a user can trigger a NULL pointer dereference by sending UPDATE_SIZE to a device that has been added but not yet started, or one that has been stopped. Fix this by checking ub->ub_disk under ub->mutex before dereferencing it, and returning -ENODEV if the disk is not available. Fixes: 98b995660bff ("ublk: Add UBLK_U_CMD_UPDATE_SIZE") Cc: stable@vger.kernel.org Signed-off-by: Mehul Rao Reviewed-by: Ming Lei Signed-off-by: Jens Axboe diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index c13cda58a7c6..03edabdf8977 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -5003,15 +5003,22 @@ static int ublk_ctrl_get_features(const struct ublksrv_ctrl_cmd *header) return 0; } -static void ublk_ctrl_set_size(struct ublk_device *ub, const struct ublksrv_ctrl_cmd *header) +static int ublk_ctrl_set_size(struct ublk_device *ub, const struct ublksrv_ctrl_cmd *header) { struct ublk_param_basic *p = &ub->params.basic; u64 new_size = header->data[0]; + int ret = 0; mutex_lock(&ub->mutex); + if (!ub->ub_disk) { + ret = -ENODEV; + goto out; + } p->dev_sectors = new_size; set_capacity_and_notify(ub->ub_disk, p->dev_sectors); +out: mutex_unlock(&ub->mutex); + return ret; } struct count_busy { @@ -5331,8 +5338,7 @@ static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd, ret = ublk_ctrl_end_recovery(ub, &header); break; case UBLK_CMD_UPDATE_SIZE: - ublk_ctrl_set_size(ub, &header); - ret = 0; + ret = ublk_ctrl_set_size(ub, &header); break; case UBLK_CMD_QUIESCE_DEV: ret = ublk_ctrl_quiesce_dev(ub, &header);