From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail115-171.sinamail.sina.com.cn (mail115-171.sinamail.sina.com.cn [218.30.115.171]) (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 084C1126C18 for ; Mon, 30 Dec 2024 12:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735560164; cv=none; b=uOrxLclNFXxNz2vlbU2poXZO1xWMR7dY0TdN6mcJv4+0LzhVZsayOL79qHeVXnkE4rpzGspjmEoSEG0lXBHiBKc14b3i15WjsNJqcRiM/Y5eaPxwURFp42b+4eAeHhz3pYQmMU6/Q+ciy3E/Rsbs7QctD3ElGIgDkz/vXkGs62s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735560164; c=relaxed/simple; bh=z/qAXQ30hw70mTEXMGcjl2pxCWENjb0d3AIEIB0SCRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oRxWB4amvJU1R/lea86kW51rCDPpSkMAqnNDNZ7BUvH4BJX6AWbFTZtFvCANPfiKtYbABnrn7diOa4yVjA1QGKjDDABmt0wdS8dilNK2FL0eRcHwr5ScRQ3MIzjSeK4ogHZFKYyNUEApO8AjNiVwEV7UDNA4LIsnoISdrCq3KH0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([116.24.11.162]) by sina.com (10.185.250.24) with ESMTP id 67728BD300006C73; Mon, 30 Dec 2024 20:02:29 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 57435210748397 X-SMAIL-UIID: B7E78161DD5F42A9A574B63C71A6D6B3-20241230-200229-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [mm?] WARNING in __folio_rmap_sanity_checks (2) Date: Mon, 30 Dec 2024 20:02:30 +0800 Message-ID: <20241230120231.706-1-hdanton@sina.com> In-Reply-To: <676f84f5.050a0220.2f3838.0493.GAE@google.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, 27 Dec 2024 20:56:21 -0800 > syzbot has found a reproducer for the following issue on: > > HEAD commit: 8155b4ef3466 Add linux-next specific files for 20241220 > git tree: linux-next > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1652fadf980000 #syz test --- x/mm/filemap.c +++ y/mm/filemap.c @@ -3636,6 +3636,10 @@ static vm_fault_t filemap_map_folio_rang continue; skip: if (count) { + for (unsigned int i = 0; i < count; i++) { + if (page_folio(page + i) != folio) + goto out; + } set_pte_range(vmf, folio, page, count, addr); *rss += count; folio_ref_add(folio, count); @@ -3658,6 +3662,7 @@ skip: ret = VM_FAULT_NOPAGE; } +out: vmf->pte = old_ptep; return ret; @@ -3738,8 +3743,8 @@ vm_fault_t filemap_map_pages(struct vm_f addr += (xas.xa_index - last_pgoff) << PAGE_SHIFT; vmf->pte += xas.xa_index - last_pgoff; last_pgoff = xas.xa_index; - end = folio_next_index(folio) - 1; - nr_pages = min(end, end_pgoff) - xas.xa_index + 1; + end = folio_next_index(folio) -1; + nr_pages = min(end, end_pgoff) - xas.xa_index; if (!folio_test_large(folio)) ret |= filemap_map_order0_folio(vmf, --