Skip to content

rgw: compare If-Match and If-None-Match entity tags whole - #72117

Open
mmgaggle wants to merge 1 commit into
ceph:mainfrom
mmgaggle:wip-rgw-etag-compare
Open

mmgaggle wants to merge 1 commit into
ceph:mainfrom
mmgaggle:wip-rgw-etag-compare

Conversation

@mmgaggle

@mmgaggle mmgaggle commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

The conditional headers compare the object's ETag as a prefix of the header value (if_match_str.compare(0, etag.length(), etag)): in check_preconditions for writes and deletes, and in the read path for GET, HEAD and a copy's source. So any value that starts with the ETag matches it - an If-Match of the ETag with more characters after it is accepted, and an If-None-Match refuses it - a list of entity tags matches only when the first is the object's, and a weak tag never matches.

This adds rgw_etag_matches(), which reads the header as RFC 7232 does: a comma-separated list of entity tags, each quoted or not, compared whole; If-Match compares strongly, so W/"..." does not match it, and If-None-Match weakly. The callers still handle "*". It is used in the four places, and for the If-Match of a delete by version. unittest_rgw_etag covers it.

Related: https://tracker.ceph.com/issues/64439 (If-Match not unquoted).

Fixes: https://tracker.ceph.com/issues/80924

Validated on a single-host vstart cluster: test_put_object_if_match_etag_with_suffix (ceph/s3-tests#763) fails on main and passes with this change, unittest_rgw_etag passes, and test_s3.py as the rgw suite runs it shows no new failures.

Versioned buckets

Every conditional path for a version, and for a delete marker, compares entity tags through rgw_etag_matches(). s3-tests test_versioned_if_match_whole_etag and _suspended check GET, HEAD, PUT and DELETE with a version id. Other storage backends (d4n, posix, dbstore, motr) still compare by prefix.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

The conditional headers compare the object's ETag as a prefix of the
header's value, with if_match_str.compare(0, etag.length(), etag), in
check_preconditions for writes and deletes, and in the read path for
GET, HEAD and a copy's source. So any value that starts with the ETag
matches it: an If-Match of the ETag with more characters after it is
accepted, and an If-None-Match refuses it. A list of entity tags
matches only when the first is the object's, and a weak tag never
matches.

Add rgw_etag_matches(), which reads the header as RFC 7232 does: a
comma-separated list of entity tags, each quoted or not, compared whole.
If-Match compares strongly, so a weak tag (W/"...") does not match it;
If-None-Match compares weakly. The caller still handles "*". Use it in
the four places, and for the If-Match of a delete by version, which
compared the unquoted value whole but did not take a list.

Fixes: https://tracker.ceph.com/issues/80924
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
@adamemerson adamemerson added wip-aemerson-testing Testing by adamemerson and removed needs-review labels Oct 2, 2026
@adamemerson

Copy link
Copy Markdown
Contributor

@adamemerson

Copy link
Copy Markdown
Contributor

jenkins test make check

@adamemerson

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@mmgaggle

mmgaggle commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

@cbodley ok to merge?

@cbodley

cbodley commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

as in #72101 (comment), this needs to run through qa for validation, which needs to include any test cases you added for it

@RaminNietzsche

Copy link
Copy Markdown
Member

jenkins test api

@RaminNietzsche

Copy link
Copy Markdown
Member

Confirmed on main (5ab2b0d) on vstart: If-Match: "<etag>garbage" is answered 200, If-Match: "nomatch", "<etag>" 412, and If-None-Match: W/"<etag>" 200 instead of 304.

The same prefix comparison is in the other SAL drivers, which this PR does not touch:

  • src/rgw/driver/dbstore/common/dbstore.cc (If-Match and If-None-Match in the read prepare)
  • src/rgw/driver/posix/rgw_sal_posix.cc (same; this one also does not special-case If-Match: *, so * fails as a literal tag)

Would you like to cover them with the new helper here, or should they go to a follow-up?

Probe script: https://gist.github.com/RaminNietzsche/818ad8dd6b8d8093560183cd09d2b169 (cases T3 If-Match prefix-extended etag, T3 If-Match list, T3 If-None-Match weak tag).

@RaminNietzsche

Copy link
Copy Markdown
Member

RFC 9110 RGW audit — series context

This PR is one focused change from an RFC 9110 conformance review of RGW (S3, Swift, Admin, STS). Each PR is meant to review and merge on its own; there is no batch dependency unless called out below.

Item PR Tracker
T1 — 416 + Content-Range #73200 #82229
T4b — CopyObject source preconditions → 412 #73201 #82230
T4a — If-Match before If-Modified-Since #73205 #82233 (Fixes #19965)
T5 — 405 + Allow, 501 for unknown methods #73206 #82235
T6 — Swift 401 + WWW-Authenticate #73209 #82242

Same audit, already tracked on other PRs (not part of this series authorship):

Item PR Tracker
T2 — Range header parsing #71300 #13412
T3 — whole-tag If-Match / If-None-Match #72117 #80924

Follow-ups from the audit not opened yet: T4d If-Range (best after #71300 and #72117 land), T8b header field section too large → 431, T9 admin GET ?sync=true side effects.

Shared repro script and sample output: https://gist.github.com/RaminNietzsche/818ad8dd6b8d8093560183cd09d2b169 (rgw-rfc9110-repro.py; cases T1–T8).

Audit cross-link (T3): Whole-tag comparison for §13.1.1–13.1.2. From the same audit: precondition order for If-Match vs If-Modified-Since is #73205 / #82233; CopyObject source preconditions are #73201 / #82230. Planned follow-up T4d (If-Range) builds on this PR and #71300.

@adamemerson adamemerson removed their assignment Nov 18, 2026
@adamemerson adamemerson removed the wip-aemerson-testing Testing by adamemerson label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants