Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp824359lqo; Fri, 17 May 2024 02:43:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjyLEX8H5ueeuV0vqvbseGF8qV6eLev34CSfNZNjEBH8bDpPRb8YIUldgRPRF8P9asAE7qTN16m0KtYFpLdSZGzq9CNps75XdM1aXW/A== X-Google-Smtp-Source: AGHT+IEwWVFERpL7d9en8AOM8HaRbanGdBj5cJ4dPWHgRuhDUdrBFfocy0vFVvAX843IQsQ2tIrw X-Received: by 2002:a50:ab02:0:b0:572:8aab:4415 with SMTP id 4fb4d7f45d1cf-5734d6e05f9mr13524485a12.40.1715939003815; Fri, 17 May 2024 02:43:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715939003; cv=pass; d=google.com; s=arc-20160816; b=XCeCaUF95j05gxwldFFE6qCDEo1MF1PfoDoVWoN2zpdJX/Xvs1+B4P33NQUKbvpYq6 ts8/5FczBD4qa/xdmWfWmaEPx82VNOgGv1M29DAQr080f1OQfKNxO+3OJxuWFRp7mazX eVrEq3sUU20GL+HRQhSbaAgTdI+l436QIOn5y2mW7sU3yAnzdGw0vMnceB4vUbWIrT+S ntnS4SPMgOfvBJ10ImtnGNTFJUvzDYe7KgvwF2TxxmlrdzI56c1Q9LrGAs3/cVKmZ6j3 IQRaQsmWqEAJ6BNG5W1uJBJmQ85NiDMJljHWL+ZqMUsTa3PO1W8S/o1LsXeiJRVHAk5m YhUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=QgYHiA2D/PhDXSmwX2QgWvfRzxnp5N5zSE4/nZm4IEY=; fh=0G9Bu9/+gWj/4lmtoTNxOcMogOdFXL0UujPNAlTKDhA=; b=y78fUrGhWyfwak9DfVTM7Ti5C8zaYHQIBMzBHTnu4MWV68fbY3GVSy45r4RlPiQcGI iaryMqUoilqYe6CZ6jS1anCCHkkTM+srBTJss0oz16oj5YkMSlDmpEpYE4JtoIL7b0KQ 8YOj/iqOsXf5gmK43hI+WTlJdty1/Z66in+xp3HKNc2T1HfhMbVreOQMJnZqPxydTpeA VDy5OyWMEWweyRUTSwPX+Av7ibhwwBpfBeBx9ulH4JjlQeMSJwz5QmGbFs8hKRlBf2Dc TJ18uiScmngMHUDlEP+wF/+nX5QOPrs1P5BIKN7m8Pcblhpcfn6dyxoRi8k+S3Anv5Ah DzGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=akXQueg0; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-181949-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181949-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c36d43asi9402521a12.527.2024.05.17.02.43.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 02:43:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181949-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=@linux.alibaba.com header.s=default header.b=akXQueg0; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-181949-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181949-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 F167D1F23185 for ; Fri, 17 May 2024 09:42:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EB5D28DCA; Fri, 17 May 2024 09:42:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="akXQueg0" Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 4A4ED18C05 for ; Fri, 17 May 2024 09:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715938932; cv=none; b=jRFrDQzdPSkrpYdSiEgA+1bbUHTlENTwGkVIpEUOt7vLj/IDjQYgYDYHkhwjSHcDivsoOphs6Ht1ODUJVys8jQUdHnSWzRXoKHb6hZLlhIqfYKBT6hpUHZYrb9WmASGt7BZBdVCEg1fia1+LLcEGOcsysUA9WIWsXq4dPLnjY6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715938932; c=relaxed/simple; bh=IVvnRV6hnYHhtVXXcf/vgiezSElLbioCWLuRkoRmcHY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iqyxm2ZM79NqIskIGuOAo5GU8UT0Idv33jYD+JOD3wzg0h2BmRWfERjjY2LNqXfE+sbRR0UAhiHJy/eHgcZ9wGpbUTcFuR6uw9cW8oV3RtG94DS+s0kHJE6sEbIgZAjMOJaPPAkS/24NXjgagQZfNRfNll+6QVPfxPEN/1t3lEQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=akXQueg0; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1715938921; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=QgYHiA2D/PhDXSmwX2QgWvfRzxnp5N5zSE4/nZm4IEY=; b=akXQueg0O3mCXtuf5NW0AGO8Eok8AGrDfrrZttTL56KbnRu7G/M7JIGbT5t2PmZHd+VkFd0QlxGMWr4BrGhecYXlxsr2iR+0Te7ZhvTaeTsy8c56UXC13n73y8BTcJu6Rfs/LhEOkkafyZqdLrPq5mBgT7pwjYSdv19MiAmjEGU= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033022160150;MF=mengferry@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0W6eF4EW_1715938910; Received: from j66c13357.sqa.eu95.tbsite.net(mailfrom:mengferry@linux.alibaba.com fp:SMTPD_---0W6eF4EW_1715938910) by smtp.aliyun-inc.com; Fri, 17 May 2024 17:42:01 +0800 From: Ferry Meng To: Mark Fasheh , Joel Becker , Joseph Qi , ocfs2-devel@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Ferry Meng Subject: [PATCH v2 0/2] ocfs2: add checks in ocfs2_xattr_find_entry() to avoid potential out-of-bound access. Date: Fri, 17 May 2024 17:41:45 +0800 Message-Id: <20240517094147.87133-1-mengferry@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, all: This patch series attempts to address a scenario where accessing user-defined xattrs in a carefully crafted image can lead to out-of-bound access.(To speak truthfully, I do not think this vehavior would occur under proper usage.) In my testing environment, I constructed an OCFS2 image, created a file with several user-defined xattrs(long name attributes, this will cause a "Non-INLINE" xattr, which requires additional space for storage), and then forcibly modified the xe_name_offset using a binary editing tool (e.g "hexedit"). Upon remounting the image and running 'getfattr -d /path/to/file', this patchset was able to detect "partial" malicious modification. In v2, I make these changes: - (1/2) use xs->end directly, no need to parse a parameter. - (2/2) define a local var 'name_offset'. Ferry Meng (2): ocfs2: add bounds checking to ocfs2_xattr_find_entry() ocfs2: strict bound check before memcmp in ocfs2_xattr_find_entry() fs/ocfs2/xattr.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) -- 2.32.0.3.g01195cf9f