Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3081714pxj; Mon, 17 May 2021 17:18:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6k8rt9vHTIdrkYaq0FN3TYlnyUGHJjo1uE+VhzuvfxoyhHji0vskW6sqlj8pbPlaNY9Fw X-Received: by 2002:aa7:cf06:: with SMTP id a6mr3545027edy.138.1621297082453; Mon, 17 May 2021 17:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621297082; cv=none; d=google.com; s=arc-20160816; b=DThclyMY1YFr12IY+KT6hvOluf9pb/5aAvgb+gP70eR8PoCpCdeV9DMOKmpq+2isYZ n4uwgjAN15FbFoD0ZYsRML9m7lgdujHd4IG6UH3QH9t8+fF8nEFtIE9+jxp/yQ3ROB2e 1tQ3vME666XBLZDqSh30ACCprPNxeLTiwa/soccG6o5WMfRFZPCelVOEm/IOo9q/U0Qr oR2zr6hGjHpjJSMAzMfB46M+aC6kzotLyvb0jMnMO3+8itDJMthVI5PHSayYvNm+cMKz OHWYHN0JzPlAyi//cnR6GBkxdJw2V2Z4uZJ6z6iJw7yA1tLuAE544fLYNrJfXX9zVrgP eCSQ== 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=o1Tzmi1CmxiuONkwGWIe2XcMQj0PrlXZYktFrmuvPnw=; b=VxtBt9WHDu1LnuAsR3Q2DOPlba3xeu0GqME7RbnUCh2ijgDGoUDhgeXDePHQu+u0mp DmKUATdUZB6n5jt+Px7Cw2anYoDXXWhuhUNPOSXsXqH1wB9/P/60DNbBPuzV2BeY7JAK NPfGp7UciAzMvXNbn0VziNR2/zCHQa5OImMIL7+6mvufUFunGbja5f8Gd+QZaV4K1sQS cI96TvfO8p36P86zYVlwd6Z1bRgmQkG90plXn8mqPwC7q66NyOY0wj2zOlW6c5aSS7jh NGaKiTgzZgDSakUKF1E77wZ5myhyt02R1fLX5m6745EOQUqwXkgOp2I/KN4Nio0bBQII 2CFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QxGoId2v; 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 y59si13205068ede.390.2021.05.17.17.17.39; Mon, 17 May 2021 17:18:02 -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=QxGoId2v; 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 S238960AbhEQO2J (ORCPT + 99 others); Mon, 17 May 2021 10:28:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:53176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239454AbhEQOYL (ORCPT ); Mon, 17 May 2021 10:24:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0CE0361463; Mon, 17 May 2021 14:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260756; bh=rpSqR4MR4S37JY+TbR1OCsT8vEv9VQu8ZuJfas7Qs2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QxGoId2vsbrGfVmlxbkdA0Jfhw1iPyJS0e71Wz46ujz/SyfrzgRdJ8s9eI/j3CnQW rT+WdRsEuwFMW2zSPvDqW+p6WaZ+ODHNOW+7MxZ0pTOld5P0em+VPgpjlWiXG3TR4+ RdkFNFx6MWbNIQMW3Zl0TQoaL8Bg7ucxLuOwib2A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Fastabend , Karsten Graul , Cong Wang , "David S. Miller" , Sasha Levin , syzbot+b54a1ce86ba4a623b7f0@syzkaller.appspotmail.com Subject: [PATCH 5.12 227/363] smc: disallow TCP_ULP in smc_setsockopt() Date: Mon, 17 May 2021 16:01:33 +0200 Message-Id: <20210517140310.262611288@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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: Cong Wang [ Upstream commit 8621436671f3a4bba5db57482e1ee604708bf1eb ] syzbot is able to setup kTLS on an SMC socket which coincidentally uses sk_user_data too. Later, kTLS treats it as psock so triggers a refcnt warning. The root cause is that smc_setsockopt() simply calls TCP setsockopt() which includes TCP_ULP. I do not think it makes sense to setup kTLS on top of SMC sockets, so we should just disallow this setup. It is hard to find a commit to blame, but we can apply this patch since the beginning of TCP_ULP. Reported-and-tested-by: syzbot+b54a1ce86ba4a623b7f0@syzkaller.appspotmail.com Fixes: 734942cc4ea6 ("tcp: ULP infrastructure") Cc: John Fastabend Signed-off-by: Karsten Graul Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/smc/af_smc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 47340b3b514f..cb23cca72c24 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -2162,6 +2162,9 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, struct smc_sock *smc; int val, rc; + if (level == SOL_TCP && optname == TCP_ULP) + return -EOPNOTSUPP; + smc = smc_sk(sk); /* generic setsockopts reaching us here always apply to the @@ -2186,7 +2189,6 @@ static int smc_setsockopt(struct socket *sock, int level, int optname, if (rc || smc->use_fallback) goto out; switch (optname) { - case TCP_ULP: case TCP_FASTOPEN: case TCP_FASTOPEN_CONNECT: case TCP_FASTOPEN_KEY: -- 2.30.2