From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 4E12441B8F3 for ; Tue, 14 Jul 2026 20:53:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784062387; cv=none; b=k4TTbe6+DyG6NHtCTeFYzbSHx1ElyHFoUYRPZTTfsbXlIL5EvKbtrbRRi7kkRvOr7CELNw0ge5lhpfKYpDRJlaoP/5wpgvNnWSBDms35Vq0Y9adOak98taoDc/nqQM2+rXS+CJ34D0F3tdl12gzElhwTBrQGrtn4DhUQYnBi24U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784062387; c=relaxed/simple; bh=JYol08YXW91ovkNpZaJIz1Ed+fcIPymArOeW437uj6E=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BDoRJSA8PzkkfEL8eggHDIgEzJeSxxYiMoKGbI/ChVzK7cK3rtKbwJ+Fp29hyJq+uZ/F+eSo0byeMZ8tnZQj65Z926NL79XLvMmjFS7gnD/KtW+Sca+CFEuTTqj/YAHAMo49/GIRGIw0fxKKUMMNlRLJ+4vmkJNYcmXH8ysbHEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZbZtBtow; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZbZtBtow" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-4720d22c94aso1404055f8f.1 for ; Tue, 14 Jul 2026 13:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784062384; x=1784667184; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=hPy+9VG/Wk31EHh/SoTTpkYEXwE1ur2uoLWA6FIrzb4=; b=ZbZtBtowHnKVwWhiD6W4WpkjM1/b4ytWELp6smlEUBB5giX4gp8gZHd7HyjyC1OOfY LajJeYuFBpaPRAz/L2bwLnCrsOv9cynhodMK8KYLSmwYVLKbULpao6pQorQUGizkzhFD JHoSvOCriqdFWVhmgBO09XVh8RYV5HHEa9jiLW9uV0vydVAzmdLou8TZe3jLJSGIj8d6 J3mA3HToUkf9CvaEpLyUM5uBV9rag6Ga6RIZi/TLvYG+aANH8NqVz6O0yQK453L8GIMt 4ewJDnzml3D2e9wQR+aEJGFHcoKbQYlv1gVoCoRhiOa+lyTFgmq3Lysw51/MfiOh3DgU 60RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784062384; x=1784667184; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hPy+9VG/Wk31EHh/SoTTpkYEXwE1ur2uoLWA6FIrzb4=; b=HzDwhm8RrxvxmrsZx35URj9g96kIen+wfngyurya1Vy4snJN8EnQ0PUPjitffs9whm PmPCxi8L8UcnUQDBCfcSvBBXbfSpeInB0DPYavrzzTYPObMGYifrAwl62/Gh88v0GzPj T/pWem93o/qO3Cn4xLOBVhUZ4o6EHL1BLNBgCEP+sg4KHLCFrtEOeO7+Q9HnyYX9W9gQ A7p6IbVIOITbQ8EEMub2AGyyGb5NA6EhsrzX2OHH2F+yCHPUC51hINvNrLXhKSqI9qm2 LB5mWphO8LTYoZ8MMK/N7XwevOB4OHvOoMujFVLACvvKV4W3Otl9rXf2paPbLph1M2ad CgJA== X-Forwarded-Encrypted: i=1; AHgh+Rri4la4jOz9IvFjS6203oE5X/s1554Gnb8CPjBSSdapliPo3Om4N+BD1d1LpTxcAaePjuIe7+j2leopNis=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/iI/RTgbQaSMJ9gLAXSK0iefelClni7jE1MM+ZqLH5IavsZqi 7DfJkNqLGnWNowDY5o2R6sFQTrRC13Op17go9li6ssQZ8WXU/ArGlLWW X-Gm-Gg: AfdE7ckAH057mM6QPIv3f2BWQR+B+5Y9WianPZRyi6X98ONH5h0V7I717xiEbe+y4cn bmUcYEQbS40VhjzTbC0us/0NClI1FtmB5vhSi/d+B1+cOt2waZ/MRGTavOE8B9NNidzPt1GiQ0A d+uPi1rVqxbxJEwG6iQrndsrdM9TKF31RDwgTaCVUcIBR390UYMsxZ0u39eyVJDtishE272jzul AUXboXk0u69PcVzlmIWYtccEENB0J9fSdIRZrSxeQ0b+JceWkbuu8i+IhrU2gGzDA3kPXKjxF6J UsRvvg5ogQdiIJRbzF1QJz2jOpjl0jkSKW2kAs660DR0vK19mMVniD8EZ8E8Fs2o4Lr+7Hrp/tM aQNz/OBEr8hKqglYPg+wI9jRy9aJZUIkss80xLzmwOUS+IUc+fK0Gv7s7ZkgJmHeSoY1W9EO5Dz qXnJlopptb11xL1YFGu3/6lvN5tWLsG1YK9HK6KFfEpMLhEZUaKA== X-Received: by 2002:a05:6000:1866:b0:475:f0d1:eb56 with SMTP id ffacd0b85a97d-47f2dd0d63fmr18015724f8f.49.1784062384331; Tue, 14 Jul 2026 13:53:04 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f4634debesm10998794f8f.8.2026.07.14.13.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 13:53:04 -0700 (PDT) Date: Tue, 14 Jul 2026 21:53:02 +0100 From: David Laight To: Doruk Tan Ozturk Cc: david@ixit.cz, vadim.fedorenko@linux.dev, horms@kernel.org, oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH net v2] nfc: llcp: reject PDUs shorter than the LLCP header Message-ID: <20260714215302.75d8bf72@pumpkin> In-Reply-To: <20260714164629.75051-1-doruk@0sec.ai> References: <20260713221556.13a830b8@pumpkin> <20260714164629.75051-1-doruk@0sec.ai> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 14 Jul 2026 18:46:29 +0200 Doruk Tan Ozturk wrote: > > Is there a similar problem with non-linear skb? > > Maybe they can't get into this code, but who knows what can happen > > with unusual configs. > > Good question. Today every skb that reaches __nfc_llcp_recv() is > linear: the target path (nci_rx_data_packet -> nci_add_rx_data_frag -> > nfc_tm_data_received) and the initiator path (nfc_data_exchange -> > nfc_llcp_recv) both build the frame with alloc_skb()/nci_skb_alloc() > plus skb_put()/skb_put_data(), and NCI reassembly uses skb_cow_head() > and skb_push() into the linear area. Nothing on the NFC receive side > attaches page frags or a frag_list, so skb->len == skb_headlen() and the > v2 skb->len test was in fact sufficient for the in-tree drivers. > > But relying on that is fragile: the parser reads the header out of the > linear area (pdu->data[0]/data[1]) while skb->len is the total length, > so a non-linear skb with a short linear head would slip past a skb->len > test and still over-read the linear buffer. pskb_may_pull() is the > right guard here -- it also covers the non-linear case, and it matches > how the sibling NCI and HCI receive paths already validate their > headers. > > I will send a v3 that uses: > > if (!pskb_may_pull(skb, LLCP_HEADER_SIZE)) { > kfree_skb(skb); > return; > } > > That is strictly stronger than the v2 check and does not reject any > valid frame -- pskb_may_pull() pulls the two header bytes into the > linear area when needed. Does that help any code further down the rx path? It might be better to drop non-linear packets with a comment that they aren't expected to happen. David > > Thanks, > Doruk