Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1506257rdb; Sun, 8 Oct 2023 10:48:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyR1R9VBKFnK/k6j6VuVQI/Vly9C9VQof69dUqjz9kUTGhASmGCyNStSGSFrTzFy/gh00J X-Received: by 2002:a05:6e02:1d9a:b0:34a:be3f:9ee6 with SMTP id h26-20020a056e021d9a00b0034abe3f9ee6mr17576071ila.12.1696787318117; Sun, 08 Oct 2023 10:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696787318; cv=none; d=google.com; s=arc-20160816; b=qb0Yzv4QT18vaOVOkWHpvgp+yXtpLvobZSAHEv5aDcwrJg9L60ktYJktVk1MZnr80j S8GnwVsK6CDiz2YNDZf2Tk04IFxvK6McMXgoxbjM58c0UKB/W1WkwsjujT5vwhKHZacI IhHsWAWDUywxca+N8r8OIGIiB/Qj1ZPTQz1l7fN4grXahiAxALF0Z6vWdlmPrluKhMzB J+bZxLaxaCUKl7t+27ZUA56CHy1pMoSQOMOsETK5/Ohs7x24emvk1kgK0I0KZDlPga07 KoZppvfS8vlvy1y24mI+ajpCGzyzWsPMPsnUBT36ivGMr0mIti/Sao3nC11D8p8btpUE aejw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QJoz8SDUov6EH8w2r891PJdscTvuwkuTW6wM+WMDtO8=; fh=KsZtyfjOeXYxI6EnJCkJ1WCb3/tEEBxl4FEGhptOL74=; b=GXgSulQl7bCqgzWLxj/0OtQIi8tPg8kovuMUptk3uZZVwtJWDY5lhWMJUMMzA7G2yj Wawrf2w4wyBEuhTNJp+ypI3C0VE/b38EkAUA4qetE9IxZ65lUpJ+i/MAeIx5o5faFMHA C7D2SK46dsZ0EfrFjNlLGdUgHzUrCXyjpbR4hsnZ/Q/fSqoqHKT1LR1OX7gD7hUIM3ry rnQEMGu8JrilUX7cTTg5Gm4hx71E2xov3Bd545v7YBgwiE6XNMPT002ztihWRv7k7q6s acBwtz7gasR+LrgU/1koesjjjx4Daax5+QTdWtPRujm1cxGu6kdBneva7G6hMWcRphco Svcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gBMH4Wem; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id eb4-20020a056a004c8400b00690f74dd2cesi4562780pfb.354.2023.10.08.10.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 10:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gBMH4Wem; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3BC3B8078339; Sun, 8 Oct 2023 10:48:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231307AbjJHRsA (ORCPT + 99 others); Sun, 8 Oct 2023 13:48:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbjJHRr7 (ORCPT ); Sun, 8 Oct 2023 13:47:59 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B997A3 for ; Sun, 8 Oct 2023 10:47:58 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c5ff5f858dso25426385ad.2 for ; Sun, 08 Oct 2023 10:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696787277; x=1697392077; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QJoz8SDUov6EH8w2r891PJdscTvuwkuTW6wM+WMDtO8=; b=gBMH4Wema6+fO1Ql3z0kv5RR+wOeVYeDVieDNL04tv5gYlwtjXEG0jw3yl3P5wPyP2 +iPmi/ln14auMZCjRGlOio/KlDgod8Ne/0Fh04+PJJkt3EtHj9csmdImF58eZ5b4Ouv3 dxbFN7COMxyCsJshxeR5vlMSSRWOvtVupl8x8gHrb+e2KpjIU70JvRpO7WvzTko7eiMS /568Lma6VA1ThHtd5XZtq/ddARIiE2MQnC+D+R4kDgBKMfgMDudkMtLcZLfeTu5BSQP5 Ji5w9fOaOyDrOsOE9Kxp8vSxGQaIlZAsvcR0IPnjgFKYM+wp/mh57b+HtMgtjnQwOUaG r6yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696787277; x=1697392077; 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=QJoz8SDUov6EH8w2r891PJdscTvuwkuTW6wM+WMDtO8=; b=nuimGuum2uUr2MvbQ5iapg+KJjQhwtdItECPUKd7Z1SL1T+YM7/OjWUqfpOUEGxn0n 17i3QEjrBMAXPknKVbPopjVd9/T2P/q+ybPmSnQfSTZ8SoFwD6JnQEJz/LUIj5mEBT8r Ha2yLTCXEtHLdhnjuW2iMIzu/njTbKMAEToRmHN3jsm5gL8I3ZZNrL/aqdl7KLXhi1BT iXg/7z/sgcrM+34dGZNAebKCQReRamq0DuQeDRnXI4cwkFaU7AX0VHl0+zg2epy//1cY P6KJ13je9tm9X3gQlWHRgXDkL92Qj1KZcMAVPZXM3hmTsF63i3aP8XifJS0yW/+D+A8v Euiw== X-Gm-Message-State: AOJu0YywGKM4dTcl2twsJRlt2mbjP87D5OADLM40e2BhEGxAw/2anx9y o9f1jHeo8IlvcGf83Lc+tQsrS9Al/wYyooLSQHI= X-Received: by 2002:a17:903:48f:b0:1c7:2c07:ca00 with SMTP id jj15-20020a170903048f00b001c72c07ca00mr10512562plb.36.1696787277368; Sun, 08 Oct 2023 10:47:57 -0700 (PDT) Received: from manas-VirtualBox.iitr.ac.in ([103.37.201.175]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f54900b001c47541ecd7sm7757861plf.250.2023.10.08.10.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 10:47:56 -0700 (PDT) From: Manas Ghandat To: dave.kleikamp@oracle.com, shaggy@kernel.org Cc: Manas Ghandat , Linux-kernel-mentees@lists.linuxfoundation.org, jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzbot+c1056fdfe414463fdb33@syzkaller.appspotmail.com Subject: [PATCH] jfs : fix array-index-out-of-bounds in diWrite Date: Sun, 8 Oct 2023 23:17:45 +0530 Message-Id: <20231008174745.27342-1-ghandatmanas@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=4.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: **** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 08 Oct 2023 10:48:08 -0700 (PDT) Currently while copying dtree root from inode to dnode in the xp slot there is a out of bound memcpy. Added a bound check to the memcpy. Reported-by: syzbot+c1056fdfe414463fdb33@syzkaller.appspotmail.com Fixes: https://syzkaller.appspot.com/bug?extid=c1056fdfe414463fdb33 Signed-off-by: Manas Ghandat --- fs/jfs/jfs_imap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index 799d3837e7c2..d1f897848be0 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -746,7 +746,8 @@ int diWrite(tid_t tid, struct inode *ip) xp = (dtpage_t *) & dp->di_dtroot; lv = ilinelock->lv; for (n = 0; n < ilinelock->index; n++, lv++) { - memcpy(&xp->slot[lv->offset], &p->slot[lv->offset], + if (lv->offset < 128) + memcpy(&xp->slot[lv->offset], &p->slot[lv->offset], lv->length << L2DTSLOTSIZE); } } else { -- 2.37.2