Message ID | 0490c52b68c27730d9916ff22c917b4838c32af4.1702925869.git.code@siddh.me |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-5732-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2141495dyi; Tue, 19 Dec 2023 10:30:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IG841UXZSeLJYzLRCj+u0mjp+55M1olRqWIfIkWzBIDRvUQ5HSRza7jin1afiU2/Cdo7gBC X-Received: by 2002:a17:906:739e:b0:a23:6822:3e50 with SMTP id f30-20020a170906739e00b00a2368223e50mr1309013ejl.132.1703010656193; Tue, 19 Dec 2023 10:30:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703010656; cv=pass; d=google.com; s=arc-20160816; b=HQN4VJ2iJtcwIGD+D+wF+xSh+OzO+KpCA096X+5v1AXFR5kjhbXfiZE/q149q02Lu9 7AxJIg6dSwbnjp26G34E3Ju/67CMYNX3ha1scASwMzZzGpXPZ6k9uRM87OoK9nhdr4UA 9vcXHgDQQ5kME4ZNHlFsm1YPV8TZodemrDx0B0CL4rwYju7A3wJx6jnQUUKfcgiOMYcK OFxgmsAya3vJG/JO+wi3Ix4t8j1a2z2cNKTOw0dBlx1/70x015SZsgBlXSEk5rmoIpI0 BIvQOtheqlfbApbix481HbpH2J7fY61oQkzSWmVEy6+LNZ9rOz+lqlNajRZ2Qz62En7S Blbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=872tkGPm7VUCxpgjJMERmpcep5wm35gG4ZP3R1Drljw=; fh=jRNF1o820nunFTFcGlj9FjVjB7ilggMA+a+y3yJrIks=; b=XffLhltonqjWLSPsFVbFnQv5T2rQWp2sZoZJuPr9WYQeDmY62ZgEmD3nNF3aSPf0bd MfdwzCVSnnne7+jACSxSB/W+czQM2zJWHM22KtW0tgi1dTiWW6qMy8tvZULAX8XfRaAx URdM2IVub8+cak5vo9x+hbcDwcOlxRH1rrW+SlCUWHOWfzLKOZNB7T9Z1EJQz05Yh8it 4VentwWd73tCWKwdjacxBr6GOdvY4nEqbQbjR/FzQM2UnChk7gN2tR71VSJafAHAt89y Wb/7qYpg89flyp/t1VsX3tqNNzfnZYkaU2Exvopy/K9h2U7FfsVKTLc4M40xPVrxbsyJ uBpQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=d3w5td7+; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel+bounces-5732-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5732-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gt26-20020a170906f21a00b00a2341afa442si2448667ejb.331.2023.12.19.10.30.56 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 10:30:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5732-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=d3w5td7+; arc=pass (i=1 spf=pass spfdomain=siddh.me dkim=pass dkdomain=siddh.me dmarc=pass fromdomain=siddh.me>); spf=pass (google.com: domain of linux-kernel+bounces-5732-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5732-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A2DA41F26630 for <ouuuleilei@gmail.com>; Tue, 19 Dec 2023 17:54:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7A2C3A1D1; Tue, 19 Dec 2023 17:50:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=siddh.me header.i=code@siddh.me header.b="d3w5td7+" X-Original-To: linux-kernel@vger.kernel.org Received: from sender-of-o51.zoho.in (sender-of-o51.zoho.in [103.117.158.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7D6E374F8; Tue, 19 Dec 2023 17:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=siddh.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=siddh.me ARC-Seal: i=1; a=rsa-sha256; t=1703008193; cv=none; d=zohomail.in; s=zohoarc; b=O2lZZ9HwWZENrMMyZrM1Yzod/hHiK+jK7pDwdayn2m/RELjnaOQnoMBhLc8IgMYKPkp/gIlHxPLgIOZ4KmPkAVR/7tlVNneEy+hM1iKd8T4Osi57whn1bSuVC1f4zoc2OMSZ/G0LiBqOEJAOtx4j8NAvNsFbnsoupDURhzgLP5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1703008193; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=872tkGPm7VUCxpgjJMERmpcep5wm35gG4ZP3R1Drljw=; b=RAmho9NtBqc8m36Qeb4liQdXtQa96J7exICe0g9G/LAGohQmSHMOq7impzN3sDPMcWQd2iuImnttjpLMgK27s0kTYvj34zoU7mZAl/gvF+mCIki+Z1umMeUvUmt0BcPiigMScbdTp0tfAwvGT47vijAHTqokNzmm7BXo/KMS1F4= ARC-Authentication-Results: i=1; mx.zohomail.in; dkim=pass header.i=siddh.me; spf=pass smtp.mailfrom=code@siddh.me; dmarc=pass header.from=<code@siddh.me> DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1703008193; s=zmail; d=siddh.me; i=code@siddh.me; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=872tkGPm7VUCxpgjJMERmpcep5wm35gG4ZP3R1Drljw=; b=d3w5td7+zQt54GRVeCfbgqH/oeI7Y0/Kqr/EfxRXvdCSbwbJTYN0z51jFOGuQ3DI H+WpJKUkaIMo73xARw10HHgeCqQmna40+cEq7eCkGrH2l7dlq5pCdlaD4A3kptOOgna 5H5BRWJ2kwXXZN9Y9+zP8LcVOSbkCXJBYdTXw+9M= Received: from kampyooter.. (122.170.167.40 [122.170.167.40]) by mx.zoho.in with SMTPS id 1703008191467810.3177351858395; Tue, 19 Dec 2023 23:19:51 +0530 (IST) From: Siddh Raman Pant <code@siddh.me> To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Suman Ghosh <sumang@marvell.com> Subject: [PATCH net-next v7 2/2] nfc: Do not send datagram if socket state isn't LLCP_BOUND Date: Tue, 19 Dec 2023 23:19:44 +0530 Message-ID: <0490c52b68c27730d9916ff22c917b4838c32af4.1702925869.git.code@siddh.me> X-Mailer: git-send-email 2.43.0 In-Reply-To: <cover.1702925869.git.code@siddh.me> References: <cover.1702925869.git.code@siddh.me> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785736101877015971 X-GMAIL-MSGID: 1785736101877015971 |
Series |
nfc: Fix UAF during datagram sending caused by missing refcounting
|
|
Commit Message
Siddh Raman Pant
Dec. 19, 2023, 5:49 p.m. UTC
As we know we cannot send the datagram (state can be set to LLCP_CLOSED by nfc_llcp_socket_release()), there is no need to proceed further. Thus, bail out early from llcp_sock_sendmsg(). Signed-off-by: Siddh Raman Pant <code@siddh.me> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Suman Ghosh <sumang@marvell.com> --- net/nfc/llcp_sock.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 645677f84dba..819157bbb5a2 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -796,6 +796,11 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg, } if (sk->sk_type == SOCK_DGRAM) { + if (sk->sk_state != LLCP_BOUND) { + release_sock(sk); + return -ENOTCONN; + } + DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, addr, msg->msg_name);