From patchwork Wed Jan 7 23:44:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1339 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829649; bh=nXW8JeABn3rUKGb9ZGZZhcaUpdr+P83RWqCJwmT75FU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=biYAMCJACcWuD5nAZsVmIzznOQnODRHjDGzqDLvkuDP1Ga/ZnxgCrrSzXEG1X1HY9 avU5sqe3DBgzTut+yPv2Cy65dRVcg6KCAiec4BhHmdqB78j+NYzRuPStM2WhTQeLKg BKxniFfz/6Hw6PAwfofpvyrD0x9E62V27YhppwbhXWwvpLowH3xXTtXgfh4hTlnN7a /T2lNGI9kcoGM51B57sN99lPUIUSx7m40tINhEDkdMUI6ceMxFpA1MS1hdq6vTYTkA A7/tIYhE8g0xB2Yu87W3/wqXERLC9K9AGM6mnfgxhM0HUtJPQaymOKQ2qToEPM7S7e s6BZUr6XG35sg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CA48069146 for ; Wed, 7 Jan 2026 16:47:29 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rJA9suF1b80W for ; Wed, 7 Jan 2026 16:47:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829649; bh=nXW8JeABn3rUKGb9ZGZZhcaUpdr+P83RWqCJwmT75FU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=biYAMCJACcWuD5nAZsVmIzznOQnODRHjDGzqDLvkuDP1Ga/ZnxgCrrSzXEG1X1HY9 avU5sqe3DBgzTut+yPv2Cy65dRVcg6KCAiec4BhHmdqB78j+NYzRuPStM2WhTQeLKg BKxniFfz/6Hw6PAwfofpvyrD0x9E62V27YhppwbhXWwvpLowH3xXTtXgfh4hTlnN7a /T2lNGI9kcoGM51B57sN99lPUIUSx7m40tINhEDkdMUI6ceMxFpA1MS1hdq6vTYTkA A7/tIYhE8g0xB2Yu87W3/wqXERLC9K9AGM6mnfgxhM0HUtJPQaymOKQ2qToEPM7S7e s6BZUr6XG35sg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ACB1F69196 for ; Wed, 7 Jan 2026 16:47:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829646; bh=buw4q/ImIIjzeKT5Ra+gAcYhrCdggYIJ/hLx+PzHd40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oG0t/in2VUbWvLYha35es13O2immshZMfUEXV59CUlGvvFExC2PdlD/8lH0j1/Hy7 43cXpuqBAnYywRJ7wdyYwvogmJ248izkJ4oa1VeaLVRjOhSxv+rxD2lZDoP9JUM9aT G5RZlylpnEaH28AYKVifacfOsGhRR/iUmZ2rJIv6OT57GJWyVi1j1Q+TxCVs9klC1o ShjwL09x29q10300W/Sduyvq/DrSyT4YOMg7bQFztGuJHpvPdFg01TC7Oeh0N6wU8P CpRoYLKEU2OvwlWAMgEzPXG1Y+elwdRCBnF0IxBssjxRaAESJi1dwn1yXR0ic+yd9s eXM1hjdpaea3Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D3DC69146; Wed, 7 Jan 2026 16:47:26 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id si_BaUqEYDQT; Wed, 7 Jan 2026 16:47:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829642; bh=jKwln7VjUoPSndg10sqhEKHZxycls3PFq+/vtdAwtEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sZcMzu6RXJgqDQQNNolJ4zxjLBk0sNyWuco6rbetbnq8jRUgowuBQn/DVvwG4H5rf YcYYu12OK1CQfU87ApOWqILvEJ4uF+zUcEqepyCIw8LmhCr0YqUNemkejVo/hLwFO6 yeWX6adz5rMTnemTO5Wb/lk3QU26ziKLqQR2+sjIjqecjGkrl0jmXEPUiwD149hRet YqCi0r5M5EVcst2E6oXhjrxufMOmwQowrVBtFSEfdyyupXCGr14WHpkpfs+fZUpR0H n5D4YUPmSE9acmGa/0CTFbMAcGaI1rMAnUVAsFoYOzMnsXAMObEMNw+KXLL9ih3BBj zsdtY4Jo5gJaA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F1AA4691A9; Wed, 7 Jan 2026 16:47:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:17 -0700 Message-ID: <20260107234426.3508161-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260107234426.3508161-1-sjg@u-boot.org> References: <20260107234426.3508161-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UDRCSDJVBUW37IFOEYET7AQQLLAV3SGC X-Message-ID-Hash: UDRCSDJVBUW37IFOEYET7AQQLLAV3SGC X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 7/9] fs: ext4l: Align ialloc.c, inode.c et al with Linux List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Apply several small fixes to align with the Linux kernel ext4 code: - readpage.c: Use EXT4_PG_TO_LBLK macro instead of inline shifts for block calculations, matching the macro added in an earlier commit - xattr.c: Add error handling for ext4_get_inode_loc() call in ext4_xattr_inode_dec_ref_all() - ioctl.c: Add strnlen check for mount_opts to prevent reading past the buffer end - ialloc.c, inode.c: Remove ext4_clear_state_flags() calls which were removed in upstream Linux (the subsequent ext4_set_inode_state() handles the initialization) Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ialloc.c | 1 - fs/ext4l/inode.c | 1 - fs/ext4l/ioctl.c | 4 ++++ fs/ext4l/readpage.c | 7 ++----- fs/ext4l/xattr.c | 6 +++++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/ext4l/ialloc.c b/fs/ext4l/ialloc.c index 5bbe8d6d359..baef744892b 100644 --- a/fs/ext4l/ialloc.c +++ b/fs/ext4l/ialloc.c @@ -1279,7 +1279,6 @@ got: ei->i_csum_seed = ext4_chksum(csum, (__u8 *)&gen, sizeof(gen)); } - ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ ext4_set_inode_state(inode, EXT4_STATE_NEW); ei->i_extra_isize = sbi->s_want_extra_isize; diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c index 04b7c734f7f..d0262fa53f2 100644 --- a/fs/ext4l/inode.c +++ b/fs/ext4l/inode.c @@ -5265,7 +5265,6 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, ei->i_projid = make_kprojid(&init_user_ns, i_projid); set_nlink(inode, le16_to_cpu(raw_inode->i_links_count)); - ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ ei->i_inline_off = 0; ei->i_dir_start_lookup = 0; ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); diff --git a/fs/ext4l/ioctl.c b/fs/ext4l/ioctl.c index a93a7baae99..3dec26c939f 100644 --- a/fs/ext4l/ioctl.c +++ b/fs/ext4l/ioctl.c @@ -1394,6 +1394,10 @@ static int ext4_ioctl_set_tune_sb(struct file *filp, if (copy_from_user(¶ms, in, sizeof(params))) return -EFAULT; + if (strnlen(params.mount_opts, sizeof(params.mount_opts)) == + sizeof(params.mount_opts)) + return -E2BIG; + if ((params.set_flags & ~TUNE_OPS_SUPPORTED) != 0) return -EOPNOTSUPP; diff --git a/fs/ext4l/readpage.c b/fs/ext4l/readpage.c index 94361c01f08..7f1cb419339 100644 --- a/fs/ext4l/readpage.c +++ b/fs/ext4l/readpage.c @@ -199,9 +199,7 @@ int ext4_mpage_readpages(struct inode *inode, { struct bio *bio = NULL; sector_t last_block_in_bio = 0; - const unsigned blkbits = inode->i_blkbits; - const unsigned blocks_per_page = PAGE_SIZE >> blkbits; const unsigned blocksize = 1 << blkbits; sector_t next_block; sector_t block_in_file; @@ -237,9 +235,8 @@ int ext4_mpage_readpages(struct inode *inode, blocks_per_folio = folio_size(folio) >> blkbits; first_hole = blocks_per_folio; - block_in_file = next_block = - (sector_t)folio->index << (PAGE_SHIFT - blkbits); - last_block = block_in_file + nr_pages * blocks_per_page; + block_in_file = next_block = EXT4_PG_TO_LBLK(inode, folio->index); + last_block = EXT4_PG_TO_LBLK(inode, folio->index + nr_pages); last_block_in_file = (ext4_readpage_limit(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) diff --git a/fs/ext4l/xattr.c b/fs/ext4l/xattr.c index bd89822a682..a17ce41eba3 100644 --- a/fs/ext4l/xattr.c +++ b/fs/ext4l/xattr.c @@ -1170,7 +1170,11 @@ ext4_xattr_inode_dec_ref_all(handle_t *handle, struct inode *parent, if (block_csum) end = (void *)bh->b_data + bh->b_size; else { - ext4_get_inode_loc(parent, &iloc); + err = ext4_get_inode_loc(parent, &iloc); + if (err) { + EXT4_ERROR_INODE(parent, "parent inode loc (error %d)", err); + return; + } end = (void *)ext4_raw_inode(&iloc) + EXT4_SB(parent->i_sb)->s_inode_size; }