From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B664F4F7CA5; Tue, 13 Oct 2026 12:01:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791892863; cv=none; b=cG1c1ptB0LKkjn7jjQUAFHrBNia37/9NTJibuNSyfCAU8D5PpDr95sTz7Wr0bMCqW0BHHC5uDuMuG2/+Ubx2DQt8Faaf9VF73HzJi0aTtRQmqzzW5TMIkSOj+54E4blb7CfJ3Xa9LPT8LaKAKrfQ3B3zPD34kBWYhI2g1oXede0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791892863; c=relaxed/simple; bh=h0G1597Ocy6RbChLXZes7fBU//oK/q0tOrp7YSWykZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HSVILDR4XFgsuNYk9u8iNXQqM24qx7JipdcDeb+KDJS2OUCeei5nIqA33NAbNZkTp6F2wJXz1LUN++ovJJMhWveVqlCh3yYDk3K8r6ploImP7RTwQ8EPNCAcxVf+IG+OpX6HZfX85dbgLz9GMSMge05DlsDM3I5PxD5gox04h7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=R2XV7m7F; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="R2XV7m7F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B34B1F000FF; Tue, 13 Oct 2026 12:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791892862; bh=0nsYIx2kYkq32niTDCaIG1D68GMH03bZz1qBfgRpOlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R2XV7m7F9JLxleCcxrgH3hmbjbH/ac+EaRdlM0xvUu717cQl/eJqMujJMX3tmKMBJ IB2bEL2v94VPui8hL6qi2WdtxaCJ9vMMybXSSZnMNH5m5q98NkF6v39CbY2St5rXFw Kohez+35C5oh9Dgw8C/mirVU50JQHqMN0aOql3Eg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+48d935cf48a4a76be346@syzkaller.appspotmail.com, Palla Raghunath , Mikulas Patocka Subject: [PATCH 6.18 033/621] dm ioctl: dont let data_start run past the buffer Date: Tue, 13 Oct 2026 13:30:28 +0200 Message-ID: <20261013112921.651128485@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112920.855194808@linuxfoundation.org> References: <20261013112920.855194808@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Palla Raghunath commit 9b3fcf519d370df94a56f3b272d9eddffffa5be8 upstream. struct dm_ioctl has seven bytes of trailing padding, so the smallest buffer userspace is allowed to ask for, offsetof(struct dm_ioctl, data), is seven bytes shorter than sizeof(struct dm_ioctl). get_result_buffer() sets data_start to sizeof(struct dm_ioctl) without looking at how big the buffer actually is. Ask for the minimum and data_start ends up seven bytes past the end. Callers add it to data_size, and ctl_ioctl() copies that much back to userspace: BUG: KASAN: slab-out-of-bounds in _copy_to_user+0xad/0xd0 Read of size 312 at addr ffff8880169e4c00 by task repro-dm/140 ctl_ioctl+0x5e3/0xcb0 dm_ctl_ioctl+0x25/0x40 allocated 305-byte region [ffff8880169e4c00, ffff8880169e4d31) A DM_LIST_DEVICES with data_size set to 305 is enough to hit it, and the seven bytes that leak are whatever sat next to the allocation. Clamp data_start to the buffer size. Note that this is not a security bug because the out-of-bounds read can only be triggered by root. Reported-by: syzbot+48d935cf48a4a76be346@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=48d935cf48a4a76be346 Fixes: 76c072b48e39 ("dm ioctl: move compat code") Cc: stable@vger.kernel.org Signed-off-by: Palla Raghunath Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-ioctl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -556,10 +556,16 @@ static void *get_result_buffer(struct dm { param->data_start = align_ptr(param + 1) - (void *) param; - if (param->data_start < param_size) + if (param->data_start < param_size) { *len = param_size - param->data_start; - else + } else { + /* + * The buffer can be as small as offsetof(*param, data), which + * is less than sizeof(*param), so don't run off the end of it. + */ *len = 0; + param->data_start = param_size; + } return ((void *) param) + param->data_start; }