Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp503955pxj; Tue, 18 May 2021 08:10:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK2MzwQEapPHv2A6huIDj7cBfbWMSA1nwKK/gdH7Gm1y6b8xBbjf4P/gyJmG2+0nM7pzER X-Received: by 2002:a05:6e02:1488:: with SMTP id n8mr5126943ilk.158.1621350614930; Tue, 18 May 2021 08:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621350614; cv=none; d=google.com; s=arc-20160816; b=PaLJTHWDdA6NPvRMh3gzQo70rW49pORySUYxPV9gnPJRs1c4xG/nbxCjHlvhGpUkbp alz0opoygNOGdmRNL1LciezT6rNyBfInGg13JfYVgj4RYTDCYxWR5NpGVmcYggLBXKUP aXLUIw/W2I5KkQjhYfO79qqRBGz9QTo3TiizEii+Og/1j/OxY9LhNlLn6053zocmVd5I KmXQxIC2ZeDgwnUP3pG+mN3Ftnw2mxtyOyhXtg9GTOiVB1HMlPhhdXjC24pTJhFpi13U fLjHzGYK2rMN0fatqwm7PCnpTfFlTuA9H1ofYHIbh/1HPu71Qo6Nvss/IDVzEVjTLrQf QKuQ== 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=YkBa2TxNAIHHf8lMXbSIiro3iyuGThzDN25uNijW2/8=; b=fgGiJ1hN5NmOmfqWWdKYZMvtDZKVGcx6I1eLLGxPypDN4CJaiP4+n0pFfSHXzAuXyt qETuNBazbi7tnugsDhmL1rqFBKXkew7rA9z8fYKLoEg9QqOvSvrAhnUo/2nJfS0FD/nm qyE0/7ksgunISytSTNGc9CkEWRHXZlQgCjAYrOgfigTCL3+JDxUDS1NoHP0PDbGchgVS 6bxw5xWPvsC6TBp7QKgj++IA8nB+g7jn2gkvcuyB0xirz5W/41RBfWB5cRI+PWZ9USch dEK5+IsYZ50DKoA35ZTIwsvJ6X+Gf/fsi6tiRx/702HewpwGHqp6TCIeO+6Paz5zwQe9 FxtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EbUVYvjs; 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 r5si21928364ilg.18.2021.05.18.08.10.02; Tue, 18 May 2021 08:10:14 -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=EbUVYvjs; 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 S1343607AbhEQPwD (ORCPT + 99 others); Mon, 17 May 2021 11:52:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:36986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343784AbhEQPe4 (ORCPT ); Mon, 17 May 2021 11:34:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 32EA961934; Mon, 17 May 2021 14:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262378; bh=aSBztflyyzxcaizwAF1cFkI6TjbyQBLzU1TodsHwpJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EbUVYvjsiQS3jqO1jLid3zZtWFspkRB3HHTU3W4Ahke11SIChWr4yLbICkZ1FI6rx f+qecyuWbrPN4zAVrpZ78tzWCo67XcoH0aonGFXSqV5IJGboiaGSQGwkBSCsGl7/bq gX+btELnUdEWDxzhUg1WHtTEzzAHFCW/4H6GO4+0= 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.10 175/289] smc: disallow TCP_ULP in smc_setsockopt() Date: Mon, 17 May 2021 16:01:40 +0200 Message-Id: <20210517140311.006641567@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 5dd4faaf7d6e..030d7f30b13f 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -2147,6 +2147,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 @@ -2171,7 +2174,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