 jfs: jfs_dmap: Validate db_l2nbperpage while mounting · gregkh/linux@a4855ae · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 686 Star 644 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit a4855ae Browse files Browse files siddhpant authored and gregkh committed jfs: jfs_dmap: Validate db_l2nbperpage while mounting commit 1150991 upstream. In jfs_dmap.c at line 381, BLKTODMAP is used to get a logical block number inside dbFree(). db_l2nbperpage, which is the log2 number of blocks per page, is passed as an argument to BLKTODMAP which uses it for shifting. Syzbot reported a shift out-of-bounds crash because db_l2nbperpage is too big. This happens because the large value is set without any validation in dbMount() at line 181. Thus, make sure that db_l2nbperpage is correct while mounting. Max number of blocks per page = Page size / Min block size =&gt; log2(Max num_block per page) = log2(Page size / Min block size) = log2(Page size) - log2(Min block size) =&gt; Max db_l2nbperpage = L2PSIZE - L2MINBLOCKSIZE Reported-and-tested-by: syzbot+d2cd27dcf8e04b232eb2@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?id=2a70a453331db32ed491f5cbb07e81bf2d225715 Cc: stable@vger.kernel.org Suggested-by: Dave Kleikamp &lt;dave.kleikamp@oracle.com&gt; Signed-off-by: Siddh Raman Pant &lt;code@siddh.me&gt; Signed-off-by: Dave Kleikamp &lt;dave.kleikamp@oracle.com&gt; Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt; 1 parent ee2fd44 commit a4855ae Copy full SHA for a4855ae 2 file s changed + 8 Lines changed: 8 additions &amp; 0 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options fs/jfs jfs_dmap.c jfs_filsys.h Expand file tree Collapse file tree Open diff view settings Collapse file ‎ fs/jfs/jfs_dmap.c ‎ Copy file name to clipboard Expand all lines: fs/jfs/jfs_dmap.c + 6 Lines changed: 6 additions &amp; 0 deletions Original file line number Diff line number Diff line change @@ -178,7 +178,13 @@ int dbMount(struct inode *ipbmap) 178 178 dbmp_le = ( struct dbmap_disk * ) mp -&gt; data ; 179 179 bmp -&gt; db_mapsize = le64_to_cpu ( dbmp_le -&gt; dn_mapsize ); 180 180 bmp -&gt; db_nfree = le64_to_cpu ( dbmp_le -&gt; dn_nfree ); 181 + 181 182 bmp -&gt; db_l2nbperpage = le32_to_cpu ( dbmp_le -&gt; dn_l2nbperpage ); 183 + if ( bmp -&gt; db_l2nbperpage &gt; L2PSIZE - L2MINBLOCKSIZE ) { 184 + err = - EINVAL ; 185 + goto err_release_metapage ; 186 + } 187 + 182 188 bmp -&gt; db_numag = le32_to_cpu ( dbmp_le -&gt; dn_numag ); 183 189 if (! bmp -&gt; db_numag ) { 184 190 err = - EINVAL ; Collapse file ‎ fs/jfs/jfs_filsys.h ‎ Copy file name to clipboard Expand all lines: fs/jfs/jfs_filsys.h + 2 Lines changed: 2 additions &amp; 0 deletions Original file line number Diff line number Diff line change @@ -122,7 +122,9 @@ 122 122 #define NUM_INODE_PER_IAG INOSPERIAG 123 123 124 124 #define MINBLOCKSIZE 512 125 + #define L2MINBLOCKSIZE 9 125 126 #define MAXBLOCKSIZE 4096 127 + #define L2MAXBLOCKSIZE 12 126 128 #define MAXFILESIZE ((s64)1 &lt;&lt; 52) 127 129 128 130 #define JFS_LINK_MAX 0xffffffff 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 