From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25FD74B0495 for ; Sun, 16 Aug 2026 14:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786891965; cv=none; b=CY+ZAHlEWxyUWLR/SFwygAI61ulw46wEERq+lXKp3YFXX88Sh56BH+TFLvHH1ljNX4N/6J2DIJ4K7+TPLSg/AlY7bJKxdqQUF1ccAXYDC4pmClaZQoGgWXPl8F6AyEzZxkESn3SgPX5sOoc7wmbMy10HD516U7SbVgD3Hwg7zDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786891965; c=relaxed/simple; bh=TZ/jMhLpSpiWuZYwnBKNAAe642VAkQvXE89J79snnF4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=TaqTb7pWiequ185i7jeHmeDJEEOQ1/Z70dfydsFW0DsUbQ6W/69IEXdjEi1upstH887kM98NmAoBluXn6vLjxxAuFtWAsk5xgflTjTBsLOX4czkGubwizyqJg3uxcq3GcwBIDMXJVF2OvBZpovUYIirIMcn2ZXuX/YjI019XVDA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MjTqY+s+; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Q3mJ0Vpm; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MjTqY+s+"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q3mJ0Vpm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786891963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RVhpy17ZCwCJlu7ncEkrfmPtQ9a8yWWDGxgf/0hovtk=; b=MjTqY+s+UFZCHlHcIlFvUZrARfOYEM2IZVauEAOtuzx8178pHtp/sIUS2cKMwHFc1PDL+v 0pgw2iy9YVUUew6fWjAk8umNkUzH68yZ2j3/gfWpDI2wY9lpAO1XtLVx3opZxnLSGLOePU QrPvPr6rZWIcYcdq5/jui5c7aWvC4DA= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-ZVLFkbiWO3i8gRw96zXOCQ-1; Sun, 16 Aug 2026 10:52:36 -0400 X-MC-Unique: ZVLFkbiWO3i8gRw96zXOCQ-1 X-Mimecast-MFC-AGG-ID: ZVLFkbiWO3i8gRw96zXOCQ_1786891956 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-936e393061dso110139885a.2 for ; Sun, 16 Aug 2026 07:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1786891956; x=1787496756; darn=vger.kernel.org; h=content-type:mime-version:user-agent:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=RVhpy17ZCwCJlu7ncEkrfmPtQ9a8yWWDGxgf/0hovtk=; b=Q3mJ0VpmOcL35+Cglw8zZrJEvGVCd1/VBVmmW4zVUlKzS7lwNzFlqe/037liYojHrM SeD5mBxM9JkJ/NaIk5u/EkMK+L1kFXoIAPXgNXapHGUAOJFAjZjbi33jyegrxakBNnek Py0JSn1N9wpGcqFy+2eyFnwudYvbF9XlEciTlkzKoHM6inlZtQzZyecRT4DnO+r/rNPX jczBXrMMJ8uvyvHcPNq2tm2u19JJNW+axTdiM+iWE82eyoWQV1KwcwUYK6ALV6LG1Ii1 ETWD8eZwvnbyu6aP8cT97JXJQZfjR2ESmyzPCoEob6t3mwzHqIwOhHpz/lRnoCOayUbI 3JtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786891956; x=1787496756; h=content-type:mime-version:user-agent:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=RVhpy17ZCwCJlu7ncEkrfmPtQ9a8yWWDGxgf/0hovtk=; b=Sw4vlZXJg/pFWaTcGLy9v9Z88PSGg6S4lYkNgnXFaAyjfNzDQy2RzhK9zhCLKB5JJy PpTE5Uf92XI4tjFICtAindgDPe4vjocLQjU9DjJNcbcaEEYFaP3WRESFuskuxYtNuXZ/ HS7sVFGzxy9P+epp20dVvLZ+y9EOZlY7d1qMf1W//HyatsvUmXKGo53ScJ0UhXrCUEDB 9WKOn9ON5LMHBEqnzxK/JvEl5ydfxGqgkDVmEopKWsJ0VRB9wlm14uL75tXG3K1z4CBj m1wGVEeuvBxWQBvlUH4b1RIN0Y4x1vGytkFXWUEKVUyMUIZyDOtL9eVJYb1fF6uF3Vho lOUw== X-Forwarded-Encrypted: i=1; AHgh+Rpb8ImQxjxqfhSUImjHAihpH7Dn+x4LQn8JJZK8PTM6ZZzz12SXgz5iReblCRCJo7daAaU0iQL+kCRya1M=@vger.kernel.org X-Gm-Message-State: AOJu0YyjSEO9tzcs61UzeJKyEvESAwo4qsSof6Rlg/YrOuBMSU5ueg2x AR0gPMOfuzWNaKYup3Rh3f30hV/SlXVcH0O7kdPevlg5QTTm1imZV87740frwJXXhL5V1HT7k7P ELJ7JUSYktLvHxkKpN8PuE5LK55G9cRfm0mJC2Q1AuA4pjpvVGwIyaFDG6ZB4hv2QGg== X-Gm-Gg: AR+sD1274y2qDgbk4e5pvUKCCEpqqNO9StGYqtR1mpVIuM2QyRdiCAyoDYwzFIjWg6W /mAgQT8yvzL4HRKtd8geb23vJGKMIR4OoCPpgHrS8PM7nGaSR/a25mZLvUC9tGcB8utWU6sDRzZ E5r/Y5kfaSS0cxKpMYmSvA1FNUjybh3afhT7QFznnIuxOAyAa1/fp8nSaeZIub3bv6bDe5/Q62+ BvdT2Tc94hALrP1liTWfgE37OI3CBWEVg9xTCCrCzqcwvfJ06paW2RfLnXA+Z06z9+ZgHPvcGL/ g8lq6VUklJaJCvmBjzakzuEJbRo+4c3+gEe2hkFlr9Co3DSyBoa2Pw+i0JI3r9CK9gPqrg8TTCI wXdCZEAu6nh59VLA6J3QnTrsrAdEe X-Received: by 2002:a05:620a:7103:b0:936:dbf1:f4c6 with SMTP id af79cd13be357-936dbf20ccbmr1613142185a.25.1786891956029; Sun, 16 Aug 2026 07:52:36 -0700 (PDT) X-Received: by 2002:a05:620a:7103:b0:936:dbf1:f4c6 with SMTP id af79cd13be357-936dbf20ccbmr1613137385a.25.1786891955558; Sun, 16 Aug 2026 07:52:35 -0700 (PDT) Received: from aconole-thinkpadt14gen4.rmtusnh.csb ([216.212.25.12]) by smtp.gmail.com with ESMTPSA id af79cd13be357-936ce250c20sm760155685a.47.2026.08.16.07.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Aug 2026 07:52:35 -0700 (PDT) From: Aaron Conole To: Ilya Maximets Cc: netdev@vger.kernel.org, Eelco Chaudron , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , dev@openvswitch.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH net] net: openvswitch: fix flow mask use-after-free on flow deletion In-Reply-To: <20260815005915.1097270-1-i.maximets@ovn.org> (Ilya Maximets's message of "Sat, 15 Aug 2026 02:58:56 +0200") References: <20260815005915.1097270-1-i.maximets@ovn.org> Date: Sun, 16 Aug 2026 10:52:33 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Ilya Maximets writes: > The commit in the Fixes tag below made so flow->mask free is scheduled > via RCU right after it is removed from the flow table. The pointer > stays in the flow structure and it can be accessible while in the same > RCU critical section. This is done to avoid requiring ovs_mutex for > the ovs_flow_free(). > > However, while removing the flow during processing of CMD_DEL, we do > not take RCU read lock before the removal, and ovs_flow_cmd_fill_info() > uses the flow->mask pointer afterwards. The RCU read lock is taken, > but it's already late at that point. The comment on that line > acknowledges that the lock is cosmetic and doesn't serve a real purpose. > > This leads to use-after-free if the RCU grace period passes between > removal and the filling. It is a short race window, but it is there > and can lead to a real crash in case memory allocation for the info > takes a bit longer: > > BUG: KASAN: slab-use-after-free in __ovs_nla_put_key > net/openvswitch/flow_netlink.c:1996 > BUG: KASAN: slab-use-after-free in ovs_nla_put_key+0x2463/0x2e30 > net/openvswitch/flow_netlink.c:2250 > Read of size 4 at addr ffff88801ee89970 by task ovs_flow_del_ec/9487 > > Call Trace: > > __ovs_nla_put_key net/openvswitch/flow_netlink.c:1996 > ovs_nla_put_key+0x2463/0x2e30 net/openvswitch/flow_netlink.c:2250 > ovs_flow_cmd_fill_info+0x420/0x9c0 net/openvswitch/datapath.c:930 > ovs_flow_cmd_del+0x53a/0x970 net/openvswitch/datapath.c:1467 > ... > netlink_rcv_skb+0x156/0x420 net/netlink/af_netlink.c:2556 > > > Allocated by task 9487: > mask_alloc net/openvswitch/flow_table.c:967 > flow_mask_insert net/openvswitch/flow_table.c:1012 > ovs_flow_tbl_insert+0xea2/0x1a90 net/openvswitch/flow_table.c:1084 > ovs_flow_cmd_new+0x7e3/0xd90 net/openvswitch/datapath.c:1086 > ... > netlink_rcv_skb+0x156/0x420 net/netlink/af_netlink.c:2556 > > Freed by task 9485: > rcu_free_sheaf+0x1e/0x100 mm/slub.c:5978 > rcu_do_batch kernel/rcu/tree.c:2645 > rcu_core+0x59c/0x10c0 kernel/rcu/tree.c:2897 > handle_softirqs+0x1e4/0x9a0 kernel/softirq.c:622 > ... > instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 > > ovs_flow_tbl_remove() must be called after the ovs_flow_cmd_fill_info() > to avoid this race. This also helps with cleaning up the forced cast > and the cosmetic RCU read lock. Before the commit in the Fixes tag the > order did not matter as long as the flow object itself was not freed. > > A wider RCU critical section could be another option, but we have a > GFP_KERNEL allocation in the way. > > Reported by Trend Micro's Zero Day Initiative as ZDI-CAN-32042. > > Fixes: 56c19868e115 ("openvswitch: Make flow mask removal symmetric.") > Cc: stable@vger.kernel.org > Signed-off-by: Ilya Maximets > --- Reviewed-by: Aaron Conole