Message ID | c4e2435c57cff7f650c0a82c2ded12c0d1843b80.1702816635.git.code@siddh.me |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-2592-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp696721dyi; Sun, 17 Dec 2023 05:12:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgUsNGSQP5dYHeEX9z38HqEysJL66/rBUqJ7G+qC5hdb/J1/ftZqZQoXFCx0GcZb3IaD7V X-Received: by 2002:a05:620a:268f:b0:775:ed1e:2b14 with SMTP id c15-20020a05620a268f00b00775ed1e2b14mr19323524qkp.54.1702818754024; Sun, 17 Dec 2023 05:12:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702818754; cv=pass; d=google.com; s=arc-20160816; b=Vo7DXxi3s/0iC9Xihm/LwzRgYZHXE8FFRmdXbOHSutvksyKLoVe9Y2kuXyUxUq1ReS v9/zbQ0xEUHrOL5msl5ZE0DVCWu+Or4SauTtBF7qPT2SXrhiJ5+kt3NBOUm7a/5OzU3x AeXDS3WjhYyX59DEFhkQtcwZ7S/hJMHbewfwoNv5AqIuxQo83YG5c7sEbR+O9aMYBd3T E52f3DrwdfEjyWF6sV5GnfQvpv4zV3P75w4Ks502qAhB8SlQ8Pvpsbi/ucqNzvAXflCE 1D3+5O1DJFEMbl0q5BuJyb+wwK2HBBREs21ngAyq8lTV1yHykPbDHrl6/XCOtK+e6g28 2NTA== 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=Scp3IrJnE67ltgIhAprfULm6HsQ/s5KxrhhmK7w7AQs=; fh=RACn3Dz57j2O2Diwusdo+qDZ4fbRHVAux3E9Xar2zXI=; b=tq405kh0gQjtiiGRepr4XkZcB21MvKQUu+uJbI7HfpxlzwYR6cDRUn5FfEqKFbC1UM hVGWg5LToVG54m1BLXmr1uqZaUTtpjRfGzCDZj/3CClucFEU5/z0iE1qxYwRiKwX3hO/ aiWPRD2gwEsWllSrSmifG9mCJzK+qOxEuE/Gf+swTCo/DiGGPFwAAnQPBWTKgfKf+Gey ZDQJkaTwgxdz/pz6dWlkFi9tw9G+gN7sq4i8Ui3x2xiLr7oZeC/HM08wD//hAGBURzlk WEzzpnqM5RebyjoyaGhLKywP6HOtN7RnnBUtYwPwM66mGkyDuqeOsLEHvGHjhm6Atuu+ uhDg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=jaJKRVZz; 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-2592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2592-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siddh.me Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o22-20020a05620a2a1600b0077f6d73fac4si17632918qkp.475.2023.12.17.05.12.33 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:12:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@siddh.me header.s=zmail header.b=jaJKRVZz; 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-2592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2592-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CE2FE1C20F11 for <ouuuleilei@gmail.com>; Sun, 17 Dec 2023 13:12:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2B3B44C6E; Sun, 17 Dec 2023 13:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=siddh.me header.i=code@siddh.me header.b="jaJKRVZz" 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 981814317A; Sun, 17 Dec 2023 13:11:51 +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=1702818675; cv=none; d=zohomail.in; s=zohoarc; b=AQdENfINNapZlrC/EctTnMZUARzUjwqbKHHbdEEIS+PA/YJq9Kr7O1NZFI/0CjCG9HNKGuBKx6jj7a9S5baUa/ElWre7+dGz5AiN1iCDebo4hOAojZCx+c4WI458hKsH2utYDcwJXDkSFJR5GguCBcu3srbWSBPiG/tqzspomMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.in; s=zohoarc; t=1702818675; 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=Scp3IrJnE67ltgIhAprfULm6HsQ/s5KxrhhmK7w7AQs=; b=RnMOfZmQGs6b+piHKyDlptYaeFtNUGn/VMBA0li+cpBYo4RoyAjFTb6QaFQ/QE19T2AAarLo69XjQ+A0AXp+8VOOEmZf25rvAYj4qOHEQBT/0N0cLZYhgcZ3YaxP/UGrKhg+q+PsXrZRIq747QSemHYzlChItQpMFHIXewCHScg= 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=1702818675; 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=Scp3IrJnE67ltgIhAprfULm6HsQ/s5KxrhhmK7w7AQs=; b=jaJKRVZzCRbtac7qltv2l3keyMs1H8djk4xukyoEvvldO4gHlQB+2ZaM8m4ybNSg IY+MFe+jnwoU0p74HFXy6VvahDRpCQIkXcLOYKKG0j/6XKcWVGbbxOkEU71OM3AgVSI OU/VVQH77liZRBQ1Vgt47cjBXciQUwM/8e9nkmLo= Received: from kampyooter.. (122.170.167.40 [122.170.167.40]) by mx.zoho.in with SMTPS id 1702818674595848.1274981870353; Sun, 17 Dec 2023 18:41:14 +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>, Suman Ghosh <sumang@marvell.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v6 2/2] nfc: Do not send datagram if socket state isn't LLCP_BOUND Date: Sun, 17 Dec 2023 18:41:04 +0530 Message-ID: <c4e2435c57cff7f650c0a82c2ded12c0d1843b80.1702816635.git.code@siddh.me> X-Mailer: git-send-email 2.42.0 In-Reply-To: <cover.1702816635.git.code@siddh.me> References: <cover.1702816635.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: 1785534877776825120 X-GMAIL-MSGID: 1785534877776825120 |
Series |
nfc: Fix UAF during datagram sending caused by missing refcounting
|
|
Commit Message
Siddh Raman Pant
Dec. 17, 2023, 1:11 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);