From nobody Fri Jun 14 19:55:28 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4W194J6k5Fz5PQ4f; Fri, 14 Jun 2024 19:55:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4W194J65rbz4PbM; Fri, 14 Jun 2024 19:55:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718394928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OrJzS7h+QLVGza6XVyS4PQkhbMNjXclfm3Z2JujTmfs=; b=qz3pM0BcMTqmuvouaN2vd75jH8WPXsGQVIQlFdqA7ww6tz9qGUb5E0xCjLPU6+ln/jdLDp jWywp0GyfndZi0cIKhdCLJNZhajtAJifhmVxZy+qNVCWH1d421Eoke4Oz0Lxy1nqmkeASg EFA0mcDRw/mxv0BC/eEJe8NfRsKIRZGwOUOAm5xol05/EiBhiWm1VIz8CatvH0EkMVH7Is EhYbNJ77Pg2s8oC+qV7hjxpvTFe08cv+/Ts2xEGK9vf0AELPU9/fHO/RSWx0vVr4zWnp4q FZXcqsUrCgFm+N22n0Xr/a7qDV8KbSQAtjEXA1SOUnpFoPfzhsMHM0vg3tw5mQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718394928; a=rsa-sha256; cv=none; b=nC4LEfuuBYEScjB1y89yeVVU0VCF+0UtHIieRPdfPlI4k//uujGBDS8XXhFyEo5qfy6TnZ rDzC6BR3kTNhEko1qo/7gIvtsa60bqiPZh8dPCvOiPoy/OYfchIVJhaHdVW/Luj+78qg20 SuPJJWAQNhvq5+c1lf62MYKMrj5ZDei0iZlhHr4g7VMkwPAXVqzDMFj15vjnRjSv9T1f6q i/xzp5NeSMXk9MV6uS2TTv7EscwOOFIzsutmEuYn5aokoOebB6Tp9VLnrbl9A3KU8FZVBA r0FD4shZAz/hbCbYWA6ok2JZq7ikzYhsP/xAJ/MeztFzDgEibJR3UrCV/REqXQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718394928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OrJzS7h+QLVGza6XVyS4PQkhbMNjXclfm3Z2JujTmfs=; b=bHqfzMZf4hi8RyW4B9UHYF8w3x+8sgN1NlskdTP2g+ndcwGUTUVf6hL12xB13S6lleKOn7 abLX+sPmrdacdVBFE7tVGrmvsFVqYYXNoKxKgjwQ63YvtL3u+qHpYOsER7fn98BHxmjplz sjPYoI3yIM96FGQVV5mt5gxFRYAwtPEEPZCVAGkgVAnvUuqVs/zGi5cXj2425WRHwSzbYE hx63ieOX1BM2SPhI5xDbAHkyQAXQw6k84Elt8gNKCrzDooVnanrA+bSbgUHnjiHhDJb0aO 5Ms31DdL3ohAbIcJciGrQi+wX8vgSidPmAHG4eDaN15RSF0GwjQEIuec2v8/uA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4W194J5Z8NzZTg; Fri, 14 Jun 2024 19:55:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45EJtSH0039040; Fri, 14 Jun 2024 19:55:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45EJtS7N039037; Fri, 14 Jun 2024 19:55:28 GMT (envelope-from git) Date: Fri, 14 Jun 2024 19:55:28 GMT Message-Id: <202406141955.45EJtS7N039037@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 517c5854588e - main - vm_phys: Make sure that vm_phys_enq_chunk() stays in bounds List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 517c5854588eaa7c2248d97cd750b8b8bad9d69f Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=517c5854588eaa7c2248d97cd750b8b8bad9d69f commit 517c5854588eaa7c2248d97cd750b8b8bad9d69f Author: Mark Johnston AuthorDate: 2024-06-14 14:45:02 +0000 Commit: Mark Johnston CommitDate: 2024-06-14 19:55:02 +0000 vm_phys: Make sure that vm_phys_enq_chunk() stays in bounds vm_phys_enq_chunk() inserts a run of pages into the buddy queues. When lazy initialization is enabled, only the first page of each run is initialized; vm_phys_enq_chunk() thus initializes the page following the just-inserted run. This fails to account for the possibility that the page following the run doesn't belong to the segment. Handle that in vm_phys_enq_chunk(). Reported by: KASAN Reported by: syzbot+1097ef4cee8dfb240e31@syzkaller.appspotmail.com Fixes: b16b4c22d2d1 ("vm_page: Implement lazy page initialization") --- sys/vm/vm_phys.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c index 53e58283eb9f..59ab7d13c55d 100644 --- a/sys/vm/vm_phys.c +++ b/sys/vm/vm_phys.c @@ -711,12 +711,16 @@ vm_phys_enq_chunk(struct vm_freelist *fl, vm_page_t m, int order, int tail) #ifdef VM_FREEPOOL_LAZYINIT if (__predict_false(m->pool == VM_FREEPOOL_LAZYINIT)) { vm_page_t m_next; + vm_paddr_t pa; int npages; npages = 1 << order; m_next = m + npages; - vm_page_init_page(m_next, m->phys_addr + ptoa(npages), m->segind, - VM_FREEPOOL_LAZYINIT); + pa = m->phys_addr + ptoa(npages); + if (pa < vm_phys_segs[m->segind].end) { + vm_page_init_page(m_next, pa, m->segind, + VM_FREEPOOL_LAZYINIT); + } } #endif }