Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4230498pxk; Tue, 8 Sep 2020 14:18:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlV2Sq9FUcSHURvgrjILMnVkTN4iIWF+u4SA19v6Ze/7+s6I059ODXMIHbpzd6U5NnUz6a X-Received: by 2002:a17:906:455:: with SMTP id e21mr463435eja.170.1599599928838; Tue, 08 Sep 2020 14:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599599928; cv=none; d=google.com; s=arc-20160816; b=FsVR0uFP5nP1q+uSVvUhyaBri91H+/yeSSAFXO6KX8xUNLBc9KYv8zHj6KL3HF8FbC cZkBEQd65nyb6rLMJIvOJNGiHXBvx3m7vdHXuStVbhA9acrm3RbNu+jK6JXDm6MVwkZw pLWdjWd37iITZkPHy65xlh0VUByqYwawhkFmEeEklDValGUUFGvf4tLKvs5MJSvWfwkq WjDWaexbep7felavKXQF0W3QZDMcYCaa3XMa7A5h0oZLtkbLvDejDXRteXWptGqUl1cQ cPMY5a5p24xYQN6QKQ1jmmkkTTmckp5mU5Fm/q6QjfKX5gRD1RCU56/OkKthH9MF/PTf Ip1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+IV4cwLEoBu9+ZrabhGF9qeMvQyVfHuLm5z+Ltx8SnQ=; b=fVPK1XBz6jbrZjPLjPTc2+i79YU1t/LZRoir0IOZeQeinX80WesZEQG/F+wDwEll4M Tuw29eDZRZNFLDJyhqhpSrrNObGQrw86oEIzQ+IoGteu5Af596IiW81qF54s5c5rHMAQ 6UG8j6GJvMErABcHYznt6KYjVsiUK6dkXtCVblqesOlh3H/B4ZJJ1JE5S6ZA5L0ZI0mu CHNXGjbJLIymBSNHLvksbdx9NCypVSsREe6tEKW/p+0rJrgHCn0tn4CZwYu1godMrcx2 +24uJyL2M8QVt10Xe8D8KhQzYzlDNZYo7NGDyIOQ4npbC5RL1MPdxo3eHqDlDVyNOwzA yipQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZYFKQ1OV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d16si178079edr.309.2020.09.08.14.18.26; Tue, 08 Sep 2020 14:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZYFKQ1OV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732186AbgIHTdE (ORCPT + 99 others); Tue, 8 Sep 2020 15:33:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:47748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731015AbgIHP6F (ORCPT ); Tue, 8 Sep 2020 11:58:05 -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 D1D53224DE; Tue, 8 Sep 2020 15:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579432; bh=RGMU6u9awNtR7uD988/rffJ2BkQdiyK7XwLpHaGK2xQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZYFKQ1OV6f5woOu2SCjzkPWsOhTtR/qbwlFOhs6bzz8HyRtrZIDXeIk/IRUGbGd9g mbMMLcQftCAEu+V7Ffw84imjA7W/XyOqL3ZqW6UIIrXP3J5SCmP3SjB8D5o976gAWf o4hdwxU4Tchy/4DNw+3uGLQzQi5SldJu241WxW2k= 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.8 074/186] xfs: fix boundary test in xfs_attr_shortform_verify Date: Tue, 8 Sep 2020 17:23:36 +0200 Message-Id: <20200908152245.236842373@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152241.646390211@linuxfoundation.org> References: <20200908152241.646390211@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 2f7e89e4be3e3..4eb2ecd31b0d2 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -996,8 +996,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