Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796034451; b=Jk52K7xRH93lQDN9mj62PKlFxXp0UxSEuCdmANkqd3y2FXF4cZcUnibRpPq4+6hxmQad 0tikaGgifCxLbREPT+1r3UD9DtRiqjLhNOy84xksWFVpRM+gIhlvADnqZ7ixQDFRp2pgv ex51+BwUVcxqzeXP91Bgd076PuUSgWny0wEMJN6PD2lNKGW+l09QBmseEZzzmRyD1tUQh WtqICD0PAKxHqYLI1DC+g37TBP4DZzHBu/0cj6v/SMTk7zyiAjDov5qAyKUOK2n47smud 5Slviq0cqMCYLSToB/rUufvKOjcr1EPZJCsYIcFOu5zA/XOIoCeL/SIUXwrdXbYL4TA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796034451; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Reply-To:Subject:To:Cc: References:From:Content-Language:Organization:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=lsYwiCEwJ1P1q8bQWXoq8SnKepkL5SvrlywQ3Ro7pvw=; b=wAkqOBuRwW+FrYOfWg9cqBOvW+fO3K/iBLXBl4a9jW9uPtG5OEwkaWSoCb8+qWmzf2e3 eXmjfglg/eow4vJbrR+NF8/6OGfrW5XctnIKqe5al+rtULI2hN/C/flJYwImhrpQeqjxG 3ogER1VxvgskaenPk3D0woRp3djBjH/BBiiYyWiiPcXiG3PdO6VN5cMp8hFBzZnBjAJpd /NQF4Y1u3e8X02tfoOo9smhKt5kBa1JnkaVeo+w0DzJgyZbcfLUp0udKJJw+sKEjaW0k5 aq4QOmSNK8BcOLyBHEaJTkCUy5vEQOdbtrlrImtMaUumM11znmtndy81mYP9qknfzMQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=6wind.com; spf=pass smtp.mailfrom=6wind.com; dkim=pass header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=QmMs2SGT; arc=none smtp.remote-ip=209.85.128.44 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FE7E606A320 for ; Mon, 30 Nov 2026 10:27:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1FE7E606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=6wind.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=6wind.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=6wind.com header.i=@6wind.com header.a=rsa-sha256 header.s=google header.b=QmMs2SGT Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4bb66245c51so6188965e9.0 for ; Mon, 30 Nov 2026 02:27:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1796034449; x=1796639249; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:organization :content-language:from:references:cc:to:subject:reply-to:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=lsYwiCEwJ1P1q8bQWXoq8SnKepkL5SvrlywQ3Ro7pvw=; b=QmMs2SGT3fxNfpXaZ1RQOHh3m4Y/rgkJH7Bf4CnUnfJTq9SMmiDx9EGygw8PLg/QeI RJ0giWYwENW2T7Z1o9Qi/FstI6S3LmNN60ZOwPWdXJluNSQJF0nUwTf7WZ9d5cw4idVS 3YEqCgTImMmTS/gXQ4JZJ1KQsuEUyuumo3rw5osver2ay1Ohs8qK2hMLh6JiKt9RmE45 sf1/9XJmZdVnY02CJcsg9MWELTuShEon3Z60TLRxKEh9v4K72kV1rJN3yzJjE8xpqSBk 0oBiI4D9BGYyF9dd7Zh9y/7jTYl14LXDZ/eztm0vUpyktb2Qsa07EDpblKWv8iDJyMPQ 1acA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796034449; x=1796639249; h=content-transfer-encoding:content-type:in-reply-to:organization :content-language:from:references:cc:to:subject:reply-to:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=lsYwiCEwJ1P1q8bQWXoq8SnKepkL5SvrlywQ3Ro7pvw=; b=ZpCmNNmRp5nporkV722d7T5VLoUzIs5kzwL9B+3xxrDUHO06DIwnWiRF+Q0n+MbN4X XlApG08ZeNZvDEXHJ58igCHB7TAtfeNQTGZFOv53u3j0FfI7sPjqr69u6P3uGdci9YCf 2yqrOMgqpi4OmEr+lWBcZKz3LiaFlaUfP7wOSUFpIFw1bCteU15ok3A6yfv/jRNxfuFx /QqHtC2PBHC5g6D1W54CWO16DEcWtO9iydlcOjTWgKjJV7CttgHb1Z/7CyJuNevzx0Bb uqgEhX/ZwZT3N/8tx1MgrU4CRgJvY/Kvo/RN7nA0qKpFGaxYGb6VovwofljQYtYDf4qL 6amg== X-Forwarded-Encrypted: i=1; AL+hErFPhcHQzZYr+MyV7Um4IpPJLzCVCSIGqqgplt+XhSPFzeAGwLGleBV3AU10iq+gv3W2DaDFZq0cxX0KVtDsdlA=@vger.kernel.org X-Gm-Message-State: APuU4Z+zA3APF4r3FDYizOGeW2NttgnzC6GjETN0CR2KR9e4JY3u4wX0 TSPUUDXQtFyfg0X/GYvr2p6ZciWE7wvu++PfDHL9SbnWxkSTP+7yB6eIaI9XtyMMppM= X-Gm-Gg: AZFdTZc2ThEV/LEPsDYTFwhtIg7TKN6PVOGtjnk1Zz/pSFkuTWno14MSheWa7XfsdK8 PMx/IY8LE9KYRcGliGNlEKeAyPCKkmVTryRJ3kBIbn45SWyF1EdpLTHsJfudgNJFIQwe7DHY0wz AT+ZTlpHfLsi8gI7vxi9kgRpVrh9fpOEOc5EmcNLLLIT1FBXHmbAPjkeYpKhqGoLLyUqnUBa4Om MKE48RoZWrI/nahACVGEh9ADUQdSYL7FWOsaDhl3yLv7dIUs4A9VMivS+JAW+zgdDvsjonLTJln hF/YIODe0TZl1R1udv4pp970eth9pQ9fwtDhmDGNRZ41F/q3nEJ8XBpiWafviMg5h3okvfy/S0B lrjyPICap9cjis9OQvl43y5e10TO+mukitOqD1wM5OQMByXEdzmzARrv9F9cZdZI6KcSy3PuMpX EyM8Ldk2glwIehypvs7nM69a+97pE1Jsm0gLIe5vBaOs4Gu4dFh8MMstGM/R+/odCyO8+M5vPU5 E99ddezGOC++/eoUKHlsmrhc5jVT4xIBXt7Mgobf1ehP0+Htg+NL4to5InNaAbTzJwNz4Rvb61/ IsklvcSew0cpHRRKsKTeGCUSLI5CpC0kzBLmRVOQKtbv0GHCERQ1ooqOQT+VjtLSmqF9FujZ5wg y+3eUPA== X-Received: by 2002:a5d:5d0a:0:b0:4a5:d259:4c57 with SMTP id ffacd0b85a97d-4abab7df50dmr75625619f8f.2.1796034449424; Mon, 30 Nov 2026 02:27:29 -0800 (PST) Received: from ?IPV6:2a01:e0a:ab7:2110:6a1d:efff:fe52:1959? ([2a01:e0a:ab7:2110:6a1d:efff:fe52:1959]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a680355sm52490949f8f.27.2026.11.30.02.27.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 02:27:29 -0800 (PST) Message-ID: <25359215-983a-4fb1-af0e-810e6ce66a6d@6wind.com> Date: Mon, 30 Nov 2026 11:27:28 +0100 X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: nicolas.dichtel@6wind.com Subject: Re: [PATCH net v10 1/2] genetlink: Reject joining multicast groups no family owns To: Anil Kaushik , netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, idosch@nvidia.com, willemb@google.com, jacob.e.keller@intel.com, jiri@resnulli.us, fw@strlen.de, martineau@kernel.org, v3rdant.xiang@gmail.com, aliceryhl@google.com, linux-kernel@vger.kernel.org, nhorman@tuxdriver.com, shuah@kernel.org, linux-kselftest@vger.kernel.org References: <20261127032246.2886407-1-anilkaushikwireless@gmail.com> <20261127032246.2886407-2-anilkaushikwireless@gmail.com> From: Nicolas Dichtel Content-Language: en-US Organization: 6WIND In-Reply-To: <20261127032246.2886407-2-anilkaushikwireless@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le 27/11/2026 à 04:22, Anil Kaushik a écrit :> genl_bind() checks the GENL_MCAST_CAP_* flags of a group only when a > family owns it. For a group ID that no family owns, it returns 0, so any > user can join it. > > A family registered later can get that ID, and the socket stays a member: > nothing checks it again. An unprivileged user can join the free IDs, load > a family module with CTRL_CMD_GETFAMILY, which calls request_module(), > and then receive the notifications of a group with > GENL_MCAST_CAP_NET_ADMIN or GENL_MCAST_CAP_SYS_ADMIN. For example the > drop_monitor "events" group always gets ID 1, and is free until the > drop_monitor module is loaded. > > Fix by returning -ENOENT from genl_bind() when no family owns the group. > There are no group flags to check before the family registers, so this > applies to privileged callers too: a program that joins a fixed ID such > as NET_DM_GRP_ALERT before the family is loaded no longer gets its > messages. I don't know of a program that does this. One that resolves > the family first still joins. Say so in the comments on the static > IDs. > > bind() takes a mask of groups, and most IDs in it can have no owner. Such > a mask used to work, so keep it working: netlink_bind() skips an ID when > the bind callback returns -ENOENT, and joins the others. Only genl_bind() > returns -ENOENT. A skipped ID is not joined, so it is no longer in the > groups that getsockname() and NETLINK_LIST_MEMBERSHIPS report. > setsockopt() returns the error, as it asks for one group. > > This does not cover a family that is unregistered between the check and > the point where the membership bit is set. Hitting it needs a > privileged module unload at the same time, and the capability check > already has the same window. > > Found by the Sashiko review of the gtp multicast group fix. Tested as an > unprivileged user who joins all free IDs, then loads gtp and > drop_monitor: > > Before: > joins: ok=62 EPERM=2 > gtp/gtp (ID 15): member > NET_DM/events (ID 1): member > > After: > joins: ok=19 ENOENT=43 EPERM=2 > gtp/gtp (ID 15): not member > NET_DM/events (ID 1): not member > bind(), an owned group and free IDs: ok, member of the owned group only > > genl_bind() was added, with its first capability check, in the commit > in the Fixes tag. > > Link: https://lore.kernel.org/netdev/179324692107.3134.14443689892607921337@kernel.org/ > Fixes: 4d54cc32112d ("mptcp: avoid lock_fast usage in accept path") > Signed-off-by: Anil Kaushik Reviewed-by: Nicolas Dichtel