From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796034451; b=uLe6ktLMQH6tB8imd8/X+WgxsT8Jf2+0/yBWBT9vKUPL6F//NsvLyyV3+90b+RnDNnD/ o+6a3SIH92xGizUGjfL6xfDFzrkoAdKBFJbzA9nN6hUqib2Vu+PTW7Wo5DjadpzfyVXKi txyKcwu4vM8TJ8tFx34L7cnqh9l/wCfPKwaDENSIwKkHpJUW3hz7x+qzFEsINhZFT7kmv q7wrVToHqhybgc5oeQy208PR899VqkEZ82UkiG99jWasE9AUdVZetClk0CglR5slENPzs 8pSnzxZUsHHkZ1buTJ+QsfYQlSqw95cHio2IIi810e/GDvHETz2ggRg/ECYfHUqenSw== 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=wrAxofSfOW3n8QJkWQlbNAxP1YQs7klNiBKaqSsDy8cwS9HwWVR+4tA1CLhNAg/CJqSh 8IVtcHSbvLlMcBpMBENvyRXGGSzGm12n6X3dyxdvRcXusiCiOJjwGZdJkEyqZv3xS2Lac /eaxT1SXMF377yK0e2dk5EBafXN4G3OA/835V837mSWldF5vg4pGP8LKZNMBe9BWHK4py CXq6ORC0ybo41cIP1mhbn9KFLoi989FrDSySqFNdv4dcUBfxg4KvtGh96gwr43N1SyFOO ofleaAScmSaRv0mrqwid+Mwgye2EjE0C/E3IYLaKxOY/SeQ7vM1TpcMwTOybkmkIV9A== 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.221.41 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 29E46606A325 for ; Mon, 30 Nov 2026 10:27:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 29E46606A325 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-wr1-f41.google.com with SMTP id ffacd0b85a97d-48ff6bd58b8so1081214f8f.2 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=lbmmM88SKnkKpSJChCv8Thq7So1zG0VElOx+SEMuDVUy0JAxxVnSZMo14aYb41afmd YbbavdWQwCN5wNULAlTw9gpMTaniSCu2RZdbmP5aEv2QYsWcfsqY0iiZ31RK+o3zwlVf 7uzEUyWdu/5sHpumayIKimcn6AT62omiUP9jYSGtjPeLCqBS2KKYy3rRun5MztGWnYPj v846PlXx86YNs5qsSre4br+6RtHBd+mwToFqzu7TdAxmHL01AlTUoyyzMWDH8uDkWIFA AGrFiyC+oGlthX28ZDE8R1PvERSo6MdeEo9li2eX1CQE5JSDcV612+mb0zCMWq6HdiA6 511Q== X-Forwarded-Encrypted: i=1; AL+hErHBEsWiXtg9tklzPRsoeheAzDonfPA1VXNEkux00y1DuKYJWoM1qnBZGeppiaxKTR5yeHDbO+C0bLXnC8I=@vger.kernel.org X-Gm-Message-State: APuU4Z8T+5krTKvc4Q7j/J5ynactyI+MxWzHfFmzM5uaXFRPOj6WqeIC Zw0gwoOQ/VcvMPNxcKJ1Wrur8xHMFjMbA7OkcTGxCMQMdMluydMt7DAlo7K2g2HPOYk= X-Gm-Gg: AZFdTZckWxGjoYMuEqIg8sHEP8Tvb8id3hUfPUFKGk55A78B8xZy345tIxoICIM+NmT KbPZI0w4i1OOIjhV4VN7vDKk4SXhjwiv0wOuJDlr02k88jY509GWVT32KUaPyHY/32PQWeshAjo aUw7JgZIjT22ha8V/LbEPB3sgF3jf7BcZJCfLxpscIBWq8QWkZ6vPwxJI7xMtmsNY5ktKZxkhs0 ZRctw0cAgJCcjv/c8jHr339o2hZchdKzxJbjWlPsB2AHozWYMoYQ5Azh3mWMyjSaMlFCdtP+/1T LUhdDUZQPioKnGM9GbXdcfN6u7sBUhOPpscSx2q7vfOAS70eWgQjK5jaZxlq/h2S4r8hV765WYI uuEh1D5lG+swSqVcB+OE62aU6EA7bz+LEJ8au4WDaWUGrbbo9+zI26IiTypJhIC3TZ+3wf9Ifwz vhITGAAgp/VAW7mgP/kfE3+HathCAFbInsViSvASqVav4oNngcuUijnrzs+j42lv7mpXc9lN/A+ ZTG78+z+3l50mfzTHz1vrGeX8yxqS51r/uZkCK27ubZkhHAAyQwCYARUDSCk2u3ncRVBVBMXq2g MFHjzO3GQ0Fy9jBLIH+kLX4qErPSoJK8EzZGHH5LFpGP2uUJhfqnsRST5tcIzKacoLpO38F0aKX fkNkh+Q== 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-kernel@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