Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3258044rwb; Mon, 15 Aug 2022 22:31:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR6IgKP+aykTxTIpZtTcGWsLZriMpRScJKN1O3bsraQlxdud2Vi1BRGFzTigsT2Nmy4fnS02 X-Received: by 2002:a17:907:7e8f:b0:733:16da:24bf with SMTP id qb15-20020a1709077e8f00b0073316da24bfmr12310855ejc.349.1660627871247; Mon, 15 Aug 2022 22:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660627871; cv=none; d=google.com; s=arc-20160816; b=bvzeOuUIGoH2/5Wz2dmXaqraWedShcu9tz5TaVOX/jC9QGomNf5toMeXMs+fNyga2n jdzU9ESr5uYv8/c7RBBbT3gJZM4CgP1J8YhfVDiwSrHD/HY3TIu3y1pzxih70hSJr45t 0WUZLNfXCUOfF78Q7enab9h5yje/AZGMcwVzHfBOVHFfXQqt9GgAw+OkyL0LIzv2WjnJ ujxVp7fF0mTY4cJ876YCX38J5H4aIA9JC6ef+t/nEHMTtLTnLHClwEsygTvMC+dgAmpX gy9W4aDDdRInRgJ8mobscwE5/Nh7pWjQoF7zQSJd49OOmwNjcAfAmlQkD/6eq8Ngunsf wy6w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RjhsSX12ZWjtfclpF8q216f33nQIUGfw7NQKBL5xtQM=; b=ANSuh40NrnX/m6l9ayyNZzKbbXu6tF3+GzbFO0hPpk3itAA7cgysdEIxW4tpjDGaPc 3e016C2irD6rC9U+tayliS/bhi1U+Ph45qrfSHZiABch3r/MZ33f6AJOShldpzV5gqTP g7XMZueJulpv3Hrll3HBNwkv++HO76skgH5okZPHFqj6c0RXzfFUxkzWMqmCC79HUnD/ IRuWIsJW/8zV82884r0YZ2hmuYFjzopQF8UlsEPP0vSviRlqiLtxQQ03+8rhFlFcarMW x8KWujjnaoBtvWfolX2MT3UmVbDuxopjtXUOrFDYIVzj7kmgzQPeptx3ER751yJLlTx9 LO7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1P7FvrLl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa35-20020a17090786a300b0072b193ac94bsi9692613ejc.627.2022.08.15.22.30.46; Mon, 15 Aug 2022 22:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1P7FvrLl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233716AbiHPE44 (ORCPT + 99 others); Tue, 16 Aug 2022 00:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234065AbiHPE4R (ORCPT ); Tue, 16 Aug 2022 00:56:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18815BB68A; Mon, 15 Aug 2022 13:51:16 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 7497EB811AC; Mon, 15 Aug 2022 20:51:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B472C433C1; Mon, 15 Aug 2022 20:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596672; bh=dhF1/NQMWIzDt9euqKEuVQlmK9TFSNf2KeDeCJevN9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1P7FvrLlBJzo+iVQwD9nvmMi6/53zrN9OtB1hY9nUJDSO+QO1XXUXcSTN7NDShycn lQsEOTjTz4ZsKhD05h0jSUTZgRTdjTpY/U9aGmvl0gIBbyLnTZXIcPR1wqVxdeoYTw 6ie23PY6U1VMXWXSoyef1atz3vUdC1bgRcDrBq8o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Baokun Li , "Ritesh Harjani (IBM)" , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 5.19 1121/1157] ext4: correct max_inline_xattr_value_size computing Date: Mon, 15 Aug 2022 20:07:57 +0200 Message-Id: <20220815180525.192713819@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Baokun Li [ Upstream commit c9fd167d57133c5b748d16913c4eabc55e531c73 ] If the ext4 inode does not have xattr space, 0 is returned in the get_max_inline_xattr_value_size function. Otherwise, the function returns a negative value when the inode does not contain EXT4_STATE_XATTR. Cc: stable@kernel.org Signed-off-by: Baokun Li Reviewed-by: Ritesh Harjani (IBM) Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20220616021358.2504451-4-libaokun1@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/inline.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 1fa36cbe09ec..a4fbe825694b 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -36,6 +36,9 @@ static int get_max_inline_xattr_value_size(struct inode *inode, struct ext4_inode *raw_inode; int free, min_offs; + if (!EXT4_INODE_HAS_XATTR_SPACE(inode)) + return 0; + min_offs = EXT4_SB(inode->i_sb)->s_inode_size - EXT4_GOOD_OLD_INODE_SIZE - EXT4_I(inode)->i_extra_isize - -- 2.35.1