From patchwork Wed Jul 17 21:52:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 13735838 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4630DB64C; Wed, 17 Jul 2024 21:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.188.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721253150; cv=none; b=Yb0CgPbg68bWjCYRq5gm8OdSp2jIwi15JGIsSNXwoXqk19Ho3foHyI6onX87EzymYBEzIXbUy65HeCOZ8ydD8ZGVG0fXWzegAC7+jyF1KktKNJqN7VGDGh2I9+dqfWC/JXFJwjNu4glT2r+Dp4h7dFmdg6ScjUA1qlJKVFtlMuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721253150; c=relaxed/simple; bh=NrXJJms9KuICyI2G04+usoSFPj8jcnIM3VKbzizzTnc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g8lsa8kIah72jkdNvibkbYNzVj6p1goYjjOo1gSuDk/SIjOkYZOYiHoykAvh24KPAa0H0di7hrn41kB6SZdftXDW4OWT3yCJo3rMjWXkXzlnP8GMSdGQc/4/r3gjcfHw95MxpQdABIJv/TUfd80fw2WgbszD9zaHEbYsMOYEh6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; arc=none smtp.client-ip=217.70.188.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, fw@strlen.de Subject: [PATCH net 1/4] netfilter: ctnetlink: use helper function to calculate expect ID Date: Wed, 17 Jul 2024 23:52:11 +0200 Message-Id: <20240717215214.225394-2-pablo@netfilter.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240717215214.225394-1-pablo@netfilter.org> References: <20240717215214.225394-1-pablo@netfilter.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Delete expectation path is missing a call to the nf_expect_get_id() helper function to calculate the expectation ID, otherwise LSB of the expectation object address is leaked to userspace. Fixes: 3c79107631db ("netfilter: ctnetlink: don't use conntrack/expect object addresses as id") Reported-by: zdi-disclosures@trendmicro.com Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_conntrack_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 3b846cbdc050..4cbf71d0786b 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -3420,7 +3420,8 @@ static int ctnetlink_del_expect(struct sk_buff *skb, if (cda[CTA_EXPECT_ID]) { __be32 id = nla_get_be32(cda[CTA_EXPECT_ID]); - if (ntohl(id) != (u32)(unsigned long)exp) { + + if (id != nf_expect_get_id(exp)) { nf_ct_expect_put(exp); return -ENOENT; }