Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Paulo Alcantara <pc@manguebit.org>
To: Frank Sorenson <sorenson@redhat.com>, linux-cifs@vger.kernel.org
Cc: linkinjeon@kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] smb: client: tighten validate_t2() offset bounds against actual buffer size
Date: Wed, 26 Aug 2026 20:03:33 -0300	[thread overview]
Message-ID: <f67877e37eeede299fbbe86914cd58f2@manguebit.org> (raw)
In-Reply-To: <20260825030948.3577275-1-sorenson@redhat.com>

Frank Sorenson <sorenson@redhat.com> writes:

> validate_t2() rejects ParameterOffset and DataOffset only when they
> exceed 1024, far below the allocated buffer ceiling.  Raise the
> individual offset guard to CIFSMaxBufSize + MAX_CIFS_HDR_SIZE.  Add
> joint offset+count checks against frame_end — bytes from hdr.Protocol
> to the end of the received payload, derived from WordCount and BCC to
> match smbCalcSize() — so a large offset with zero count cannot reach
> beyond the received frame.
>
> In CIFSFindFirst and CIFSFindNext, bound lnoff <= DataCount: since
> validate_t2() guarantees data_off + DataCount <= frame_end, this
> transitively bounds data_off + lnoff within the frame.
>
> Add min_param_size and min_data_size parameters to verify the offset
> clears the byte past ByteCount and that offset + struct size fits in the
> frame.  validate_t2() computes the minimum valid offset dynamically as
> frame_end - BCC, which accounts for SetupCount > 0 (WordCount > 10)
> responses where extra setup words shift ByteCount and the data area
> later.  Non-obvious sizes at the call sites:
>
> - CIFSPOSIXCreate: sizeof(OPEN_PSX_RSP) + sizeof(FILE_UNIX_BASIC_INFO),
>   as the caller memcpys FILE_UNIX_BASIC_INFO immediately after OPEN_PSX_RSP.
> - CIFSSMBQPathInfo: legacy ? offsetof(FILE_INFO_STANDARD, EASize) :
>   sizeof(FILE_ALL_INFO); the legacy path skips EASize intentionally.
> - CIFSSMBQAllEAs: offsetof(struct fealist, list), not sizeof, because an
>   empty EA list returns DataCount=4 (list_len only).
> - CIFSSMBPosixLock: (0, sizeof(struct cifs_posix_lock)) — pSMBr aliases
>   the small request buffer on the waitFlag path; defer
>   cifs_small_buf_release(pSMB) to plk_err_exit so the pLockData branch
>   does not read from freed memory.  validate_t2()'s frame_end bound covers
>   both the waitFlag (small buffer) and !waitFlag (transport-chosen buffer)
>   paths correctly.
> - CIFSGetDFSRefer: (0, 0) — parse_dfs_referrals() reads from the fixed
>   dfs_data struct offset, not from DataOffset; add an explicit check that
>   dfs_data + DataCount fits within the received frame.

Besides all these LLM-generated messages and comments, would you have a
reproducer or a real use case that would require such changes?

  reply	other threads:[~2026-08-26 23:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  3:09 [PATCH] smb: client: tighten validate_t2() offset bounds against actual buffer size Frank Sorenson
2026-08-26 23:03 ` Paulo Alcantara [this message]
2026-08-27 13:45   ` Frank Sorenson
2026-08-28  1:30     ` Paulo Alcantara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f67877e37eeede299fbbe86914cd58f2@manguebit.org \
    --to=pc@manguebit.org \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=sorenson@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox