From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 4598B30BF79 for ; Tue, 16 Dec 2025 03:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765854747; cv=none; b=AUPex8mHMxR7bYz5j8iYoLXakFnaok9AR87ESWWJV29qiDm16dFZM5XGaTbtg+VtSYo2rzTEwjVnM9llvt4zxICn0vnKdXQz8PnKAVWP4duWPwLBZREU5ll0OvtcF+nBkWTc+G8Gil75vkyZr1dPcexvrLVfB9y4gni85waxJqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765854747; c=relaxed/simple; bh=MHj5eMaKpbXLESG/oNUTKn3hO7O7opkUhpED1G1y26E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HmN9v1rU2wRcYthfbP9eMBwZGuE+bUHjpl9tnX0owHqVz6zeBppjdieb77IYYtAiYBh3VtsU6tfr0FQOkglc+y5z7nyUeUhLBGszQfHLMQVw7YbGUSvfImlhZUqH4ygxyTgsNY+1+QYz7uoEql9234iEhWhTj4md73vvdk4Caec= 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=AOFBuCyj; arc=none smtp.client-ip=209.85.210.171 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="AOFBuCyj" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7b852bb31d9so4726579b3a.0 for ; Mon, 15 Dec 2025 19:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765854745; x=1766459545; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=v1XTKIE7lS6ISh9SSrfsgd7hwp0qO7clmkEC+ykt48o=; b=AOFBuCyj5biOosYWEPnJZmYqmDNs/s4hEc8ENSzZJM6QjNPTyOKpB/75Onk+oNaLlZ tQxfk89kAQgkNSxUtrkBgHZ3O2x3+w29YQTDTM92xEgDMPbtBytuX/m2VpkjBlV+raqA 5oMfy/dlcGuGW7xk6hu7I1gPBzhuNEpZP0+JQSr5JyiSbGX/to4lTAFW0SYQrGSbOkyh AuG2PVToLgtczCi/sAONDEaJOMzR5LCFYoFJkQzgWemSiRZkCdACniI63GmTGOIKMc4m x8jcOIyjj7a5NARv2pHmMEBnKtx1hKeNmUZwQl7kTgSL+7RSmt44QVNCK3BLLjQYw326 7oTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765854745; x=1766459545; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v1XTKIE7lS6ISh9SSrfsgd7hwp0qO7clmkEC+ykt48o=; b=qaoxXJ3tqEdN2nvyCuleaO36idLWGty4vrnaWF9htX6CZ9atR40aAGiW0DrSuECMjC 4I2bemYI+NOCRffRGalvC1dDt47E/tfhO1fwu98xHmyC1LiLMEkBJl47u3Z4se3c5CcZ bpdzZ1B6FOPcMo83fpS/hOF+ozahH34SrjorEZhOcJBI2SztU+VAI4ufSWkQ8lYaRt00 Ln1t+Bk276Mny4VM6hMYpVWUuFZ9p+xk1ljf5pCu8LjGLa6DtaSqrJDC3jZ1eed8RFZl 3gPluaoY1DsHpNFAIVyCJJHYCA6kSE4vmHP0/vp+k0Eh/ntg3eMDf6206VBzoN2P1Dds VnpA== X-Forwarded-Encrypted: i=1; AJvYcCUh3phxgzh3FWJ9V3XptMwpYvFjhkfNRjcpGH7vekz9W4cOELKQGI98dfDJ6F+gCi38BOxm96spkbF1XIc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy+Wg4bmbBV2xoEaNzZRZzoV2Egpb4stZYqfntU8aNA2hkFhsZy vCcHYs8teD3oV38BtlwhEMBBKr9OY7fNutURHta4eLYgpiM30U6KfFz/ X-Gm-Gg: AY/fxX6FVeBi9BSb6Rg0ldjpDLh0JwEN2ceOzw/yft8ruKup46GhoOGWJXZcFIPYCEQ N7bd2VL2vGOGyR7yUF6DQ5aA29ZXjVN8ovSUPu4q05hdny/fBPsk8Dp/X51ySU6IvT+GY9eAonf MgesIk0fv5EuQS2X1ekqQrHv1bKyqn5LB3uc7AMT3+8O+Yk1uOxzn6rr+9xy32XPGKdEENNcu3S a8cW+acSBRUg8xrdfX0d+R2v7IdN33uPwXeJKr3PEl4TOI1h3BmqNMOAtGviSsxxELjkB86YKcu dAPDRPSptLExmITbJvOSVDXkP60et0TOFkdOQdIvxtL/aoU7eaT83XPM20KtCMDIZU6HyX/nJaU IV6tmnvL0vsYtoOG1DLH6YpF0NCrzS/HcM1JlJ/gugK7Q63GKcId9ng8pEgWYtDDDjVT2iwtGwx FTBYQ= X-Google-Smtp-Source: AGHT+IF0tz0zYbc0FACU6KRTQzZw3IhUO2xklXRdt4pY23/rn5onAkq4lgOwW+t2ZMZ15thjO9SINg== X-Received: by 2002:a05:6a00:288e:b0:7e8:43f5:bd2c with SMTP id d2e1a72fcca58-7f669c8add9mr10107967b3a.65.1765854745459; Mon, 15 Dec 2025 19:12:25 -0800 (PST) Received: from localhost ([2a12:a304:100::105b]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c585cde0sm13791160b3a.69.2025.12.15.19.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Dec 2025 19:12:24 -0800 (PST) Date: Tue, 16 Dec 2025 11:12:21 +0800 From: Jinchao Wang To: Matthew Wilcox Cc: Andrew Morton , Christian Brauner , Hannes Reinecke , Luis Chamberlain , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, syzbot+4d3cc33ef7a77041efa6@syzkaller.appspotmail.com, syzbot+fdba5cca73fee92c69d6@syzkaller.appspotmail.com Subject: Re: [PATCH] mm/readahead: read min folio constraints under invalidate lock Message-ID: References: <20251215141936.1045907-1-wangjinchao600@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Dec 16, 2025 at 02:42:06AM +0000, Matthew Wilcox wrote: > On Tue, Dec 16, 2025 at 09:37:51AM +0800, Jinchao Wang wrote: > > On Mon, Dec 15, 2025 at 02:22:23PM +0000, Matthew Wilcox wrote: > > > On Mon, Dec 15, 2025 at 10:19:00PM +0800, Jinchao Wang wrote: > > > > page_cache_ra_order() and page_cache_ra_unbounded() read mapping minimum folio > > > > constraints before taking the invalidate lock, allowing concurrent changes to > > > > violate page cache invariants. > > > > > > > > Move the lookups under filemap_invalidate_lock_shared() to ensure readahead > > > > allocations respect the mapping constraints. > > > > > > Why are the mapping folio size constraints being changed? They're > > > supposed to be set at inode instantiation and then never changed. > > > > They can change after instantiation for block devices. In the syzbot repro: > > blkdev_ioctl() -> blkdev_bszset() -> set_blocksize() -> > > mapping_set_folio_min_order() > > Oh, this is just syzbot doing stupid things. We should probably make > blkdev_bszset() fail if somebody else has an fd open. Thanks, that makes sense. Tightening blkdev_bszset() would avoid the race entirely. This change is meant as a defensive fix to prevent BUGs.