From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC32B3CF675 for ; Tue, 23 Jun 2026 23:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782258115; cv=none; b=D7wdphjXKHec4/hXl3d0gJygvG0Cbtk2u1g09eSb2iX2i6tbr3fSnZBjEzTqkZVi/uxnCBKR7+PrqUY433NaoftbeqDObYqHe87EKZxSCMFuA1BAqmGbgHpvYNyPpoA/jSKbSzSVw2nOzylh8ainOxN9O3M+vOg3X7z69k6lANU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782258115; c=relaxed/simple; bh=Q0OR99yi2KTeQqBV6zSKr/IxWlEosp13yzQoJ9jbwdo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BpUM8fTr0nyi+DXECQO18ASBalMn44CbcCJUYtn5yT4jEpLEgzr8LlrctsCIfqxpQmqKw82XW0LYyzdiclBHiwCnhHJVjsLmCZK3w4OcqYX1EemYqNc0enW5m3H7kt3h020hQDnoGu9hrPUXp6HZBdn/yT/H9kURC97bknwabVY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bynar.io; spf=pass smtp.mailfrom=bynar.io; dkim=pass (2048-bit key) header.d=bynar.io header.i=@bynar.io header.b=DJOQipYY; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bynar.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bynar.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bynar.io header.i=@bynar.io header.b="DJOQipYY" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-c07d76ffd0fso45432366b.0 for ; Tue, 23 Jun 2026 16:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bynar.io; s=google; t=1782258111; x=1782862911; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nOj4ZzoO0fd8cVdfzVSBt6Auoi0sws5oiKgIpomRCU4=; b=DJOQipYYly18FrthmR6swX7UcCIXFkKhPNgyr8wuWWtrU0FTBSihz3/JKOQUX6CaKB YoS+IBVSzHVPlvX1WSKpEEBJZhCHR0jA8d/Pr1r7z6ROc3ceT22WfgP60o0QAQPDubX+ 3Rwyg8NMQjDYIWxSjmCxYFF9w6QIk54CiWm1WB5SDAu3O+TQf8PW7fp9td9BlFEGqiMR 8nYE2FaRHTeyp/Wswc57owlyUqUXqOx14e8AsWdRMzpZFUtf0b2VJMUCxtlQ+JJnsIqB shJiz+L5aVjm7tY3I/4w1nGrVQdLHPPDIbPNinmUHThlE3BzrtygJsXODtRbxz1XOBia mCHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782258111; x=1782862911; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nOj4ZzoO0fd8cVdfzVSBt6Auoi0sws5oiKgIpomRCU4=; b=Z3Kv7gk5c8RHwKZLuwzPqRDfMo7/WwvXLqqIdD0rFAk5t9ydCLRPg9BaPQPGyEHFDj dV5bvbYAHIoyYtAI9LlDWFHEtYMy7NjE+Q+RW+2a0E2+E0MxPRPLvSmEu9eYERQNA1Pt nDNHlVXiP5zigtfRDa9Tl1+Vpo0VjgwC/N16BP3idX7Z+W8booKOlhj6tCXBxf76Gzh+ +4pbfnJuiK3NlDELzwUweIUmAlI9s4gHmtyWhs7rLALnSDPBrT0w3JUQPjA1o6+/0wvV +WHUWQs6KEWkjt+cnOncrmVVF/MpdXCJEqvrCgqPvTHlvBhzlOEmxtggE9VYBr3e9NCh vsKQ== X-Forwarded-Encrypted: i=1; AFNElJ8GXUG4+FqV3bNjhb9fj8hZnDXcgeAhbai2qtpIH+4K6QoeMEzrT4sZRd0DA8aK88p7UR70IhYznhsbLgk=@vger.kernel.org X-Gm-Message-State: AOJu0YzWdeC7PreZg9ocHNN4YmiD6rBNY4ZbQlQ7NYrgDaKZXLLRyLh9 Aq6a84yVTePoFIvTXNAjCEoI9uAUrQYFgni4yRtskQFK1oyMLmKF6IpXkf7pDEJHoJjI4U/Qbxp Fz5uwFg== X-Gm-Gg: AfdE7cmrAR/GVsnn4QnMg0Ntd1pGi63gqfxMHbRDan4sIqixJy4BNAW99FpT2xO5xeV xmx+FTTUC5xG3DARTdFW1g3UnpcWtbWNFlyhGeqiaDwLSOjdwC2Ug1rdsI4D+Y9KjQeIeqsmj/h WKYqBkZfrW2YC1G6s7AoC+3AG1qLWOZ3+B10lApSv7nVG1W/2stD2kciSQUjLCgnWFgzzby4dto l4W8dWaLQ1PDWTDtE3y3Sv1wNt2WXo4Df7XHXJUrxkBzkQamq0J2HqPAfRKfEZ18qk/e4hm125v IazGy0oID90mtrqU87udRAoEC0m5rBsVO11eiY4ynTxkTOCSRjsqOZWrqG2R9lUChO8OlQ2Naiu E+OjZd0LtOC6VYRO8axAJ08iTX1jBXj6pLUcwjA5jGX2vE+bonrhq22Y3AFclUNpiIq/vj10jdl oHS+CHqsydoS0= X-Received: by 2002:a17:907:3ea6:b0:c08:59dd:3fea with SMTP id a640c23a62f3a-c107efc1f64mr260781666b.27.1782258110366; Tue, 23 Jun 2026 16:41:50 -0700 (PDT) Received: from localhost ([2a06:61c2:d427:0:b321:1c7a:b072:326e]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c0c61610bacsm591936366b.58.2026.06.23.16.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2026 16:41:50 -0700 (PDT) From: Samuel Page To: David Heidelberg Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net] nfc: nci: fix uninit-value in the RF discover/activated NTF handlers Date: Wed, 24 Jun 2026 00:41:26 +0100 Message-ID: <20260623234126.214667-1-sam@bynar.io> X-Mailer: git-send-email 2.54.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 nci_rf_discover_ntf_packet() and nci_rf_intf_activated_ntf_packet() each parse a notification into an on-stack struct (nci_rf_discover_ntf / nci_rf_intf_activated_ntf) that is not initialised. The technology- and activation-specific parameters are only extracted when the corresponding length field is non-zero, so a notification that reports a zero length leaves the relevant union uninitialised - and the handlers then read it: - discover: with rf_tech_specific_params_len == 0, nci_add_new_protocol() reads the uninitialised rf_tech_specific_params union (nfca_poll-> nfcid1_len is used as a branch condition and a memcpy length) into ndev->targets; - activated: with rf_tech_specific_params_len == 0 the same union is read via nci_target_auto_activated(); with activation_params_len == 0 the activation_params union is read by nci_store_ats_nfc_iso_dep() into ndev->target_ats. In each case the uninitialised bytes are subsequently exposed to user space (NFC_CMD_GET_TARGET / NFC_ATTR_TARGET_ATS). BUG: KMSAN: uninit-value in nci_add_new_protocol+0x624/0x6c0 nci_add_new_protocol+0x624/0x6c0 nci_ntf_packet+0x25b2/0x3c30 nci_rx_work+0x318/0x5d0 process_scheduled_works+0x84b/0x17a0 worker_thread+0xc10/0x11b0 kthread+0x376/0x500 Local variable ntf.i created at: nci_ntf_packet+0xbc2/0x3c30 Zero-initialise both on-stack notifications so the unions read back as zero when the corresponding parameters are absent. Fixes: 019c4fbaa790 ("NFC: Add NCI multiple targets support") Fixes: e8c0dacd9836 ("NFC: Update names and structs to NCI spec 1.0 d18") Link: https://lore.kernel.org/netdev/20260623172109.1105965-2-horms@kernel.org/ Cc: stable@vger.kernel.org Assisted-by: Bynario AI Signed-off-by: Samuel Page --- net/nfc/nci/ntf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index c96512bb8653..274d9a4202c9 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c @@ -440,7 +440,7 @@ void nci_clear_target_list(struct nci_dev *ndev) static int nci_rf_discover_ntf_packet(struct nci_dev *ndev, const struct sk_buff *skb) { - struct nci_rf_discover_ntf ntf; + struct nci_rf_discover_ntf ntf = {}; const __u8 *data; bool add_target = true; @@ -688,7 +688,7 @@ static int nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, const struct sk_buff *skb) { struct nci_conn_info *conn_info; - struct nci_rf_intf_activated_ntf ntf; + struct nci_rf_intf_activated_ntf ntf = {}; const __u8 *data; int err = NCI_STATUS_OK; base-commit: a986fde914d88af47eb78fd29c5d1af7952c3500 -- 2.54.0