Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp328707ybg; Wed, 3 Jun 2020 01:45:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywJfLj7xiK/XkTKOrqRrJCvfjQ3VX2z6esE4sw+nKp3RMhD6BX9kKn38sepBVjHNDzHEw7 X-Received: by 2002:aa7:c758:: with SMTP id c24mr29449977eds.290.1591173928654; Wed, 03 Jun 2020 01:45:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1591173928; cv=pass; d=google.com; s=arc-20160816; b=OtBuTW9In9S7qM4StaDEDbJHE+hWptNnYbQNEUwRZBtEkwGllgFpUiSLlsXsAwOCNT 44WqIKbtLxxyYx92D5JsOWO33Mxuo2uGa10Sxx63C3/lIMnNNI+jMFPN+bfYdv5/dYwe Obmg4vkBuj4U1PrAXIZ7MKquaaMBYIGR1LV6lv5Z/Q7ghNuciUE5cKdmTTZBV3Q9CsMK 6NR72LOoLlkofCYZbdkJMgsleoy09WKyBfp4GcT+tAucu8c3c+LPQ87B44WmTi4gzME7 jpI66MKBvD4a5nOWHZdQC6fYjpm/JU41FAd23tvlk00PRWQE7AyBPy37Xi1DCKE1ogWV 30Jg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :date:subject:message-id:cc:to:from:dkim-signature; bh=dOnotvF97+vjFLmZhdKmcUk4BU3ZedAnmV6Txn6xxAU=; b=ZyVCceI2nFwfR7lZ4qHISNHoBogEP/YfpH0mVLyLrTYIe1DRw9BtaV+a3vr3xTFd0Y W2vBBVYmLQbbk0OoppBLGITle1DDWB6nX1xBtqJsjXZIh58U2hKeQPtBeXgM0knQYDWT acyqCpVmd3wuXRXGgGx+0PyqtAVCZtAaJ2zb28gujPeGLyVefxokjflH9cKwwb0ylnK0 wZtro4BLOKmepBtqQs1eN5/0nebvtXGJQ46XATXB1sGLXpO8PZyfF5erfu2j5q1gWab0 d1bT7fbUTmQm58tSWaXCfi02cgVbcKh5ZUPw4f9IWz3p87bNqOmZlMMEGrhW1e4J77de gRIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=Ph9LhjZX; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si810272edp.67.2020.06.03.01.44.55; Wed, 03 Jun 2020 01:45:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@mykernel.net header.s=zohomail header.b=Ph9LhjZX; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725888AbgFCIov (ORCPT + 99 others); Wed, 3 Jun 2020 04:44:51 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17141 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbgFCIov (ORCPT ); Wed, 3 Jun 2020 04:44:51 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1591173882; cv=none; d=zoho.com.cn; s=zohoarc; b=DMCes2hKHfmrpBgmHO5vNWKxI9foSlu4gfRF76nyBT6meEQTK8eX2asgBTUAsMUxF3PybSrOgnccsByBmJJSrKPVaDPZuvJlP1JdPa/Qugu24FHQWKA1ZAXKOeHFDrO1wnv080sLGuPCecJEegLm77YL3qyt0V5nrgShCqlpA2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1591173882; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=dOnotvF97+vjFLmZhdKmcUk4BU3ZedAnmV6Txn6xxAU=; b=XPbgeeXLkHQfnUw6IHRfF65GHNxa7jFWyd++U45JO9z/52D3uRRIwJz6U40oS7EJTy3aAGu2SoqRIMlTB4eLXEDbgzVfMOP1S5Cy+tLtf387jPzpVeFpIZTgiRFN4eC0x3kyDLqubFh64lb/1SDFsSxrgQGRy60WG1kTOs7YwiY= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1591173882; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=dOnotvF97+vjFLmZhdKmcUk4BU3ZedAnmV6Txn6xxAU=; b=Ph9LhjZXig4osbVSi1srjcBZk5e4z4wD/uBdDSWLFcoZCa/9dkpsrW8JQWtDHTl7 A6Ir0dJv1ksSGnCr2DNxe+rqkh818ZlKekAq4evEAHV0a1MtmzydMXMpbUYxa3WQRLf 5fCrxQQAZwaWVGKpKw6hi0vKG0OaWhS1OmR+kyys= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 15911738790561007.8362167889828; Wed, 3 Jun 2020 16:44:39 +0800 (CST) From: Chengguang Xu To: jack@suse.com Cc: linux-ext4@vger.kernel.org, Chengguang Xu Message-ID: <20200603084429.25344-1-cgxu519@mykernel.net> Subject: [PATCH] ext2: fix improper assignment for e_value_offs Date: Wed, 3 Jun 2020 16:44:29 +0800 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In the process of changing value for existing EA, there is an improper assignment of e_value_offs(setting to 0), because it will be reset to incorrect value in the following loop(shifting EA values before target). Delayed assignment can avoid this issue. Signed-off-by: Chengguang Xu --- fs/ext2/xattr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 943cc469f42f..c802ea682e7f 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -588,7 +588,6 @@ ext2_xattr_set(struct inode *inode, int name_index, con= st char *name, =09=09=09/* Remove the old value. */ =09=09=09memmove(first_val + size, first_val, val - first_val); =09=09=09memset(first_val, 0, size); -=09=09=09here->e_value_offs =3D 0; =09=09=09min_offs +=3D size; =20 =09=09=09/* Adjust all value offsets. */ @@ -600,6 +599,8 @@ ext2_xattr_set(struct inode *inode, int name_index, con= st char *name, =09=09=09=09=09=09cpu_to_le16(o + size); =09=09=09=09last =3D EXT2_XATTR_NEXT(last); =09=09=09} + +=09=09=09here->e_value_offs =3D 0; =09=09} =09=09if (value =3D=3D NULL) { =09=09=09/* Remove the old name. */ --=20 2.20.1