From nobody Wed Jan 26 12:42:08 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3F988198AA35; Wed, 26 Jan 2022 12:42:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JkNdr60Bjz4kLQ; Wed, 26 Jan 2022 12:42:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643200929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mN+I7kRqZCe+T7DZ5P8iuaD8dOOYwbc+T+O3wxOE9Ls=; b=nHbW26gYs06VNuh+A3fiMlYTqv3m2c1HTupr1DwMJufjYgWU2l4x5OUqujQdHuuk6wl4XF latPi9ynlH5U09DCSYUEYsaZrJCToJXKingwds7D1qnTvkZcX4SUOuL5YegkkK0iPy1wDy UCjL1W4WQlaDptIsL7fsX2fFCR6ebEEM2scGwqSmoIQ1tE9kP0IEF0kLDKtU9Q+1uriGG/ kKuqq3Iid+8kh43/q0ISXHqKmRkhCVZ/PGTx6k2cBkgJ+dZXe7peEdoDP0OJsR6LNamqDw 5BHrqNI3NzcI//4Y8FW/2WbBpAykIqrrLcaiTOKzU0Mzy22M+lOn9tc/bXU/ow== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 97D811D75B; Wed, 26 Jan 2022 12:42:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20QCg8Kd074973; Wed, 26 Jan 2022 12:42:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20QCg8jX074972; Wed, 26 Jan 2022 12:42:08 GMT (envelope-from git) Date: Wed, 26 Jan 2022 12:42:08 GMT Message-Id: <202201261242.20QCg8jX074972@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 17cbcf33c3b6 - main - mbuf(9): Assert receive mbufs don't carry a send tag. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 17cbcf33c3b6d0361d71bdb00b8633ec9bb5ae53 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643200929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mN+I7kRqZCe+T7DZ5P8iuaD8dOOYwbc+T+O3wxOE9Ls=; b=IQIg+egIjsMKb7SQAORpJo/9e+awR4MiigcIDcYMg2bz2dsu5XKNvSWfo0LVZaHVuDm1Vw jXDEle+izn0C1hrChX2KChubzyPEsckTVtswu+JRL7WJflB/WMUeNRWmPwVgP9pg0VUvPJ 7Zi5/LJUYy5QHKSWtHxCAvd7rZVtHvnNXc8QW8J6k+6xxsvQoIS1Xqw302TcGJ1WNhOW2F pdOfPbfbCfQcVP/r39Knk9afYBoqniIGA8J71JVez1QiOBtCHGe/GKdhSfQUbR0Y4lQfAE d1YJntBD4m9ZR8QKLW4rHOlN56xdBrDFJbu7lqqGWDL207RJk39PBbOv6soH+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643200929; a=rsa-sha256; cv=none; b=rGDyTnm+xdGMrp50Onlyi+vyatVHC6KSrRtIlyaCu0AMIumN4NLHGef0VP3vbbmbg/t7Sn QoVCQK20j6ktaJ5fhSzcHWhl61hvqzJR6bSlDc+u+9AjGC5maM7ykma8aEpCA7F/CofB6A 5Y0gHlnDxCLOK1vkI0qdrNArgjN+ixhSK+MtBg5rsrKyKG860OK7pulWsefSyLUq0PHdGw 0NdB9a19twpZTIzwUF0CH88rKWibsnY+Zt5S/EcZHeGz9qCTArGc0Xk8dtc0jqYWfmItXH JrgwopHhOAYxN+S3pSP+PCOTOyfJctvJhE/sXLyzohTMt4k47BYc2bfNN7/DQg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=17cbcf33c3b6d0361d71bdb00b8633ec9bb5ae53 commit 17cbcf33c3b6d0361d71bdb00b8633ec9bb5ae53 Author: Hans Petter Selasky AuthorDate: 2022-01-26 11:13:53 +0000 Commit: Hans Petter Selasky CommitDate: 2022-01-26 11:55:00 +0000 mbuf(9): Assert receive mbufs don't carry a send tag. Else we would start leaking reference counts. Discussed with: jhb@ MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/kern/uipc_mbuf.c | 1 + sys/kern/uipc_sockbuf.c | 1 + sys/sys/mbuf.h | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 42c94ae4a355..dab068894f54 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -263,6 +263,7 @@ m_demote_pkthdr(struct mbuf *m) { M_ASSERTPKTHDR(m); + M_ASSERT_NO_SND_TAG(m); m_tag_delete_chain(m, NULL); m->m_flags &= ~M_PKTHDR; diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index d4db19598392..80505dd4dbd2 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -1144,6 +1144,7 @@ sbappendaddr_locked_internal(struct sockbuf *sb, const struct sockaddr *asa, m->m_len = asa->sa_len; bcopy(asa, mtod(m, caddr_t), asa->sa_len); if (m0) { + M_ASSERT_NO_SND_TAG(m0); m_clrprotoflags(m0); m_tag_delete_chain(m0, NULL); /* diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 51dac927e421..77364f428b12 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1139,6 +1139,12 @@ m_extrefcnt(struct mbuf *m) KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR, \ ("%s: no mbuf packet header!", __func__)) +/* Check if the supplied mbuf has no send tag, or else panic. */ +#define M_ASSERT_NO_SND_TAG(m) \ + KASSERT((m) == NULL || ((m)->m_flags & M_PKTHDR) == 0 || \ + ((m)->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0, \ + ("%s: receive mbuf has send tag!", __func__)) + /* Check if mbuf is multipage. */ #define M_ASSERTEXTPG(m) \ KASSERT(((m)->m_flags & (M_EXTPG|M_PKTHDR)) == M_EXTPG, \