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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2711EC2D0E0 for ; Tue, 8 Sep 2020 17:28:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAAC92078B for ; Tue, 8 Sep 2020 17:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599586125; bh=mECtXbiRFJUbuleY1pmT6Ktiv9PX7GzbC8Bl9dfQ3N8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=em2K6o6aSRY4GQi7fzrslNVbo+u7yJ/K99u/NjQi26y8LkhJTGxVpN2Lbv+tpUm6i pn4rpimF5zCR2yoEmMYn4fFtCqJHhNSlYYlr+j1kJadQaY/kKg7a1G78xh6gH2eVQ4 1XcKKwXT7TCWAdEzC4qFOiQHrXp1PmwcTZTR3Eno= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732052AbgIHR2f (ORCPT ); Tue, 8 Sep 2020 13:28:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:57572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731725AbgIHQQb (ORCPT ); Tue, 8 Sep 2020 12:16:31 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 632C22483B; Tue, 8 Sep 2020 15:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579894; bh=mECtXbiRFJUbuleY1pmT6Ktiv9PX7GzbC8Bl9dfQ3N8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qyuxbq7o6EpMboBHKmVD9k4u8EmSKyjOyz7Rkshj7bTaH4afpc2LviZmCbIKccRTm qhXCdbG/fQMJ9O+xy+1ngMvxVbY5hmUBo2Xc4SP4+DW0fX5j5y/IGW3+8+RKab9Ywe FcayABey6Q7MuyWfhpach+F1tCzPwBFo436q8TBI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Sandeen , "Darrick J. Wong" , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.4 047/129] xfs: fix boundary test in xfs_attr_shortform_verify Date: Tue, 8 Sep 2020 17:24:48 +0200 Message-Id: <20200908152232.053568703@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Sandeen [ Upstream commit f4020438fab05364018c91f7e02ebdd192085933 ] The boundary test for the fixed-offset parts of xfs_attr_sf_entry in xfs_attr_shortform_verify is off by one, because the variable array at the end is defined as nameval[1] not nameval[]. Hence we need to subtract 1 from the calculation. This can be shown by: # touch file # setfattr -n root.a file and verifications will fail when it's written to disk. This only matters for a last attribute which has a single-byte name and no value, otherwise the combination of namelen & valuelen will push endp further out and this test won't fail. Fixes: 1e1bbd8e7ee06 ("xfs: create structure verifier function for shortform xattrs") Signed-off-by: Eric Sandeen Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Sasha Levin --- fs/xfs/libxfs/xfs_attr_leaf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index f0089e862216c..fe277ee5ec7c4 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -946,8 +946,10 @@ xfs_attr_shortform_verify( * struct xfs_attr_sf_entry has a variable length. * Check the fixed-offset parts of the structure are * within the data buffer. + * xfs_attr_sf_entry is defined with a 1-byte variable + * array at the end, so we must subtract that off. */ - if (((char *)sfep + sizeof(*sfep)) >= endp) + if (((char *)sfep + sizeof(*sfep) - 1) >= endp) return __this_address; /* Don't allow names with known bad length. */ -- 2.25.1