From nobody Thu Apr 2 10:45:46 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31FAD1F5437 for ; Sun, 29 Mar 2026 16:49:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774802986; cv=none; b=UpLrvQENBSFvOBAkN+Y840kvntyE+yURBaJvHuuXbLet7SeF8qczlg8MkhgUuOYEqVisV9od42WueRJZiZb4c8ydJB4Hb7wBihqE6hUmJi70TTxygTDEQutTyKt+SDTfy1HtzAlA4vA5LVZL6YN2tZ5C3/3ykpG2wm9HtLElXOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774802986; c=relaxed/simple; bh=FegCePrRgmlQ4BFtsYObKp5mK24ZIcDy6Qpqk9+d6wg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=F9Q8eDPi8YsFBYQUZFBm3edTxqUOrTAd4Se7eCymuUcah1aJ5/uG9afKqEbgMd7VjyB6tiIFJdWTv3Dho7suyApaU+6LeZmYiugPf+IWveVL5eeSpiWB1DfP6wEJGeZ546xRyRPIvXRWPl8rGJwQ8kxgDXA9JdoBbH5BWra9dKA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Jk9RcH3b; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jk9RcH3b" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-35c1d101355so1548962a91.1 for ; Sun, 29 Mar 2026 09:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774802983; x=1775407783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cD2gxKgayIiCaDoFwClB5W0CmSi8WMV/LcL4kFdAEFU=; b=Jk9RcH3boaiC5lLNW+lpnd3hs9mmZ2PFaYhXeymxIW+gKmqe634LQswpT+erR6TW3o uIw6iC3u+HbjtcCV2hK4d/IcR7SzpQ4aT93/WjyKgTcFnzFwv7Cdn7SVqW7AVpORwl8H wzTX/NeyWE9kOrHmtTCjEK9gLjE3dfyx2dZA4qmuwyEWjRfnDIZfF8+4LdJAErCHvbci 7Yb/KQlh1NbIoSRVEMoZyPmGlSoGPJwRcJ3bSdF2jvJQB1wbWbNt6k4dPIKlP20LqHS9 jGjez1Jsr3JnAflKy9YK/sScxZyr18U60PMkU701NmXBUrTWxliNE1RfT3dadTAScGbk OGKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774802983; x=1775407783; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cD2gxKgayIiCaDoFwClB5W0CmSi8WMV/LcL4kFdAEFU=; b=LQQfeEBJp5pknJbL5NYRVAjHDcLeSoVHKpGUNe1e/TUF/r+jYolg0KFJs9TZJ68fCJ xuHqjCKVTZBVE053WDBbMXxFFg4LmHkNZki/9luyxH2bKVEdTNFrv8Ur9/TGrQBF/f7P 8O7UkpmvnZ1a67MP9u9XQv3l5/wdX9anLET4v+Rtg1D5F7hmaBiJUY71ZjrqkiTcXfvd 30qRM1QjFUTntsDLa01LmLGuStoL9iPQF01eZrTthjSn92M7Yg7wcxnV22D+XqadFDON 2B34BkGw+pSoNdyHkXzbX7iJ9AwL7uBfhw15CxpqA8Q62wuGStN1L6cCuIsVdzDkfJOK 4nlw== X-Forwarded-Encrypted: i=1; AJvYcCVCepm5w8BARkaEWKucn4/m78whgY6nqUuyBFR7etJ5tSuE6HtcLq7+vyvGHbeB3oWGpE4Axgcxx0gyhfY=@vger.kernel.org X-Gm-Message-State: AOJu0YzoXz5dq05zMkE2uYtVicKCbUe1fiAPqnpVvRvBcs9Mx6SUW7PW y0tHVcVsh2cpOorZp96zxcLmUSUPc57oUfnntYEc1knpo9qHaatz8vT+ X-Gm-Gg: ATEYQzwBPnM/5097mPCrsfIsopBN1FaMgWm2vtaOXihC1pkcLGroqkPVfvWzNDkHHgf VY2Dfof/1dAmRSlO8vG6rEjp7cxFsYBegBfcdDf4uTJ4nOpCSPzfNW38WUZ3OSHj2H3gt/+Uim7 mXT04Q2bUWjsMrSpTxeo4O9vP1lhDVXT8FhB5Kt50tG/Hf6aBaJ6BzAY4BV8UloVc+5G0efZpHL 9nOouM6+/NbCF5AxVEgGV8TZgpK41dAe5ps35vyosjQEYB24GVuagu50DPamFRhS3w8sbjQMOQ3 tOyijL5x29V3g0vGeHMrYSfCkPgzw8XW4b4WYsm4D6yekRBEMMozZfGfnhKqosM14eEujaR8STy c/pIiKuJNGEuxGyZGLwxZMmwNhyQEKAt6Wm+FX/pAVXjs2rlr9gVRFKy3oq/3ib43GyPYnUP+hq 6OFiZ9ez5T4y63baE+dyzb/QB4DIzrYn9vc14= X-Received: by 2002:a17:90b:3fcb:b0:359:f6f8:57b8 with SMTP id 98e67ed59e1d1-35c2ffafed9mr9455628a91.1.1774802983393; Sun, 29 Mar 2026 09:49:43 -0700 (PDT) Received: from localhost.localdomain ([47.236.127.140]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35c2f398df9sm4023623a91.1.2026.03.29.09.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 09:49:42 -0700 (PDT) From: Qi Tang To: Jens Axboe Cc: Ming Lei , Caleb Sander Mateos , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Qi Tang Subject: [PATCH] io_uring/rsrc: reject zero-length fixed buffer import Date: Mon, 30 Mar 2026 00:49:36 +0800 Message-ID: <20260329164936.240871-1-tpluszz77@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" validate_fixed_range() admits buf_addr at the exact end of the registered region when len is zero, because the check uses strict greater-than (buf_end > imu->ubuf + imu->len). io_import_fixed() then computes offset =3D=3D imu->len, which causes the bvec skip logic to advance past the last bio_vec entry and read bv_offset from out-of-bounds slab memory. Return early from io_import_fixed() when len is zero. A zero-length import has no data to transfer and should not walk the bvec array at all. BUG: KASAN: slab-out-of-bounds in io_import_reg_buf+0x697/0x7f0 Read of size 4 at addr ffff888002bcc254 by task poc/103 Call Trace: io_import_reg_buf+0x697/0x7f0 io_write_fixed+0xd9/0x250 __io_issue_sqe+0xad/0x710 io_issue_sqe+0x7d/0x1100 io_submit_sqes+0x86a/0x23c0 __do_sys_io_uring_enter+0xa98/0x1590 Allocated by task 103: The buggy address is located 12 bytes to the right of allocated 584-byte region [ffff888002bcc000, ffff888002bcc248) Fixes: 8622b20f23ed ("io_uring: add validate_fixed_range() for validate fix= ed buffer") Signed-off-by: Qi Tang --- io_uring/rsrc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index 4fa59bf89bba..1b96ab5e98c9 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -1061,6 +1061,10 @@ static int io_import_fixed(int ddir, struct iov_iter= *iter, return ret; if (!(imu->dir & (1 << ddir))) return -EFAULT; + if (unlikely(!len)) { + iov_iter_bvec(iter, ddir, NULL, 0, 0); + return 0; + } =20 offset =3D buf_addr - imu->ubuf; =20 --=20 2.43.0