Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp112917rwe; Thu, 13 Apr 2023 23:19:21 -0700 (PDT) X-Google-Smtp-Source: AKy350bFN6Qn+5ET7pIuavHQTlFIlJqbLieO3eW69DX9vcJXeRZUOgnOHKa50ZM7Cm5l48w8KgTr X-Received: by 2002:a17:902:c945:b0:19a:727e:d4f3 with SMTP id i5-20020a170902c94500b0019a727ed4f3mr1786229pla.5.1681453161333; Thu, 13 Apr 2023 23:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681453161; cv=none; d=google.com; s=arc-20160816; b=IL/v3WjtJdU2wqoQRxnyo+f9fZY06yAsREX2w2+OZG5u5Ver72oQA8hxO03N1nQoBs vPjmJXkppxjcqR3i0ADFowFN/054c1lM2c54ENHm+i+o/2uevvCsUmgnB+lYYVS0wNNm zXzpKRDxGZxWPsuw2gsOLVD7tWdyn/tlTizO2wbkYHeFig3TbHCcYSwhQb2LCQN0Z0H9 dCPXxXSIgyDAWVZkg0sBAoiljVmLFd6/j1UUQoHcDaK0eMS1fcKqfAhFrXkIFShQnDya lgQXUYteB5mUqQEffc9i8BNEZUg1odDpHXmxi0bqOs75/Rj0m9pr5b9bKIaE9mXE16mq MsyQ== 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 :message-id:date:subject:cc:to:from; bh=48sXrKqy44cmSJdpxPOcr0v2BHXau9SfsrS0Tl7HRpk=; b=AWnqnItxnA8ogQ7vk9KclN97gc4/2sefq3wIz2uUfA1vxq6JiMOa8RUp873YN8eJOV CrNcywDaRLBhkg8SBSWpMCh5Haegm7Hr38IOXXCgNDd2fDf4RTxe8fffIcf8seili9/k rIDv4DXsOwIKeAwBTkRPWsbZlzUfLmRLXcRvAkkUmSXdTwmbTaAkQFvoHvpwQP7P4Suq 6ORaTmVlqjxDbVauhSM1wGfGrNtMqt93dp0DFhg4BEuIhkBUQUKsn3cp8FHFtQ3gcKeV CxaogR36hENAqqzNzeWooGubIose4sHiTa4QY+rUqQn20fVfOc/UPo8bRH89yzAb3SVU Cg0g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a170903234400b001a68d4a42c0si2920828plh.560.2023.04.13.23.19.06; Thu, 13 Apr 2023 23:19:21 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjDNGS1 (ORCPT + 99 others); Fri, 14 Apr 2023 02:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjDNGSZ (ORCPT ); Fri, 14 Apr 2023 02:18:25 -0400 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 808FB72B3 for ; Thu, 13 Apr 2023 23:18:13 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Vg2OjnN_1681453090; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vg2OjnN_1681453090) by smtp.aliyun-inc.com; Fri, 14 Apr 2023 14:18:11 +0800 From: Jingbo Xu To: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] erofs: fix potential overflow calculating xattr_isize Date: Fri, 14 Apr 2023 14:18:10 +0800 Message-Id: <20230414061810.6479-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 Given on-disk i_xattr_icount is 16 bits and xattr_isize is calculated from i_xattr_icount multiplying 4, xattr_isize has a theoretical maximum of 256K (64K * 4). Thus declare xattr_isize as unsigned int to avoid the potential overflow. Fixes: bfb8674dc044 ("staging: erofs: add erofs in-memory stuffs") Signed-off-by: Jingbo Xu --- fs/erofs/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 8a563374b518..c86241a32ab3 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -306,7 +306,7 @@ struct erofs_inode { unsigned char datalayout; unsigned char inode_isize; - unsigned short xattr_isize; + unsigned int xattr_isize; unsigned int xattr_shared_count; unsigned int *xattr_shared_xattrs; -- 2.19.1.6.gb485710b