From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 6A66818CC17 for ; Tue, 30 Jul 2024 20:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.211.166.137 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722370428; cv=none; b=AVK6x6sNKPpX2qNLmEjDNJR0sGVnb521cxRd1+o40D84watvsYl+6WuGjUzXLhwedeCuTUDhxraRhRCLTX3y9TfHbgZseoDLoo0H7768iB40om05YEW1eAJvUJv8RQcIiuhUo6oi/xGWB4fDp+XE33gyARU4btMRhHg0pOlFVWs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722370428; c=relaxed/simple; bh=qT00zwkYKJgoOxVY+BeA/YOxYgQaa4TKzMRCAlXSilM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=U0G3Z1oEUFf4xEWSV0BKXDNHJ+Nd3nqoZf9z7WCgb4P6bvQTVZdkHchTxN2ffELbdTWOl5yjmU/wd0TzPGeeN67venR1aANXlm4jYrnY5Vatd5tQECfkgu+QTlVCmoNnJc2WLPcmt73Qf6rNUM0YVyb6kSDpBCOpcj2vpDuMdpU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Z2aL66lH; arc=none smtp.client-ip=140.211.166.137 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z2aL66lH" Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 178614064B for ; Tue, 30 Jul 2024 20:13:47 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id HwJLizlYE_QQ for ; Tue, 30 Jul 2024 20:13:46 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::32b; helo=mail-wm1-x32b.google.com; envelope-from=sergio.collado@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org AD580405FA Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org AD580405FA Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Z2aL66lH Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by smtp4.osuosl.org (Postfix) with ESMTPS id AD580405FA for ; Tue, 30 Jul 2024 20:13:45 +0000 (UTC) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-428119da952so29955095e9.0 for ; Tue, 30 Jul 2024 13:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722370424; x=1722975224; darn=lists.linuxfoundation.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xXBOk6u7M6ky2TJSBluwduZrSddYhgFxG2c5cgfXD8k=; b=Z2aL66lHzPUMGw13AagofH7agoPgagJB6Nr1Uo31TnDMrNzNEY0yP5RBo+UC8B+aAJ 83lFzV4vpdAzVB3zZ8FdB/WJrh0SQyPlohZg9PM+jZ9W8YETR/Oa14jJ/C2vooeEdGad bqH96VAolonh2p2wuFRaYWfGXJLLTzHjzbdpCMUx0Q/AKSaB5bUpvSjaP3g+i7Yq3WPr fszJO2St1fmSK3Ef+eK8xfegKjRAFmiGHc1gCRRipI3QK1VTdruCIxxouNCABmJR00HO hnhokvkzIAPCcVx2ArRMXfBeaxt/YVnIj/FQMYrgPf2Y8PnTPr9nulLJW6ZXEYDwTaxb yJDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722370424; x=1722975224; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xXBOk6u7M6ky2TJSBluwduZrSddYhgFxG2c5cgfXD8k=; b=NmE4HhivJ1SAtfes2L9nlPoajSG7OqdKD2NXa9/n1uOam+OyCtNxyI9NJcTIBT/Mzd L29JU1eTO2llX9E+guY+N6bBL04rNfFWUU/Gl8HK0xIISlC9vUoENXAzWa8FcNKBVs7+ vCzjjqVeHZi3XMj0ggr3DUzfpz5W7x+kGPEqx+Flh7ChFPPoyU2mMtbZn1E6oa23w/9u L1TVBQXHDDUcrscBvk6CVkBjv/QV+JiTzGwoGts9SAAVdv65ImxFk5eG+etxi9+6GgcJ r4SAncdnxnVj3qdOmYV2nDZeOuyBxDrstTaUC3NXbRz73BlfbhttHuyP2VvpH2CxMg33 Jpyw== X-Gm-Message-State: AOJu0YwIlB3SvsGXkmU0SQoPz58tCx3tx7kmXcwo0MOXxZ22RRcUrSiQ ADSI49rJZ/2uYsW0xIrGiRBA0RHYmIK6ncOmdNn5guMxhssPDzp8 X-Google-Smtp-Source: AGHT+IG6RnNUmcE8SRkRazzvViDEzBmKx/cfzBb40ZZKy4IHiHDgrlpiJoWjnfE/K5nhecrF4Gc99w== X-Received: by 2002:a05:600c:4f4b:b0:426:64a2:5375 with SMTP id 5b1f17b1804b1-42811d80105mr83466395e9.1.1722370423392; Tue, 30 Jul 2024 13:13:43 -0700 (PDT) Received: from laptop.. (52.red-83-52-244.dynamicip.rima-tde.net. [83.52.244.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4280573fd83sm227148385e9.19.2024.07.30.13.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 13:13:43 -0700 (PDT) From: =?UTF-8?q?Sergio=20Gonz=C3=A1lez=20Collado?= To: stable@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Dave Kleikamp , Manas Ghandat , =?UTF-8?q?Sergio=20Gonz=C3=A1lez=20Collado?= , syzbot+6b1d79dad6cc6b3eef41@syzkaller.appspotmail.com Subject: [PATCH 6.1.y] jfs: define xtree root and page independently Date: Tue, 30 Jul 2024 22:13:15 +0200 Message-Id: <20240730201315.19917-1-sergio.collado@gmail.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel-mentees@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Dave Kleikamp [ Upstream commit a779ed754e52d582b8c0e17959df063108bd0656 ] In order to make array bounds checking sane, provide a separate definition of the in-inode xtree root and the external xtree page. Signed-off-by: Dave Kleikamp Tested-by: Manas Ghandat (cherry picked from commit a779ed754e52d582b8c0e17959df063108bd0656) Signed-off-by: Sergio González Collado Reported-by: syzbot+6b1d79dad6cc6b3eef41@syzkaller.appspotmail.com --- fs/jfs/jfs_dinode.h | 2 +- fs/jfs/jfs_imap.c | 6 +++--- fs/jfs/jfs_incore.h | 2 +- fs/jfs/jfs_txnmgr.c | 4 ++-- fs/jfs/jfs_xtree.c | 4 ++-- fs/jfs/jfs_xtree.h | 37 +++++++++++++++++++++++-------------- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/fs/jfs/jfs_dinode.h b/fs/jfs/jfs_dinode.h index 6b231d0d0071..603aae17a693 100644 --- a/fs/jfs/jfs_dinode.h +++ b/fs/jfs/jfs_dinode.h @@ -96,7 +96,7 @@ struct dinode { #define di_gengen u._file._u1._imap._gengen union { - xtpage_t _xtroot; + xtroot_t _xtroot; struct { u8 unused[16]; /* 16: */ dxd_t _dxd; /* 16: */ diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index ac42f8ee553f..794072cdf192 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -670,7 +670,7 @@ int diWrite(tid_t tid, struct inode *ip) * This is the special xtree inside the directory for storing * the directory table */ - xtpage_t *p, *xp; + xtroot_t *p, *xp; xad_t *xad; jfs_ip->xtlid = 0; @@ -684,7 +684,7 @@ int diWrite(tid_t tid, struct inode *ip) * copy xtree root from inode to dinode: */ p = &jfs_ip->i_xtroot; - xp = (xtpage_t *) &dp->di_dirtable; + xp = (xtroot_t *) &dp->di_dirtable; lv = ilinelock->lv; for (n = 0; n < ilinelock->index; n++, lv++) { memcpy(&xp->xad[lv->offset], &p->xad[lv->offset], @@ -713,7 +713,7 @@ int diWrite(tid_t tid, struct inode *ip) * regular file: 16 byte (XAD slot) granularity */ if (type & tlckXTREE) { - xtpage_t *p, *xp; + xtroot_t *p, *xp; xad_t *xad; /* diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h index 721def69e732..dd4264aa9bed 100644 --- a/fs/jfs/jfs_incore.h +++ b/fs/jfs/jfs_incore.h @@ -66,7 +66,7 @@ struct jfs_inode_info { lid_t xtlid; /* lid of xtree lock on directory */ union { struct { - xtpage_t _xtroot; /* 288: xtree root */ + xtroot_t _xtroot; /* 288: xtree root */ struct inomap *_imap; /* 4: inode map header */ } file; struct { diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index ce4b4760fcb1..dccc8b3f1045 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c @@ -783,7 +783,7 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp, if (mp->xflag & COMMIT_PAGE) p = (xtpage_t *) mp->data; else - p = &jfs_ip->i_xtroot; + p = (xtpage_t *) &jfs_ip->i_xtroot; xtlck->lwm.offset = le16_to_cpu(p->header.nextindex); } @@ -1676,7 +1676,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, if (tlck->type & tlckBTROOT) { lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT); - p = &JFS_IP(ip)->i_xtroot; + p = (xtpage_t *) &JFS_IP(ip)->i_xtroot; if (S_ISDIR(ip->i_mode)) lrd->log.redopage.type |= cpu_to_le16(LOG_DIR_XTREE); diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c index 2d304cee884c..5ee618d17e77 100644 --- a/fs/jfs/jfs_xtree.c +++ b/fs/jfs/jfs_xtree.c @@ -1213,7 +1213,7 @@ xtSplitRoot(tid_t tid, struct xtlock *xtlck; int rc; - sp = &JFS_IP(ip)->i_xtroot; + sp = (xtpage_t *) &JFS_IP(ip)->i_xtroot; INCREMENT(xtStat.split); @@ -2098,7 +2098,7 @@ int xtAppend(tid_t tid, /* transaction id */ */ void xtInitRoot(tid_t tid, struct inode *ip) { - xtpage_t *p; + xtroot_t *p; /* * acquire a transaction lock on the root diff --git a/fs/jfs/jfs_xtree.h b/fs/jfs/jfs_xtree.h index 142caafc73b1..15da4e16d8b2 100644 --- a/fs/jfs/jfs_xtree.h +++ b/fs/jfs/jfs_xtree.h @@ -65,24 +65,33 @@ struct xadlist { #define XTPAGEMAXSLOT 256 #define XTENTRYSTART 2 -/* - * xtree page: - */ -typedef union { - struct xtheader { - __le64 next; /* 8: */ - __le64 prev; /* 8: */ +struct xtheader { + __le64 next; /* 8: */ + __le64 prev; /* 8: */ - u8 flag; /* 1: */ - u8 rsrvd1; /* 1: */ - __le16 nextindex; /* 2: next index = number of entries */ - __le16 maxentry; /* 2: max number of entries */ - __le16 rsrvd2; /* 2: */ + u8 flag; /* 1: */ + u8 rsrvd1; /* 1: */ + __le16 nextindex; /* 2: next index = number of entries */ + __le16 maxentry; /* 2: max number of entries */ + __le16 rsrvd2; /* 2: */ - pxd_t self; /* 8: self */ - } header; /* (32) */ + pxd_t self; /* 8: self */ +}; +/* + * xtree root (in inode): + */ +typedef union { + struct xtheader header; xad_t xad[XTROOTMAXSLOT]; /* 16 * maxentry: xad array */ +} xtroot_t; + +/* + * xtree page: + */ +typedef union { + struct xtheader header; + xad_t xad[XTPAGEMAXSLOT]; /* 16 * maxentry: xad array */ } xtpage_t; /* -- 2.39.2