From nobody Fri Jul 21 19:01:30 2023 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 4R6zRv0rSbz4npTR; Fri, 21 Jul 2023 19:01:31 +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 4R6zRv0Jwcz4Dht; Fri, 21 Jul 2023 19:01:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689966091; 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=zXQl72gRy2Hu3W0EUGiMP1Yec7JmQKPOldUHw6OggNw=; b=vycuH/BtnmvDol6G3C1FvYEkpWtb0Q4G0fuR4WZ2hocQC1PmEFFJ63P2eYu6nOJxuHs77y iRIcnT79epM1N04f+MInBaCagDTo4nt3lgUstF584YKzQfJ6itvTojX7qMLs+6j9ckps9J 7qYIwQdHGVH4XxEQ/j9liu2dY4THkOi1TQonX/FsW11qhRN24njGhCSvvNWphg2g66M2t0 +1W7vMKpKS1l7i26tzH5Iz48Wrlrovh3ZRvg3jX3sXTeCmwOyOxzMjmzs9AouQsXAdo4vK nnWSebeRBu//wpDD5j/wo+DOlReMpKo7fUoEomGmWgA+cdPh+/KTF4Ea34HW8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689966091; 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=zXQl72gRy2Hu3W0EUGiMP1Yec7JmQKPOldUHw6OggNw=; b=ZOLbduD/AqAU2sgRs5bv8gc+dip/NQZ3XD/cInQrerFjOS15zRqPRkW0Jfvi+4YWJro3b1 XkZFaDVeDQ1Jdk0MVjOBJF4tFrQSfz7oomTBIZgrmvgDYZ1LeADUaXqs431BpzaDI0tf4F HT+c1ScXKw+T1OuY5WrAwgGZrfYjE9zJChdGsmnqFwkCWJiWrYl6c8bFOUQVFVnI0fkL5r CyWIx3U8OBxpjY3bYEfUbSDtb3vX0lyeGwGAvb+JIT7EcAsParg268zDVPITW4tj7kdlUI F82PGuO5fKaiucnJlTDedd3qElDk2fu8FvWFZYGB1TIT9d5jxmhU0l5ATJMksA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689966091; a=rsa-sha256; cv=none; b=v18B4G36voE37L+bcNZzeSRLa8CULQshD2cmKrONqXSJzVvSP4fsetsOoIfCGdbtXIa1Ub 1tINsNUc4aSbG89tMGDSiDC14C8/A2vBQN9RsNMQP4dokdEr4aRIN8hYFFo98b6xvBUemg va/LWa8HBVtq/mM2LHx5myuGb1T0ht/CYhgqzDijJJ/Ig117buQto4Tv2ezWXDACIBujms u5OqhIF2lhBzOVl6zvmKYdeHlG6du9aAUtvsbDVLIKCo7QgfbMSSvTSCAHiBsz//9OYbNa hvYmyCtRCRT9ksUR2jfd+hb4BRSUSZTWS9jTFqfEKXWKqcu55lbQZC0uD7mryg== 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 4R6zRt6TRxzPS0; Fri, 21 Jul 2023 19:01:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36LJ1UYh055399; Fri, 21 Jul 2023 19:01:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36LJ1UKr055398; Fri, 21 Jul 2023 19:01:30 GMT (envelope-from git) Date: Fri, 21 Jul 2023 19:01:30 GMT Message-Id: <202307211901.36LJ1UKr055398@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: bc310a95c58a - main - ip output: ensure that mbufs are mapped if ipsec is enabled 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bc310a95c58a3c570ed7e5103371453881e36ba1 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=bc310a95c58a3c570ed7e5103371453881e36ba1 commit bc310a95c58a3c570ed7e5103371453881e36ba1 Author: Konstantin Belousov AuthorDate: 2023-07-20 12:08:24 +0000 Commit: Konstantin Belousov CommitDate: 2023-07-21 18:51:13 +0000 ip output: ensure that mbufs are mapped if ipsec is enabled Ipsec needs access to packet headers to determine if a policy is applicable. It seems that typically IP headers are mapped, but the code is arguably needs to check this before blindly accessing them. Then, operations like m_unshare() and m_makespace() are not yet ready for unmapped mbufs. Ensure that the packet is mapped before calling into IPSEC_OUTPUT(). PR: 272616 Reviewed by: jhb, markj Sponsored by: NVidia networking MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41112 --- sys/netinet/ip_output.c | 6 ++++++ sys/netinet6/ip6_output.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 1976ab9803af..3f30c63cdc87 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -671,6 +671,12 @@ again: sendit: #if defined(IPSEC) || defined(IPSEC_SUPPORT) if (IPSEC_ENABLED(ipv4)) { + m = mb_unmapped_to_ext(m); + if (m == NULL) { + IPSTAT_INC(ips_odropped); + error = ENOBUFS; + goto bad; + } if ((error = IPSEC_OUTPUT(ipv4, m, inp)) != 0) { if (error == EINPROGRESS) error = 0; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 59ac04842854..7e3c98270cc2 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -461,6 +461,12 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, * XXX: need scope argument. */ if (IPSEC_ENABLED(ipv6)) { + m = mb_unmapped_to_ext(m); + if (m == NULL) { + IP6STAT_INC(ip6s_odropped); + error = ENOBUFS; + goto bad; + } if ((error = IPSEC_OUTPUT(ipv6, m, inp)) != 0) { if (error == EINPROGRESS) error = 0;