From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796034451; b=0gfLiKAyZf4wbSkobYmlLDRFts7jaxDoOQisKvcwH7RrlbjVrjILEPYDS6NqHtqK9nkF jI6BMkaM3FSxOSLRazjxkoiaLT5lj3/g83puet9tEmSzdoSRapL+wVA8IwE0z+6UTvWUN s1SaFWYp1XFSAl+Keo8Eyv8f73T38TCVZ0v1O8AFkJt5mgE4D8QQvNx2enFYtSzUTAFp9 qmB8jAttj+6c9/GsuJUbbViyuX5/HYbXtqQWg5qR9qE0lYz3zGs3/Md8Mu/qIYbETINI0 FUeBKZ+obPse4n5Y+2JGJbe3whbu0ziCIJL5qkeO759YUj3g7TurozyW+VQrJI9j6gQ== 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=o2UgdgZD48IdH4xLL4ZaEwhmVeg3hhcHMpB6ABVZCsTip7hWuChmMgULiNxmWCaJ8xOv 9GmCKqS+ajefvsbysf8Jkr8SMa4og6PSMVwuPoIwoov1odsn9lenEf1UOfHkim3SyK9iI TIFFd9ITXUlKrvT24CXYo05e0bsddgQMhCI7sORtlcTP3mzep+OenJOocdzap+YN9PSyp +72bk3YuLgmZ0KcnBsk/Cyfg+CVdvy4ka2xxtMF6xbj1jiqNiPtTV7m9NzHOadddYZ3cb VYoFSisnf/Q+bQe/cn0JXKTo0y1wgcCIPzxsZh1igWuXtLvID+SooRkmuRFWyI0ls+w== 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.44 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.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 1ED7B606A31C for ; Mon, 30 Nov 2026 10:27:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1ED7B606A31C 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-f44.google.com with SMTP id ffacd0b85a97d-4a8eed31158so874674f8f.1 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=O3h0x1DFt8ggPytDyoYih2KHvnzU3pb1mqD+0isqjg6b5H9AmtkWY5sSD3HeLTwkXY NNCtIfymvEhf2u1f0NPP3Jr7avopQW1ajOELhCDARJwDLFMZcqEMk3/k08OH7XmkvObK nG2FVfDUSld9adRSXfa/arS4ya1Kjblr2pQsXaItSy4V4U2Df7OficIvnVOa89HvjnOO /laGK71JS0bKrgc3Q8m1HvZJkC5Ybu8zUW2ztsNF/dxWeHzYxl57zxyLK+mgi+IlDWQS rGLh7tfsbxvzYiNwpUWuX87DNpiM4Y2aG1ZWj64pxJ88kYQWyc/wntSn/FLzQit9K5sB uk9A== X-Forwarded-Encrypted: i=1; AL+hErH+SaQokrM/8yN57usUmRZd0Vt+BLB6SVB6DZV1w2EHaSFtfdWR5w9svwaujN1yKpWbWDs28WE=@vger.kernel.org X-Gm-Message-State: APuU4Z/LhOCnr78l4d3A1QbupMoW3t9EAEy67oRTA5kTiFZqskQxWg0g nx4zUezsbCx305ekc7ZKCUdvXnOBbbdxWoUg5+EQ4wTU/OPeK7eoQ+Eq1ScjYUQBlMU= X-Gm-Gg: AZFdTZdVOPvIoYof9IRJq5/Y1Jv9n5cvRNCXvVpfeYyE4c7DUnOvx2kFjNDGJItrVcR FLvVm6hHPFYkqN6FQ8mXslgP/MjRZbkfcF9ftrqHiMv5UXBS7latJ8tYGNJ8HVYnhkOnvWEqfQc NrDp0d5pzsyxuRE0m298/rxZhI9wCfeNfWW/HZTiBlEI8TJ08j5iNee60pAzXip8UpBdLykXExq lDYHDIppxJ2AWWt0M3YrJDHxTxDH+wcTxb5aihlfMYB/wjT+Rs1iakHvkeHNTSwYSmjJ8jK7Yzh hiZwmpwDHphY4Y4RB0AM4m2/V+FN0yeFpccxBPfpEd2FyNcU6f8tVXdl1cSY1vhnvypACYD1Ye7 9vwo5A0plvqotVlZJpXCRgnM2L/228mZfiz79NEsqgF+/RxFefUAxeEIE1rRYmGsx2fiBWrXn5u aZf89bfIaBR1cAY+YvGL5ba+84I6cwrSlijS2O3gjOlvx82VpXySSBVVh+p3xGj5DQGJZcPiMv1 3uRjajFJI/qNScYc4tshAA3dx6DZISJwecwxp9vdEintV6fBCmTGpyhfsukG00bKg+ALDHe7SHN YGd5vQgv7r/E0IchTI1d+INqF2KI5J8gh6OGJBJRDnhZfIhfX20K/5ln8DhFtPYQHbdha4wdu9F 6B6p6Hg== 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: netdev@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