From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 3558B3446CD for ; Tue, 16 Dec 2025 12:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765886603; cv=none; b=RFRfQ2iIdWO/ay86xGc8OBF7God7J28+5yv+FkPhoNzjW3cs8kyLSk18r451/OIXTLtWu6NDxeh3fpRSIDld3JwxrMxX14uJ+9Hrj7vWm2pu8VXSk7aF+p/NxyIB9G7f8J4rFjLkQe7rWaum9q74ABTGt1W2m0cDrzb2tAjtMYQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765886603; c=relaxed/simple; bh=+OuTyfPiRyHJRaVNUHS0ZfufPGLqwrs9N3H9aVM5u4c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Zfv6lhoQUIEADt0vdFEUcxU20H5xJU9paKVzPzK5rns+MdLlCYm0oxI2Q3icJORboQIWE30mi7j54aASI/VNMze2sZN3lJlAI3J1DDyy0IxC43ZHNOFz8gmTFJRcqZt3IbgM6KIGlO5j354BPDP6oEBCO18M97CXwkyPqdZkB/I= 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=fH7oe5BI; arc=none smtp.client-ip=209.85.216.48 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="fH7oe5BI" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-34c27d14559so2637343a91.2 for ; Tue, 16 Dec 2025 04:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765886601; x=1766491401; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=nudjjo9tQjXv4Uc7N0zXlvtzn7nmSytE9z2pqTH9TYo=; b=fH7oe5BIHGr6ibBuhEuP6R9JfXMbU/iF5Jt68g8RsZGD+itkJUHsPgvuTZXnmB27DY mZvInhGw4rwu1SMmkUqHbIvQUSUX0fT6UZZuOcxy/tykuXlfQW/wvVXtMyZaWVN4KWAA m3KMwcIbDQrLjW/LLjXpRrKgswpErTwAHe/jwbU6yF3aQjxw+V/4fRC/coEyHe5goCXT XjP2PBV/eLy9E9G9MkGhH3LNHWRAlZvytdJF/q3irxMUwLgZ7cR3R95CxCoAfNy7fWgB Pu9AMB+JmSMHoLJe40sGaEN8iRC8nMQNIOFudl8N+MEIuz92enFtLudk6NZCHHtkl7Qa 3jcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765886601; x=1766491401; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nudjjo9tQjXv4Uc7N0zXlvtzn7nmSytE9z2pqTH9TYo=; b=nPWR9E9fmU0pZu1Dw+fWjNgVOQXTNW+zmPrbd9Sc5vH+20O6Kj0/mSBhmkyAVe3/LW EAVlLcUkXiVGXDUcoXNdXg3TFx6HWYkocX+AjtxIJPuUcPt+oBuGgKf98WdWtEuoR1Kq r/0MXQseb1QbCgrffUN5FuWGM6TLfty+J2wY4xLOmfXUO3vIIDwSq08M+EnOxyNeBZep 4ZY/wBLQ7rJ3ouo7bhXwnZEjZPch30TO7WdwjdsJQejTlkfdfedTDK1oFtaG4PJoEEPd HDgfnF4PoVJql+P4UiDwTXVY2J67/uyWTtqokQ4yoGU80GxPx1f7IFHeA4YfBluFw5o3 2G9Q== X-Forwarded-Encrypted: i=1; AJvYcCWV0h1XD0fZlbAbDaK3ouwAUxUr2LquVuxXObXayrIJt5dGYkpH1DWGV98wALtfiN1kdJE4HKOgEO9FWg8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3C/W0AwNMCWGyd6uVY8VLht1n4/l2vHYq12NFuTZh5zSxAqw/ gLm5xd1I9h+Eu7Oj6weSydk8xujUNUyzM2UoIjU7fI45+4mG3u2ynbxqol2Njw== X-Gm-Gg: AY/fxX4B7SneMr9ceMetJ/Oatx3gZ081MB+i5RY/f/7J6340HGQHCZ70e7FINnoJq18 Q2wdZCvT6OJ625dUyywpwD5MuSI8pPzno3L5KvfCHrpiIgumPTIjspei95lYBV4O2PmIUG6WwE4 8vDD5PZRoak6HXpmJZpxzZo1jtrWTuqHswAC7OZs1pC6+UUqA9L4B3ehv2cyBq8g2BB7pruFRjH 3ZrAD3fkfOyCfux6HPLOTZIqPjI2PhgI7xRu+crqqh6jet9beFeEXL6pa5iEe3g2/dNeJskl9f1 lCmNcKv/CnA7okb2Rjd+K64LrFChnaGF4B8MaZ4kJACs7qRIf3HnYWl49M302H7xz3KyRUUh2I9 VLwTq6N8C3FYNewkbmA5lX0f85qPvUGpoG8FYBnwCsV4fogjhmisFbfqaKmCYaYncZTa+Si3Uw/ zLlhA= X-Google-Smtp-Source: AGHT+IGRE101MPbPNoCKbWtuok2GQamkgSTAc4yz+nOa0mSToWIwvtlKCanMm5xotu0FurQEcAzDWg== X-Received: by 2002:a17:90b:4f41:b0:33b:bed8:891c with SMTP id 98e67ed59e1d1-34abd848841mr14720357a91.23.1765886601355; Tue, 16 Dec 2025 04:03:21 -0800 (PST) Received: from localhost ([2a12:a304:100::105b]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34abe3ba5e3sm11476016a91.5.2025.12.16.04.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Dec 2025 04:03:20 -0800 (PST) Date: Tue, 16 Dec 2025 20:03:18 +0800 From: Jinchao Wang To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+f792df426ff0f5ceb8d1@syzkaller.appspotmail.com Cc: stable@vger.kernel.org, syzbot+f792df426ff0f5ceb8d1@syzkaller.appspotmail.com Subject: Re: [PATCH] ext4: xattr: fix wrong search.here in clone_block Message-ID: References: <20251216113504.297535-1-wangjinchao600@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251216113504.297535-1-wangjinchao600@gmail.com> On Tue, Dec 16, 2025 at 07:34:55PM +0800, Jinchao Wang wrote: > syzbot reported a KASAN out-of-bounds Read in ext4_xattr_set_entry()[1]. > > When xattr_find_entry() returns -ENODATA, search.here still points to the > position after the last valid entry. ext4_xattr_block_set() clones the xattr > block because the original block maybe shared and must not be modified in > place. > > In the clone_block, search.here is recomputed unconditionally from the old > offset, which may place it past search.first. This results in a negative > reset size and an out-of-bounds memmove() in ext4_xattr_set_entry(). > > Fix this by initializing search.here correctly when search.not_found is set. > > [1] https://syzkaller.appspot.com/bug?extid=f792df426ff0f5ceb8d1 > > Fixes: fd48e9acdf2 (ext4: Unindent codeblock in ext4_xattr_block_set) > Cc: stable@vger.kernel.org > Reported-by: syzbot+f792df426ff0f5ceb8d1@syzkaller.appspotmail.com > Signed-off-by: Jinchao Wang > --- > fs/ext4/xattr.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c > index 2e02efbddaac..cc30abeb7f30 100644 > --- a/fs/ext4/xattr.c > +++ b/fs/ext4/xattr.c > @@ -1980,7 +1980,10 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, > goto cleanup; > s->first = ENTRY(header(s->base)+1); > header(s->base)->h_refcount = cpu_to_le32(1); > - s->here = ENTRY(s->base + offset); > + if (s->not_found) > + s->here = s->first; > + else > + s->here = ENTRY(s->base + offset); > s->end = s->base + bs->bh->b_size; > > /* > -- > 2.43.0 > #syz test