Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp601054lqb; Wed, 17 Apr 2024 06:06:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6IImjbPfogz2xJJznPIXUe5cnITebDI7THNyLGYrCI0DZxf79slwEZXSYL1xvrKhHONDepeZ4pmx+VUKYNSa05u4E1XJYIvhkEcKkhw== X-Google-Smtp-Source: AGHT+IGtGkTImEOUrUFpVTXRYEXj/akxZ2Iv1/hf90ydkUnUl8y7CCRm4chv7I7WUXGMFBz/WRuz X-Received: by 2002:a17:906:1395:b0:a51:9911:eba8 with SMTP id f21-20020a170906139500b00a519911eba8mr10626100ejc.4.1713359179552; Wed, 17 Apr 2024 06:06:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713359179; cv=pass; d=google.com; s=arc-20160816; b=GMMPRg4AauAp9U/WOo0oTzu3w0yrmd6Vmyx8ADigG0VuA0pT30qrfQRi4zhKI9COB/ kqkDCZb+QuFTKjmbStx0dTXgp2KPbUgzi5m3Qbi1QjCNjlJ4mAn5lOa5r5mQgUiuBwp4 VGw2Pogal7CQdkSIvcXIeah8aCpGXfdex8OeWCdhUn3OtM8n54Fp8DivYP+CxpWm3afo 3LpytiJUX4B2LNfqMxpJ9GKenW6Ph+L0lrlKj3Glq6IhW8UTW4t3VgwZ5BliQEc4mGxm ZeX/2AH1HZF1S59XvYqpoHiq8iVzi4LBUdDqHMZq8Qd2x08RLi2dbvZr+mkKpnZCx2Uf hzkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=sstzwDA7HJF1SbYTI7fJ3qkhbZk4t2Sju46k98cE9Mk=; fh=zpYi+jzbV23oc4qopJmiA3iay75E2bBh64Re5HvBJvQ=; b=IKvK344o84vWgagv+XYojGPkKwIT9i2hVdu3stbE549noY81EX/k6fszAYrjfrzrn0 7oPW45T83iR/xLnwV2OdTzu2WA+Wv1YVq8S6tFnf8j6/y8zQIBlpx4AUM7PNpIYBjfFy cWsCmlzWka27l8e2y82gEFmldw6GMkOsSf1aByQRUaxVWKG5yIsKb0A07kFyrsVtNoO/ PUBKzMPHH5fmZ7cdLk+rETmBvY+EBofsamUBbwfzmGLmkedVmWEtk4LKo/V2GJsMPie6 6eAINkWpa6N96JxP4B8MGu2YhhH3QbVa7BjFlfycBUhiVPvMrIVfjXgxLHUACIpPUvJ1 2PKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=NVHiYSx9; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-148509-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148509-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c22-20020a170906171600b00a51ae5d5475si6720151eje.223.2024.04.17.06.06.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 06:06:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148509-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=NVHiYSx9; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-148509-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148509-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E521C1F236B8 for ; Wed, 17 Apr 2024 13:06:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E85AF13D615; Wed, 17 Apr 2024 13:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="NVHiYSx9" Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 271DC13D265; Wed, 17 Apr 2024 13:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359169; cv=none; b=ftJyV8faNFrwahK2FLp+RqUISs65CsOgqORoBc5wcH5ZfzYQU4QQecFZHNHdOAd3qjfddzagD0uA0ecDjNjyfadcBUvABbk+NFzNPd0quk4WlNWZqxPkwwaef7WYtreoM5KUUWpQY7Ibf3Im3A8Lkz0R4Kwf+sbvepcsr1ilsKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359169; c=relaxed/simple; bh=9Ie/YLM/joywAkgY5c4+CnSqKB8Gr3vixzyksohbcTw=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=h7sXqRBU0fKt7sycjP3M7B8HPgFaZNhb5TBcVX+sfi+PL3nO1XViLC/vjJ6N8/j9Sp/0QEjF0sW+s6lsFxcOMkZFZy7iEBajb9Y24HJJ1VubTXYzXJH36U+WvGNP7Lj8TsBhFpaFuo156VuWZlvKgxUd/QX4Ja2yeh5KrU29cQQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=NVHiYSx9; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 213B32126; Wed, 17 Apr 2024 12:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358713; bh=sstzwDA7HJF1SbYTI7fJ3qkhbZk4t2Sju46k98cE9Mk=; h=Date:Subject:From:To:References:In-Reply-To; b=NVHiYSx9A3Qy8ga9U6cPD4ucTqsztbDPJ3G1vOyNDXOz4qvhmIox/kSwJLwFDFEOt L83ygnznR6U2/UJcQVTvOOlXrMcPoTcFpTwHCHf+G5qoUYWKD0VZkBTOwObmRfBjRg pAhiJejHIrPpDsVwzcRb+XZDWj1UXcYwewVnNQUM= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:06:01 +0300 Message-ID: Date: Wed, 17 Apr 2024 16:06:01 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 03/11] fs/ntfs3: Mark volume as dirty if xattr is broken From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov ---  fs/ntfs3/xattr.c | 17 +++++++++++------  1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 53e7d1fa036a..872df2197202 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -200,6 +200,7 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,      int err;      int ea_size;      size_t ret; +    u8 name_len;      err = ntfs_read_ea(ni, &ea_all, 0, &info);      if (err) @@ -215,28 +216,32 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,      for (off = 0; off + sizeof(struct EA_FULL) < size; off += ea_size) {          ea = Add2Ptr(ea_all, off);          ea_size = unpacked_ea_size(ea); +        name_len = ea->name_len; -        if (!ea->name_len) +        if (!name_len)              break; -        if (ea->name_len > ea_size) +        if (name_len > ea_size) { +            ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR); +            err = -EINVAL; /* corrupted fs. */              break; +        }          if (buffer) {              /* Check if we can use field ea->name */              if (off + ea_size > size)                  break; -            if (ret + ea->name_len + 1 > bytes_per_buffer) { +            if (ret + name_len + 1 > bytes_per_buffer) {                  err = -ERANGE;                  goto out;              } -            memcpy(buffer + ret, ea->name, ea->name_len); -            buffer[ret + ea->name_len] = 0; +            memcpy(buffer + ret, ea->name, name_len); +            buffer[ret + name_len] = 0;          } -        ret += ea->name_len + 1; +        ret += name_len + 1;      }  out: -- 2.34.1