From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (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 E073439FD4 for ; Sun, 21 Jun 2026 00:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782000791; cv=none; b=YTl6c8o7lXtU6CnkjKWjlNjzBnwSC8FH7PmtnlHFc3s/YsIbnCOdRZLrxDLoJ/8/NDnQinS2yaZo6rGeJts5xlk+IeKTeQx5ek1XyavBfVEDSWmxghId4KsPfHhGIfQugALlshN2hRyOsho4lvfVYMFxZsJUa8oNOkr1yXTldOs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782000791; c=relaxed/simple; bh=ktaeMzihr30k6fBytVXsbxDRn9iZrYKUndscumP46qo=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=IKwEw03u33HywjPikWtwwXXJSWVs5M7JDZmrgnZDzaIUzB7OMtyvySZYu0wUIbedNdBdOKXc0R48cLZ3js+Pl9wA8drDiZQQwHovH1k/XyELFtbzSK9ddSsVm185q8ZEr+kMHhBOHQiEoV6dftzka+O5zZapeSwc8OjMkeCeFm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-7e9318cc632so3063257a34.2 for ; Sat, 20 Jun 2026 17:13:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782000789; x=1782605589; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QmHq7GYUJUQ9AlO8615I98fmlHzwNDW0gbWcWbDMWFU=; b=X3ppqkp/uAHGrMfXj8q1MMhx3ltBl8hyyeYhztG0y5wtNA17SAdnPXU3Yq7ij9Br2x AdUEncWQ53cg1CbH/w13a6854BkmHEOC/xdZ+reS4+RlUQTrF2yOrjnv6zm5cKhsQV2/ teiPKaFeIORdc+/vAZLdyVn+3aDni2DkFzOoL8ruGCdcXE4c/s8rfJnBX6ZPWbzSQu8E TF7Np/se5SQ9tPjuWo6kWS65BwZumvXKjoUoJrw0hkNdPekCgvZPlKy550TqVjl3x3Zz fwo5dP/5hgo20GSIwRU/xcSdOfdshu0wFHiJWJdwBBhwpmjxo7RCmyeEeBrbUy2I1PV5 Ui1Q== X-Gm-Message-State: AOJu0Yy3XqrmqTSdh94kXtRPGZhlRoQmCV4Gmz88wCayd5z5Vni5wEw5 ZIFCb5UQs5QOqGJoDD7ToxfYJvQd4QuFxH98PJ1tCj4rjwSiFWN3bPeGRqLFwokdQNAVAY1+umo 62WkTJjB/0nIExfTWgTz2iv/Q8BChFRVJzf6yLsBvqzS4/ruBeJqVwoTiqlc= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6808:5290:b0:485:507:ee5d with SMTP id 5614622812f47-4896aa2ce16mr8625618b6e.10.1782000788984; Sat, 20 Jun 2026 17:13:08 -0700 (PDT) Date: Sat, 20 Jun 2026 17:13:08 -0700 In-Reply-To: <6a36101b.be22b350.2a3e9.0001.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a372c94.1841f4b3.127ecf.0004.GAE@google.com> Subject: Forwarded: [PATCH] io_uring/memmap: bound io_pin_pages() by page array byte size From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] io_uring/memmap: bound io_pin_pages() by page array byte size Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master io_pin_pages() checks that nr_pages does not exceed INT_MAX, then allocates a struct page * array of nr_pages entries. kvmalloc() limits allocations to INT_MAX bytes, but the check counts pages, not bytes. On 64-bit each entry is 8 bytes, so the array hits the INT_MAX byte limit at INT_MAX / sizeof(struct page *) pages, well before the page count check fires. Since commit d760d3f59f0d ("io_uring/rsrc: raise registered buffer 1GB limit") raised the per-buffer cap to 1TB, a buffer near that cap maps ~2^28 pages, making the array allocation exceed INT_MAX bytes. This passes the page count check, reaches kvmalloc(), and triggers the WARN_ON_ONCE() for oversized allocations in __kvmalloc_node_noprof(). Check nr_pages against INT_MAX / sizeof(struct page *) so the buffer is rejected with -EOVERFLOW before the allocation is attempted. Reported-by: syzbot+f99b00a963915b6b52c6@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=f99b00a963915b6b52c6 Fixes: b4e41050b212 ("io_uring/rsrc: raise registered buffer 1GB limit") Signed-off-by: Deepanshu Kartikey --- io_uring/memmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_uring/memmap.c b/io_uring/memmap.c index 4f9b439319c4..da1f6c5d07f8 100644 --- a/io_uring/memmap.c +++ b/io_uring/memmap.c @@ -53,7 +53,7 @@ struct page **io_pin_pages(unsigned long uaddr, unsigned long len, int *npages) nr_pages = end - start; if (WARN_ON_ONCE(!nr_pages)) return ERR_PTR(-EINVAL); - if (WARN_ON_ONCE(nr_pages > INT_MAX)) + if (nr_pages > INT_MAX / sizeof(struct page *)) return ERR_PTR(-EOVERFLOW); pages = kvmalloc_objs(struct page *, nr_pages, GFP_KERNEL_ACCOUNT); -- 2.43.0