Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2108725pxb; Mon, 12 Apr 2021 14:47:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbIczS849Qw74EVXjlMjD0o0MwTF24MPJ/T6tcUbAnfhZDLqx7CGssutM7xdxvmD5CEoRN X-Received: by 2002:a62:38d3:0:b029:24e:e04a:ab96 with SMTP id f202-20020a6238d30000b029024ee04aab96mr3474001pfa.27.1618264031263; Mon, 12 Apr 2021 14:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618264031; cv=none; d=google.com; s=arc-20160816; b=BHGaTQamIIWVwPZ3kZUKPDN2R8CGLNBgY6EdqlFTGZHMEcM8Ee+57rjR+k9qaiqhYU h5ne+3OLhqBMbgL0xohFrF8o/7o6d00m+N2sO3ARNnZb2n4ZG7uOcrkFizvGMsKu3HMZ wcFBS6EMzEzQcEqfXCLbjyTDuy1d9Yo/vS/kDoD1Akntiqo3dcAn2mTP2CoA4KwlaHDp ZMCbY4jISv06Y6WNNDTvOnufTqFII+fWCwIG9hB67UF1uNj3W375i4uML9VBqkh23Z5u ndSa8a6Ch/Tj9tLCI7JONzTsvCTeniXaTvsreAUYPsleTUdeNCC4OPp8ESi8d7aZ3fwM Dwww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aglOVH1/ofDQfyq2lOWuP4yJwHJ33CZ2qUNpi4Ir6Qk=; b=wwPZBODs0DmZmk0d+634kfCGXnANTI43hEtC8nZlzyCno0W1zqvRGtXwuYG0LpVXpG 8He1wUuo+xNyfYrk4h7Ghb5dTchNQzNFwQnkuSqUuKbX1NGr3/HlVjmCs6JbVUtAtYmW 0WjTqFEz09mwShLL0FlSQ49mulW4JAdrIIZsoI6nfCFprMcBWM4N5EBB2eCVQcLUAqas irJnF9HFP68oAJFh6nEUHovFSmIfThBGDtqxaIHBywYJloMBXGcSg3RjrwTmQR1oq+P1 L8J1oeJmkrlRjgAw+7ohrCrqczNG25X2dx0FMXj8+GeeFqETMlEralXLKBtS73Zy28Xj WejA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H4lrLA4E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n21si15004569pfd.238.2021.04.12.14.46.51; Mon, 12 Apr 2021 14:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H4lrLA4E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241772AbhDLJRO (ORCPT + 99 others); Mon, 12 Apr 2021 05:17:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:49694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239196AbhDLI7Y (ORCPT ); Mon, 12 Apr 2021 04:59:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB9BC61353; Mon, 12 Apr 2021 08:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217870; bh=BugsZkqrERlsJErcRlrgYuqkNzz+IXa+0QJs+9KPk1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H4lrLA4EQqC3fJlwfbGLhUP+K7ys2FHWH9zUKsOc/yGIDU0UaSvrW+xLAHJ/NVc+W 6SiMh+LkW8rmvONl68s7sNZjQ+d/y7CecmXW+N+Q0PFNE65plEr25EuTPkMouyd7HW H4wXsfrED/LW8vWxPHNQkMF67gj8g6hMcIRNtWbg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Mat Martineau , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 141/188] mptcp: forbit mcast-related sockopt on MPTCP sockets Date: Mon, 12 Apr 2021 10:40:55 +0200 Message-Id: <20210412084018.320400737@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084013.643370347@linuxfoundation.org> References: <20210412084013.643370347@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni [ Upstream commit 86581852d7710990d8af9dadfe9a661f0abf2114 ] Unrolling mcast state at msk dismantel time is bug prone, as syzkaller reported: ====================================================== WARNING: possible circular locking dependency detected 5.11.0-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor905/8822 is trying to acquire lock: ffffffff8d678fe8 (rtnl_mutex){+.+.}-{3:3}, at: ipv6_sock_mc_close+0xd7/0x110 net/ipv6/mcast.c:323 but task is already holding lock: ffff888024390120 (sk_lock-AF_INET6){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1600 [inline] ffff888024390120 (sk_lock-AF_INET6){+.+.}-{0:0}, at: mptcp6_release+0x57/0x130 net/mptcp/protocol.c:3507 which lock already depends on the new lock. Instead we can simply forbit any mcast-related setsockopt Fixes: 717e79c867ca5 ("mptcp: Add setsockopt()/getsockopt() socket operations") Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/mptcp/protocol.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f56b2e331bb6..27f6672589ce 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2245,6 +2245,48 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, return ret; } +static bool mptcp_unsupported(int level, int optname) +{ + if (level == SOL_IP) { + switch (optname) { + case IP_ADD_MEMBERSHIP: + case IP_ADD_SOURCE_MEMBERSHIP: + case IP_DROP_MEMBERSHIP: + case IP_DROP_SOURCE_MEMBERSHIP: + case IP_BLOCK_SOURCE: + case IP_UNBLOCK_SOURCE: + case MCAST_JOIN_GROUP: + case MCAST_LEAVE_GROUP: + case MCAST_JOIN_SOURCE_GROUP: + case MCAST_LEAVE_SOURCE_GROUP: + case MCAST_BLOCK_SOURCE: + case MCAST_UNBLOCK_SOURCE: + case MCAST_MSFILTER: + return true; + } + return false; + } + if (level == SOL_IPV6) { + switch (optname) { + case IPV6_ADDRFORM: + case IPV6_ADD_MEMBERSHIP: + case IPV6_DROP_MEMBERSHIP: + case IPV6_JOIN_ANYCAST: + case IPV6_LEAVE_ANYCAST: + case MCAST_JOIN_GROUP: + case MCAST_LEAVE_GROUP: + case MCAST_JOIN_SOURCE_GROUP: + case MCAST_LEAVE_SOURCE_GROUP: + case MCAST_BLOCK_SOURCE: + case MCAST_UNBLOCK_SOURCE: + case MCAST_MSFILTER: + return true; + } + return false; + } + return false; +} + static int mptcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen) { @@ -2253,6 +2295,9 @@ static int mptcp_setsockopt(struct sock *sk, int level, int optname, pr_debug("msk=%p", msk); + if (mptcp_unsupported(level, optname)) + return -ENOPROTOOPT; + if (level == SOL_SOCKET) return mptcp_setsockopt_sol_socket(msk, optname, optval, optlen); -- 2.30.2