From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 487683A2543 for ; Tue, 7 Jul 2026 19:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783450860; cv=none; b=hUCvoC9dZKsjIfbGPHPGIemsxQvrXla+p5CNAx4anw/VoqtdMWuzF87/lihUIT0YSOHtJ3oJpES0EtqbHiPj0y+wLk8rirLUCNqLUXuLq781S6cv2zyGR4ZbKl4Yx6AF6YG5AKUeLzR47Ow4XLgrTMyvvXCBjZFwxRfqhwqhYec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783450860; c=relaxed/simple; bh=g1HCBr8bsZcnUx3gO40OyrqGIOY7LwAa+VsmFs5/+V8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XKkFBQaqMPjw/srmkEL+HKavy/Z3tlR7TPA1quh9vbzmO6RJAkYZs6/hYr8TBF1sUv1MLOKenVNr8cNMtSN3pxSRX2Se2ZM2Z1J/rzgXBVWqzZ7JXSXJGp8n5NmkXTer9a6Vi2osEHD10GEVFEUSJgb+HCe42U6zd7esIuMR4jg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=d6biJs5W; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d6biJs5W" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3847e8b0f3aso2792850a91.3 for ; Tue, 07 Jul 2026 12:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783450857; x=1784055657; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lN2b/UwZ6UTOnQoQGsvb5dcfV+ZMY1X8+RCUQeVLWRk=; b=d6biJs5WL2W39/mWRte4YaVvkmFLFkQsNXihQs2Hy42ezuZ/3T3pgZ7nbCCCQGbEbX eS5oeljPWhGMedj9Je8hGaEj/1L3jbt8D5gqLgeVXhIZW4JqQQTMGtxVx/hGXnXLLZOQ 05B3sFpRJHm19xwK8qxn3j24I2MbuWskVFZAgmA3HGDH4sWHbYNtPujzNbSNCqA0vrAY pUWEJPVnBdRPX7QAAdUqrC9nJt6mpOog/Ll7bBTRJZov+p72/SEt35AgfUqLgDuJ10vE H+Rs2Q4pRetJ4GO219GF6Unjf4xfdz4yTmTvW3jSR/lJ1O/lpn56tPt3LWDlzOdcPzQE V6VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783450857; x=1784055657; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lN2b/UwZ6UTOnQoQGsvb5dcfV+ZMY1X8+RCUQeVLWRk=; b=s6ItCGImOprdqr5M+pGejNDnljHVV0Sb9pWMYfFZt8xB1gIZPcxxyro+RUxWMeZTNq OqKCABNj5PDEed8juXdJaD7cb6Y5GPGhcZUtzFHMxUoqFVMaE1ldO9BXVUl0W4FWFdBr 9Xw0ULXwipLCpPZP7EhM2GzJQpVzcU4QkrFLZIeDdPMgm8NRiAlX7xcbKbyfJN1x+UeE yIuHMCWRjh9PlV396iiGWert4ToTWV+BHRhUVzGtl2P6LAq5kcIwJzoO5Vwwb7/zaLEA Ea4aNLQDJytt7cqP8/nOFL5H51eXc4JZTHWY9OqaD5NrtRhyp8j1u295oZ2Acoz0wL+1 +Png== X-Forwarded-Encrypted: i=1; AHgh+RqPTCBZ3ZPH/yzIQVdSX7pusTGlxc9M92wjY2EA209ppAf7zpPJALDnRzwvcGRRNOrrR3udr2Muwi2TqIU=@vger.kernel.org X-Gm-Message-State: AOJu0YzVLwQpyi+bkipR4r3j48dyq7aUp+rDbGd5MukAkPIVpgjo7k9z lUGPvpfuLwjpNZy5d7nE5ZLeJWe2L8MGMxF6jjXaRSB3CtmwU1+70tEW X-Gm-Gg: AfdE7cnUH9iPMeL/0H81id/JImttNLFF1KnWr27HNai2t6njhPIy/yVoWf/yFtHArpZ P+nTBZSwJsPzOnt1w1wCm4Q9Q6t65ANJJ7cpfdMQOoZxS7LPDd1B5mLNAm1UjrY81SC8HLe/Kuu 4fGYlwkNBYxBPqOAsKbZJK/TTzjs5cDCyUal7xvegGFklEDbEGnV/22L3SAcktN4jUSPbuAmsP1 V3xZUnIIZU5QyQ6FV2aJXcKItwhT97nYY/o1SN3kW3PlcdaVUubCxa4BB0jr5X0gm3Xp/YBqReV yafvmCZ+xJZQ9tB+4wv6ust4Iuep0yCMQ4S6ZKoT3rh0cDyO73umZAbIZUGXNOFFkp33FpEYnNd qTzWc2AZFWtdXE1zcD3crYX7UGmeJrc1Pz3mcNZpq8pM7NCt58e9BPz/k4elr3R3MW/Ix1VEJc7 S+8kRX X-Received: by 2002:a05:6a21:3981:b0:3a2:dabf:fef9 with SMTP id adf61e73a8af0-3c08ed5558emr7556572637.27.1783450856632; Tue, 07 Jul 2026 12:00:56 -0700 (PDT) Received: from beelink.. ([186.22.57.86]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-31174a583bcsm12305248eec.19.2026.07.07.12.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 12:00:56 -0700 (PDT) From: Aldo Ariel Panzardo To: linux-xfs@vger.kernel.org, Carlos Maiolino Cc: "Darrick J . Wong" , linux-kernel@vger.kernel.org, Aldo Ariel Panzardo , stable@vger.kernel.org Subject: [PATCH v2 2/2] xfs: reject remote xattr entries with an out-of-range value length Date: Tue, 7 Jul 2026 16:00:38 -0300 Message-ID: <20260707190038.3811440-3-qwe.aldo@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260707190038.3811440-1-qwe.aldo@gmail.com> References: <20260707140118.3217585-1-qwe.aldo@gmail.com> <20260707190038.3811440-1-qwe.aldo@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit xfs_attr3_leaf_verify_entry() validates a remote attribute entry's name but never bounds its on-disk value length (xfs_attr_leaf_name_remote. valuelen, a __be32). A crafted leaf with valuelen = 0x80000000 passes the verifier and the CRC. That length is later assigned into the signed int args->rmtvaluelen (xfs_attr3_leaf_getvalue), becoming negative, which slips past the signed -ERANGE check in xfs_attr_copy_value(); a getxattr() with a small buffer then memcpy()s a full remote block into the small kvalue buffer (xfs_attr_rmtval_copyout) -- a heap out-of-bounds write with attacker-controlled content, from an unprivileged getxattr(2) on a mounted crafted image. Reject remote entries whose value length exceeds XFS_XATTR_SIZE_MAX in the leaf verifier, so the malicious block is rejected at read time. Fixes: c84760659dcf ("xfs: check attribute leaf block structure") Cc: Signed-off-by: Aldo Ariel Panzardo --- v2: cc stable (per Darrick). Now 2/2 of a series: 1/2 fixes the signed value-length check in xfs_attr_copy_value(); this read-time verifier fix is otherwise unchanged from v1. fs/xfs/libxfs/xfs_attr_leaf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index d0f7753659c9..948dc8b26fe6 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -339,6 +339,8 @@ xfs_attr3_leaf_verify_entry( if (!(ent->flags & XFS_ATTR_INCOMPLETE) && rentry->valueblk == 0) return __this_address; + if (be32_to_cpu(rentry->valuelen) > XFS_XATTR_SIZE_MAX) + return __this_address; } if (name_end > buf_end) -- 2.53.0