From nobody Tue Feb 27 20:47:52 2024 X-Original-To: dev-commits-src-main@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 4TkqLd2gxKz5CPPY; Tue, 27 Feb 2024 20:47:53 +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 4TkqLd11Mnz43Yc; Tue, 27 Feb 2024 20:47:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709066873; 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=4WXvp1v1dDiwmh5IDUSfXwGLjisnCLskn3uTo0v11KI=; b=iLyFkCQ0nlp88PTVr/GRLrmofZY/UXhHkFAV1X2lktP1FHtKnR3VtskV7A0o+g+oGWlBGZ IUngg5s6OG6hl3HN1hYZrprMrqdTAW8QLvh8uIYkE5To32tLBbvdbFdZGNY3eXKjazNowh J5HlY1gsz0rhTE7ezc/j+8ROqHfNkizgquxfC3SLWIQ0XfqIMqLMZa1W4MUhqX0NA3yRAR KYDP9kLuDbAJL8qtocgLWytPJf35BvKE9trTj5MYsFHHWLNAL0X51KQRwigtrY6Ys4RWUz iF0fCTM0DCJIzQuZLEZyGyk9srkj6HfzSvz3l5J6UuEXUUl6/yJtC4eLfRyN8A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709066873; a=rsa-sha256; cv=none; b=cRu0G6Xd2a3ORbSOzaG3IOq9qgwemyBckqtqQZtxcNzi0XoKmTa9tspuEYVJSd4xgxltP6 CbZxop/ifkL1aotqfQfGD0dxGZI26LUQZHarrW8k0VRlDw+PKXCGjicsasbOZ7M3kYUOJ9 lcmmmX2nQ2YFKhu3hu0hmurfxe8YFVwA+IgJfcB0dtR0J8J4sAYRBzGLSDsxsBdY8ralgS 9RyiEOIdenr1zEF6fWQSa5jtkmmgs0byhFu08LzRJu0KViwTAxC5JBLXMoEJoh7JlbNxUv utu1OZa9O13ipo7cY9nUfp+gt3EPNgr+7lMr7tbkWFoN118X72GfwOR8V6E2GA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709066873; 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=4WXvp1v1dDiwmh5IDUSfXwGLjisnCLskn3uTo0v11KI=; b=urVaW+wuD+aaFijEJvcYMl4A/V/+ARZh6SdoCoEVndgn8ABMmA+a4MmvA9hDtPVgqA1FWh wVnNZFvj4WhA0V1L6VVfsx6TOxYbiMcIXC/9Ll12VcY56eZp0mlvFDrglrq1aI7a0BJPs5 lFWuqcvCWoJtrirbzN2RBU7XUif/fZZFpbSwH8yLC8RiZ+03e7xfmXBRtt+Sf4eh+Yqmu0 PB8JDMdtcQyI8PlJSjnhEL8ZRE/NaqaWc3mHwC4LLwxEOQrUlKkYHPDKTDBSbKcGElDYUd ysjXq9WPI3783BZdPUYkmC98LEnn1dUKpwzzHe8WlxCr0xhs+nDMJ9+xAyX6kw== 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 4TkqLd05SKzSRW; Tue, 27 Feb 2024 20:47:53 +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 41RKlqRk094806; Tue, 27 Feb 2024 20:47:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41RKlqFZ094803; Tue, 27 Feb 2024 20:47:52 GMT (envelope-from git) Date: Tue, 27 Feb 2024 20:47:52 GMT Message-Id: <202402272047.41RKlqFZ094803@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 41ce9c8b8891 - main - netlink: restore original buffer if nlmsgs_to_linux() fails List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 41ce9c8b8891eee82b2824c733f103e6671b5731 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=41ce9c8b8891eee82b2824c733f103e6671b5731 commit 41ce9c8b8891eee82b2824c733f103e6671b5731 Author: Gleb Smirnoff AuthorDate: 2024-02-27 20:45:54 +0000 Commit: Gleb Smirnoff CommitDate: 2024-02-27 20:45:54 +0000 netlink: restore original buffer if nlmsgs_to_linux() fails Caller is responsible to free it or reuse. Fixes: 17083b94a91563aba15ba03d1c74796a35bb1c26 --- sys/compat/linux/linux_netlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/compat/linux/linux_netlink.c b/sys/compat/linux/linux_netlink.c index af172fb27ba7..d2afec24fe71 100644 --- a/sys/compat/linux/linux_netlink.c +++ b/sys/compat/linux/linux_netlink.c @@ -548,7 +548,7 @@ static bool nlmsgs_to_linux(struct nl_writer *nw, struct nlpcb *nlp) { struct nl_buf *nb, *orig; - u_int offset, msglen, orig_messages __diagused; + u_int offset, msglen, orig_messages; RT_LOG(LOG_DEBUG3, "%p: in %u bytes %u messages", __func__, nw->buf->datalen, nw->num_messages); @@ -558,9 +558,7 @@ nlmsgs_to_linux(struct nl_writer *nw, struct nlpcb *nlp) if (__predict_false(nb == NULL)) return (false); nw->buf = nb; -#ifdef INVARIANTS orig_messages = nw->num_messages; -#endif nw->num_messages = 0; /* Assume correct headers. Buffer IS mutable */ @@ -574,6 +572,8 @@ nlmsgs_to_linux(struct nl_writer *nw, struct nlpcb *nlp) RT_LOG(LOG_DEBUG, "failed to process msg type %d", hdr->nlmsg_type); nl_buf_free(nb); + nw->buf = orig; + nw->num_messages = orig_messages; return (false); } }