Bug 273902 - Backwards-incompatible size change in struct tcp_info
Summary: Backwards-incompatible size change in struct tcp_info
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL: https://reviews.freebsd.org/D41894
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-17 14:19 UTC by Alan Somers
Modified: 2023-12-01 16:42 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer freebsd_triage 2023-09-17 14:19:06 UTC
struct tcp_info, which can be retrieved via getsockopt with TCP_INFO , changes between OS versions.  However, the struct has a fixed size for backwards-compatibility; a program compiled for stable/13 should be able to run on stable/14 and successfully retrieve the struct; it simply won't know about new fields.

Unfortunately, two recent changes to main accidentally enlarged the structure:
945f9a7cc9dcc071bfcc702748fbbb11087ae773 enlarged it by 12 bytes
22c81cc51636cfebe94e0979eb31556d87775938 enlarged it by 4 bytes

Meanwhile, two other recent changes added new fields but were careful to maintain a fixed size: dc485b968ddeb and 3708c3d370f26.

We should reduce the padding field to compensate, and MFC before 14.0-RELEASE.
Comment 1 Graham Perrin 2023-09-18 23:40:39 UTC
> Unfortunately, two recent changes to main accidentally enlarged the structure:
> 945f9a7cc9dcc071bfcc702748fbbb11087ae773 enlarged it by 12 bytes
> 22c81cc51636cfebe94e0979eb31556d87775938 enlarged it by 4 bytes

Respectively: 

<https://github.com/freebsd/freebsd-src/commit/945f9a7cc9dcc071bfcc702748fbbb11087ae773>
tcp: misc cleanup of options for rack as well as socket option logging. 

<https://github.com/freebsd/freebsd-src/commit/22c81cc51636cfebe94e0979eb31556d87775938>
tcp: add AccECN CE packet counters to tcpinfo
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-09-22 17:25:36 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2209676efe9a23d9411fa0314b9c6bb285baefc1

commit 2209676efe9a23d9411fa0314b9c6bb285baefc1
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2023-09-17 14:22:08 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2023-09-22 16:57:03 +0000

    Fix padding in struct tcp_info

    This structure should have the same size across different FreeBSD
    versions to ensure backwards-compatibility.  It has since stable/6.  But
    two recent changes added fields without compensating by reducing
    padding:
    945f9a7cc9dcc071bfcc702748fbbb11087ae773 and
    22c81cc51636cfebe94e0979eb31556d87775938 .  Reduce padding to
    compensate.

    Direct commit to stable/14 because we decided to break compatibility in
    FreeBSD 15 in order to add more fields.  Of course, that decision could
    be reversed before 15.0-RELEASE.  See the review for details.

    PR:             273902
    MFC after:      1 week
    Reviewed by:    tuexen, glebius
    Differential Revision: https://reviews.freebsd.org/D41894

 sys/netinet/tcp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-10-07 02:49:45 UTC
A commit in branch releng/14.0 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d67558ef3149c02223fd15206c8c7766f6891be2

commit d67558ef3149c02223fd15206c8c7766f6891be2
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2023-09-17 14:22:08 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2023-10-07 02:48:17 +0000

    Fix padding in struct tcp_info

    This structure should have the same size across different FreeBSD
    versions to ensure backwards-compatibility.  It has since stable/6.  But
    two recent changes added fields without compensating by reducing
    padding:
    945f9a7cc9dcc071bfcc702748fbbb11087ae773 and
    22c81cc51636cfebe94e0979eb31556d87775938 .  Reduce padding to
    compensate.

    Direct commit to stable/14 because we decided to break compatibility in
    FreeBSD 15 in order to add more fields.  Of course, that decision could
    be reversed before 15.0-RELEASE.  See the review for details.

    PR:             273902
    Reviewed by:    tuexen, glebius
    Differential Revision: https://reviews.freebsd.org/D41894
    Approved by:    gjb (re)

    (cherry picked from commit 2209676efe9a23d9411fa0314b9c6bb285baefc1)

 sys/netinet/tcp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 4 Alan Somers freebsd_committer freebsd_triage 2023-12-01 16:42:17 UTC
This is fixed.  No MFC to stable/13 is required.