From patchwork Thu Dec 21 11:35:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 182160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp349276dyi; Thu, 21 Dec 2023 03:44:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/m7YlI+3fLQZQdnNHnEQbj7EkDszUp13B8EG8t0M/QuETYJm2rnKkStEXZUD1utbBfN4w X-Received: by 2002:a17:906:aad4:b0:a1c:ab29:87e2 with SMTP id kt20-20020a170906aad400b00a1cab2987e2mr614288ejb.35.1703159088071; Thu, 21 Dec 2023 03:44:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703159088; cv=none; d=google.com; s=arc-20160816; b=aAFG/+fiti8QvS/FSegzUGUrUoXeW1gWYJ1JnVQOUY25b+oL4t0msQJ1Jk/h8jSEAi /Z0MZg0iM6VtLSkh7n8TAjRL2dxcbj5LR+jeqAsCcXK3sKcajwtR7o9NlqIqoORfHJRF erntCwn3oAmVAn9r1gi4gKEDX3+YbFPmDZsf5bh/K/60QgDYYZ0IBvVbWJyelkZpdrbx taaEorFyZPcpXCTA6I86myeY+HJhbCp1zE6CnpRJp7nVNV68UAxfCPa492KmgElHN36f jv9pIFdOPm4TE+PK0XWEkThk2XBd0GHeryhMJedp3kpp58Zzp+eEP+jB1SZ5d97pX+zL exwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=9Rn38mgkFfB/RmjsOLlzz6Pr1cAzEiI3A/7HJSLrTXg=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=FK0gQY6ui05pzX2cO+qN0FAbh9sr9gtNpM6Lrmr18k7L9w4thJ35W97r3Dvipl4A7A 6WhmhnFQxo+fZ9aglQNu3jbBjbinBAbcw8UcyZE5nB3qKnF9UvQeRZqg6OOeObVFhtIp swYSNPI33p4Kb9Ya2WuPbkvj1yM89/mEd7+fNqSlRtRn2TGsHlzCnq1ni+WpOvd89lUC hAYP4LXB9hqQuUMCbyc79X7uKxH+LbgovrpwqXRmCti70P0PLQcbKFUMhUyDBbYK6KRO CGzq3uD0gwY5oO9VIpAEpHqYd6xxCW/6yFo5XXODi952uqir2TgMURP7mMg/gAolh8pD akVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=MmYKJO5n; spf=pass (google.com: domain of linux-kernel+bounces-8301-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8301-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lc7-20020a170906dfe700b00a23569c07easi777302ejc.767.2023.12.21.03.44.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 03:44:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8301-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=MmYKJO5n; spf=pass (google.com: domain of linux-kernel+bounces-8301-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8301-ouuuleilei=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 AB4761F24CD6 for ; Thu, 21 Dec 2023 11:44:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81FD96E2DF; Thu, 21 Dec 2023 11:44:29 +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="MmYKJO5n" X-Original-To: linux-kernel@vger.kernel.org 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 7EEB06D1B7; Thu, 21 Dec 2023 11:44:25 +0000 (UTC) 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 CDA5F1FE6; Thu, 21 Dec 2023 11:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1703158148; bh=9Rn38mgkFfB/RmjsOLlzz6Pr1cAzEiI3A/7HJSLrTXg=; h=Date:To:CC:From:Subject; b=MmYKJO5nSAAVUQ3QGg7PtxmCHKfpDJNtV2ESHoHQ2fHOKCXzWBM08NKVN5A4QQAR4 E3Oyld0TAbtuX3195bdFkV/6s7gdBOQHomwRk0DdiNCoLhECj23PY/8X/XYYZlHE2G Od9T6ej3Swumr15SZcaOi0qKZJT0GjEanQ/UMkMw= Received: from [172.16.192.129] (192.168.211.178) 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; Thu, 21 Dec 2023 14:35:39 +0300 Message-ID: <894db108-509b-4026-a90e-666a759a3f9f@paragon-software.com> Date: Thu, 21 Dec 2023 14:35:39 +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 Content-Language: en-US To: CC: , From: Konstantin Komarov Subject: [PATCH] fs/ntfs3: Disable ATTR_LIST_ENTRY size check X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785891743622223367 X-GMAIL-MSGID: 1785891743622223367 The use of sizeof(struct ATTR_LIST_ENTRY) has been replaced with le_size(0) due to alignment peculiarities on different platforms. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202312071005.g6YrbaIe-lkp@intel.com/ Signed-off-by: Konstantin Komarov ---  fs/ntfs3/attrlist.c | 8 ++++----  fs/ntfs3/ntfs.h     | 2 --  2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c index 7c01735d1219..48e7da47c6b7 100644 --- a/fs/ntfs3/attrlist.c +++ b/fs/ntfs3/attrlist.c @@ -127,12 +127,13 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,  {      size_t off;      u16 sz; +    const unsigned le_min_size = le_size(0);      if (!le) {          le = ni->attr_list.le;      } else {          sz = le16_to_cpu(le->size); -        if (sz < sizeof(struct ATTR_LIST_ENTRY)) { +        if (sz < le_min_size) {              /* Impossible 'cause we should not return such le. */              return NULL;          } @@ -141,7 +142,7 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,      /* Check boundary. */      off = PtrOffset(ni->attr_list.le, le); -    if (off + sizeof(struct ATTR_LIST_ENTRY) > ni->attr_list.size) { +    if (off + le_min_size > ni->attr_list.size) {          /* The regular end of list. */          return NULL;      } @@ -149,8 +150,7 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,      sz = le16_to_cpu(le->size);      /* Check le for errors. */ -    if (sz < sizeof(struct ATTR_LIST_ENTRY) || -        off + sz > ni->attr_list.size || +    if (sz < le_min_size || off + sz > ni->attr_list.size ||          sz < le->name_off + le->name_len * sizeof(short)) {          return NULL;      } diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index c8981429c721..9c7478150a03 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -527,8 +527,6 @@ struct ATTR_LIST_ENTRY {  }; // sizeof(0x20) -static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20); -  static inline u32 le_size(u8 name_len)  {      return ALIGN(offsetof(struct ATTR_LIST_ENTRY, name) +