From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66A2FC3DA7B for ; Sat, 17 Dec 2022 15:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229524AbiLQP1j (ORCPT ); Sat, 17 Dec 2022 10:27:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbiLQP1i (ORCPT ); Sat, 17 Dec 2022 10:27:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B40211C32; Sat, 17 Dec 2022 07:27:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3FF8760C13; Sat, 17 Dec 2022 15:27:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A752FC433F0; Sat, 17 Dec 2022 15:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671290856; bh=OOTfHPq132Z/gNUYFksJS8kJvhXbse9O8ds3QhYEmVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qB45JXBnIIotGtfDGFYj8gpvF2dPznIgx6Ye3d4Uo7xqfDJd5YKEfbIFqP6NUfNxq /blT1ZsTZOyfNmIKMUsTA3Z2Pso/PiribYdGCjzF9ba9DtgVWm+hS1iGMmdSqSEriM qsYi2gNGeTZRtCSWHS6KvyBxahJ65Znk5wH5NRcS+MPQYuNOMRS6oP4B1aaWLi7Lx4 /kIg3NXp+3wbf/a76PNqqMJRZnV3JXZ7D06T2wH87UvNHv+nttYEb5TP+AP7BKBCB6 8DA/2Daf5SM9J1XONLuNKeTrILk4Id8zEmWFz3W8mhB2g1vOjxbu1ncxLjON4ueAgk eq5nPU5aopIeA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Dr. David Alan Gilbert" , syzbot+5fc38b2ddbbca7f5c680@syzkaller.appspotmail.com, Kees Cook , Dave Kleikamp , Sasha Levin , shaggy@kernel.org, brauner@kernel.org, jfs-discussion@lists.sourceforge.net Subject: [PATCH AUTOSEL 6.1 03/22] jfs: Fix fortify moan in symlink Date: Sat, 17 Dec 2022 10:27:04 -0500 Message-Id: <20221217152727.98061-3-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221217152727.98061-1-sashal@kernel.org> References: <20221217152727.98061-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: "Dr. David Alan Gilbert" [ Upstream commit ebe060369f8d6e4588b115f252bebf5ba4d64350 ] JFS has in jfs_incore.h: /* _inline may overflow into _inline_ea when needed */ /* _inline_ea may overlay the last part of * file._xtroot if maxentry = XTROOTINITSLOT */ union { struct { /* 128: inline symlink */ unchar _inline[128]; /* 128: inline extended attr */ unchar _inline_ea[128]; }; unchar _inline_all[256]; and currently the symlink code copies into _inline; if this is larger than 128 bytes it triggers a fortify warning of the form: memcpy: detected field-spanning write (size 132) of single field "ip->i_link" at fs/jfs/namei.c:950 (size 18446744073709551615) when it's actually OK. Copy it into _inline_all instead. Reported-by: syzbot+5fc38b2ddbbca7f5c680@syzkaller.appspotmail.com Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Kees Cook Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin --- fs/jfs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 9db4f5789c0e..4fbbf88435e6 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -946,7 +946,7 @@ static int jfs_symlink(struct user_namespace *mnt_userns, struct inode *dip, if (ssize <= IDATASIZE) { ip->i_op = &jfs_fast_symlink_inode_operations; - ip->i_link = JFS_IP(ip)->i_inline; + ip->i_link = JFS_IP(ip)->i_inline_all; memcpy(ip->i_link, name, ssize); ip->i_size = ssize - 1; -- 2.35.1