From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (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 685EF3BB4A for ; Wed, 8 Apr 2026 05:59:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775627967; cv=none; b=qjj2nDB8IHOoHYQ287HedgB/mgb0JWUWcdt1PnjwaRz2s2By0KkghvCO9sNv0ibUDYretWmB4VFX4aMEqaF5ieosx4xVXTzNz/RQUAU7fDKAsYA31u/QAFEqdynjOlf9yogvBNQF3x5HWCJx1PCIV57iMp6LGX1s8urAbvFObcM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775627967; c=relaxed/simple; bh=xVIxbtIea2Zy2XrpkRKCbatOYUs0i15XfkSqs6z80Lg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=t2xqTU3ONa+jRyjsXnhe8w0EGhhw/K4Q8/xfoFaIYmbbfJgFr27Nfb8pSQ84Ui/C4aR5EzdTJW97WF8ojaarzcL37FUTvnFCVRAOR98bVmb4jI5TyRN+EIgDD6DVu6hcOaF7Z/htZLGiEfDQ+H2DFOCcyhxdXiYWvKkgO9qfmY4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chenxiaosong.com; spf=pass smtp.mailfrom=chenxiaosong.com; dkim=pass (2048-bit key) header.d=chenxiaosong.com header.i=@chenxiaosong.com header.b=hgzBT5Q3; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chenxiaosong.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chenxiaosong.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=chenxiaosong.com header.i=@chenxiaosong.com header.b="hgzBT5Q3" Message-ID: <68bc86cc-1c57-4734-9c75-14c9de80bd71@chenxiaosong.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chenxiaosong.com; s=key1; t=1775627960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kyizpbPf2SethJLAQustHYCjGlsy/KWMQjDIkCTOE2E=; b=hgzBT5Q3PyhXBEPxettMPAjFiAW0z0nPmKwzFioY+x7KR0NROPbZLxDGPAcmdXTt8phAo/ NPS3j2HZF6kmOibTRlzkXUiSLovhdx8rF5G6pPjze6BQnaH+enF0RZysjPmLKUaECsdyA3 c/GZHvcM5ScTgQ6nw54RWW0bpupxfX0LqHhySG4t5q+TwCYQDjZP4SnkUCZB1ZRI3TWEk+ GtqhxM4qgGPHoZUZWqRYWKKqch1dcN0kc4uaJn2UoNIsDdZT84kTUqgifGdXMh70CENUnD p46EGshgi9px2ENwxUBQgfy2DWzooG8JCKOdEttxUdpq+5SofkTpj4ciZCMtXg== Date: Wed, 8 Apr 2026 13:58:27 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 1/2] smb: client: fix off-by-8 bounds check in check_wsl_eas() To: Greg Kroah-Hartman Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , samba-technical@lists.samba.org, stable References: <2026040635-banking-unsoiled-3250@gregkh> <2026040636-unsigned-jackal-e239@gregkh> <2026040822-shortly-chump-8518@gregkh> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: ChenXiaoSong In-Reply-To: <2026040822-shortly-chump-8518@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT The for loop does not seem to catch cases where `outlen` is excessively large. In such cases, smb2_compound_op() would use this large `outlen` to `memcpy()`, which could lead to OOB. ``` smb2_compound_op() { ... size[0] = outlen; // very large check_wsl_eas() memcpy(..., outlen) // out-of-bounds ... } ``` On 4/8/26 13:39, Greg Kroah-Hartman wrote: > On Wed, Apr 08, 2026 at 10:51:12AM +0800, ChenXiaoSong wrote: >> Sashiko reported another out-of-bounds issue: >> https://sashiko.dev/#/patchset/2026040635-banking-unsoiled-3250@gregkh >> >> Should we add the following checks in check_wsl_eas()? >> >> ``` >> --- a/fs/smb/client/smb2inode.c >> +++ b/fs/smb/client/smb2inode.c >> @@ -121,6 +121,9 @@ static int check_wsl_eas(struct kvec *rsp_iov) >> ea = (void *)((u8 *)rsp_iov->iov_base + >> le16_to_cpu(rsp->OutputBufferOffset)); >> end = (u8 *)rsp_iov->iov_base + rsp_iov->iov_len; >> + if (ea + outlen > end) >> + return -EINVAL; > > Then you would miss any "first" structures here, as I think the for loop > catches this later on with the line: > > >> + >> for (;;) { >> if ((u8 *)ea > end - sizeof(*ea)) >> return -EINVAL; > > That one, right? > > Or am I misreading this? > > Pointer math is "fun" :( > > thanks, > > greg k-h -- ChenXiaoSong Chinese Homepage: chenxiaosong.com English Homepage: chenxiaosong.com/en