Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1664003rdb; Thu, 25 Jan 2024 02:28:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBsrZ9QVpAKj33j1kfaHdk52HLib2rGP4qJy8spAqqpFmKydLIppyy0VqRfa25IrMrHrnG X-Received: by 2002:a92:ca8d:0:b0:361:a2f8:deb1 with SMTP id t13-20020a92ca8d000000b00361a2f8deb1mr864889ilo.54.1706178481869; Thu, 25 Jan 2024 02:28:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706178481; cv=pass; d=google.com; s=arc-20160816; b=KdOGKNgVfSWTabcPRiMQcFthWWidvmIxD4ngi5F0cQV/LSg2TiEi70c3wuR2ciDcv4 kIUU4hnQPXebKasY1bLMsWplWvzokdPmhip1xCzwm05htjvFCmKtdEKfJUzJ7113Dby7 hqyn0tQ+U0Ypoip2CyPbr47JrUcJSO5bA7kQN4mkcZxku8ObYxUE0/0bXpelZM45aLhc WH/+SLPrD8tYA0Mjlv8FEvI/OxWOcQ4bCBhtVbzwzF/D2wdlDLay2eSzTFrZfKk5vpQo 6IQfbh2P1lcHQQNKClTrmpGzdKPCdK2qKscwT6iBbYGqnGf9mESL/L/eSbKupfrV1vC+ pSSg== 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:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=KQrR+5BkSPmu/kRG4OwqNQfdmbL9yFyULUlnEV6F95k=; fh=OKF8oZ6Cg189aobgS7U9zEvZsQrBIivEoBGYLxJQen0=; b=p+ftx2ItVAg52JusrxRrg9gN3TwwTo6j387+euSX3Zm9uUB8/PIvtmXJinXfCtTziK SXX/QuL537N5M9X91TdQoPiX9MttLRx4AnqczXwgWYXQZ2STExmAFwx5KHTMmPbeLWII nbKJP405cM416oM9CRddFu8ojEx6qukHC1w9w5sBSgC6WnDt2ppaKOqwfUBSR6J9ilGO lmLo0eCGcIUMCoe+r6MN9Lj0jgiy8FJjR4ym2AkoYLcDzLpijv8Yuw4sEXLmItTCFwpx niHTGRMo0g7JHV9Orph/cz49wMOZ5x3rbCgGkJ/hGTHzYQcpCo1nTiwrQmy5gI9WtwsM OXRg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=KRrMtcPM; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-38338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id by38-20020a056a0205a600b005d5e9dfc051si1478940pgb.888.2024.01.25.02.28.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 02:28:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=KRrMtcPM; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-38338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 588EAB2B889 for ; Thu, 25 Jan 2024 09:54:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D61D81CA82; Thu, 25 Jan 2024 09:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="KRrMtcPM" Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 614611BF33; Thu, 25 Jan 2024 09:53:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706176415; cv=none; b=IlCjbgNvwEDNyFejH/2rBq6fkF1oZQbNBBPVxcukUgfQj/+lHTBjrrkEH60GX3V+IwRcI2qoxSa/93BzRArX+4qusdB6wCr+jW09clHAxMLXl1WNliD3RRwg0iZPc+C6sIBc6E0iPFa8Y1sok7y3s2CWTI0R93NtIZvc/Aju6Nw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706176415; c=relaxed/simple; bh=MOQWUs4LfrqyBim3cdZJiOlBAObGGDGpzuE1pIY1Gwg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JtRk/8T67nRMUOc6HOO8g/F3m/4Nwzkh4xZkpQ/2xOFE01rivhKw5NjxVNjR62wI+fYc1BDYb25IBNE+uKxY2qoUHfxwxQ3zL6t6LKg1khMQdpY2Pc67CFc5XrOK+UB2BHEkKJKL2P5mS09XnM7FaikUVZQUWoZNwiZwMYpIQcY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=KRrMtcPM; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Received: from localhost.ispras.ru (unknown [10.10.165.6]) by mail.ispras.ru (Postfix) with ESMTPSA id 755C04076731; Thu, 25 Jan 2024 09:53:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 755C04076731 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1706176403; bh=KQrR+5BkSPmu/kRG4OwqNQfdmbL9yFyULUlnEV6F95k=; h=From:To:Cc:Subject:Date:From; b=KRrMtcPMC+9jDKT+AIn/r5Lj8MaJLvhTzsrcsyy3xGxnr7uDd+F9aRmE1BdU0jfE2 AAfNyzDjwRfyNf9T6Kx+iqsaazo712CpMtE8/9mEp8tKVgNpjuZU0HBhneWS7q+l0E o2bP+OZ8QbLRtOmmzA9sT/4Go1hKPCX2hzTOvaRw= From: Fedor Pchelkin To: Krzysztof Kozlowski Cc: Fedor Pchelkin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jeremy Cline , Simon Horman , Breno Leitao , Ilan Elias , "John W. Linville" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org, stable@vger.kernel.org, syzbot+6b7c68d9c21e4ee4251b@syzkaller.appspotmail.com Subject: [PATCH net] nfc: nci: free rx_data_reassembly skb on NCI device cleanup Date: Thu, 25 Jan 2024 12:53:09 +0300 Message-ID: <20240125095310.15738-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit rx_data_reassembly skb is stored during NCI data exchange for processing fragmented packets. It is dropped only when the last fragment is processed or when an NTF packet with NCI_OP_RF_DEACTIVATE_NTF opcode is received. However, the NCI device may be deallocated before that which leads to skb leak. As by design the rx_data_reassembly skb is bound to the NCI device and nothing prevents the device to be freed before the skb is processed in some way and cleaned, free it on the NCI device cleanup. Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Fixes: 6a2968aaf50c ("NFC: basic NCI protocol implementation") Cc: stable@vger.kernel.org Reported-by: syzbot+6b7c68d9c21e4ee4251b@syzkaller.appspotmail.com Closes: https://lore.kernel.org/lkml/000000000000f43987060043da7b@google.com/ Signed-off-by: Fedor Pchelkin --- net/nfc/nci/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 97348cedb16b..cdad47b140fa 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -1208,6 +1208,10 @@ void nci_free_device(struct nci_dev *ndev) { nfc_free_device(ndev->nfc_dev); nci_hci_deallocate(ndev); + + /* drop partial rx data packet if present */ + if (ndev->rx_data_reassembly) + kfree_skb(ndev->rx_data_reassembly); kfree(ndev); } EXPORT_SYMBOL(nci_free_device); -- 2.43.0