From nobody Mon Dec 15 11:26:02 2025 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 EFC0225A659 for ; Fri, 17 Jan 2025 09:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737106728; cv=none; b=aXZ8kK2RqW9ty8e+I1P5HKJpzkg/cr+esfL0pwzSDthcUjUR13FHtngPGDAvn8omfAWdT3qyJ3JJ7Owknexu8VQz+InbNqLlaM5iuT6+9ICzMLG8U3a65BwBNWC2KYIlpd2AfBFzhK/ICW+BaKl7d+rJfNOjBhxnLBpM2UVXosU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737106728; c=relaxed/simple; bh=7PIDeEtvr9uPdcgHVL0bACn5nZLTvKQ8toqwIsMpJu8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=rMCiIXoq2nsEDrbOL+90/Jn7QnobBYflDTR0+Uoh384YDhP45AqZRfNV3tJSYCxB7TDckQiaUjp51GbAv4rODgHvgZA1JW48du00jfGIayKau/KzaFmPhfToSOQsbSIXvsTYfgYuDxBgTAB7/XMbGkOPKZde3MJfi31qsBkCFko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=PWzA/b6y; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PWzA/b6y" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-385dece873cso1015443f8f.0 for ; Fri, 17 Jan 2025 01:38:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737106725; x=1737711525; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=aVa2rnxV4FahyPJ4tYXvs8063pmYzJqVqaz+tJmn1sU=; b=PWzA/b6y1lZ69sZaTvI+Z8mh83kP2vCuyoq+Rs4bBteRPJKMLdkojew3DMQpwBgYgl QAPcXg3m1lf/agfhS9LgDnpHhgUgluHvzT6OKZtpYLg56zn1665iXiEgaIZXgfrKwVrd SnHmmq52fJ4vssbnuG4BPKdhoixi/JrgUSU3StT/hTJQV6XC8wG1jpHqw6XcbZRZsgYR IUsCze1zwYIQD1h7Eln/C9HY5RZwBSdFhCaAuUyXndTlbsyqn4PO/OCxRzJ8gvDfew5T C/8avyxfmQUzOrrqRV5RaFrVYVMoBi+J2BCug9/S9PH6cfr2pkQIMAEKISxc8cO8rwOs STmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737106725; x=1737711525; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aVa2rnxV4FahyPJ4tYXvs8063pmYzJqVqaz+tJmn1sU=; b=uiu05ipyKCQdrXqtQlNRyBWA+7P9LSvLg7WahAbI5mxe1CoL514sEZfzW+9Axrqc+C TLCBhAREQuxPTaJhQ9Q94Oi6IfouyQ2JjSEHLOkFhzquTVCqcwIkuuwRCpcR6s66ngI8 q8yjWdEZX0xiN1+yhXNwbVbIKXl2FvL0S2cKjWjJM57wvvUnzpLf4JG4hyvW3YzZAbCj 5i7EwP5/UVXUpf4F3csJcqQRuVE7sqg4DJ2ScYvATlbeiHVT6cR7q84oEN16Xa3aqyeo aXhapP0Se87/SnOwRC88NYqed+0jbBAihyZT79myRMa6vuH6qj2aQvjenHRy3EUbtQIW YkEg== X-Forwarded-Encrypted: i=1; AJvYcCXMU26JOtqjEKk1fGiQCeQsz8vLasjKpIFoysadetbFjksHhGESA0CdbyC4vjxXdSNZDeU7ODtHnTDd5Ic=@vger.kernel.org X-Gm-Message-State: AOJu0YzqYT9kwvJKXgRmuZPw+Tqbkku4hRwvurrFzi4QMUbMJUg0gM6r VpZPSfYPojqSb7r7p31w/HuXxf0DWGNd9uHtBzqkcsmUi8b/k4AVIDVkT7jWBQg= X-Gm-Gg: ASbGncvJ2vrkSMfVBuf86H4mJhH4qNHlSAPjhS/t+4jWY6A1uEQCB3c0lK3ShaY33Uy bVykvHgSlyXh7Z9XfyarZAb501swllI/lcStZ13tGJLgjjQ2KJ8WZ+VfH9JIebf9PIAphohH5Pp djXF/9mXoPbdFPUv48JJVZwq3X/IVI6SutjX6ZxKXROWoD0GfT3SdBAoUPwD534v5werJOqDIV4 tB4A1b8g+lZZx3E15Sf+lppn8905izk7m1X0KkkJlj2XYJg+DZaT4P81b/t/g== X-Google-Smtp-Source: AGHT+IFfhDofhNGp6rNLJ+2OR7B+O+RY4aExqQfShuso+2vT/89CUvI075Q+efQl6cI00ww6Mcwsgw== X-Received: by 2002:a5d:58ef:0:b0:386:4277:6cf1 with SMTP id ffacd0b85a97d-38bf57b380bmr1503817f8f.39.1737106725381; Fri, 17 Jan 2025 01:38:45 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bf327556dsm2024569f8f.71.2025.01.17.01.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 01:38:44 -0800 (PST) Date: Fri, 17 Jan 2025 12:38:41 +0300 From: Dan Carpenter To: Christophe Ricard , Samuel Ortiz Cc: Krzysztof Kozlowski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] NFC: nci: Add bounds checking in nci_hci_create_pipe() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The "pipe" variable is a u8 which comes from the network. If it's more than 127, then it results in memory corruption in the caller, nci_hci_connect_gate(). Cc: stable@vger.kernel.org Fixes: a1b0b9415817 ("NFC: nci: Create pipe on specific gate in nci_hci_con= nect_gate") Signed-off-by: Dan Carpenter Reviewed-by: Krzysztof Kozlowski Reviewed-by: Simon Horman --- net/nfc/nci/hci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/nfc/nci/hci.c b/net/nfc/nci/hci.c index de175318a3a0..082ab66f120b 100644 --- a/net/nfc/nci/hci.c +++ b/net/nfc/nci/hci.c @@ -542,6 +542,8 @@ static u8 nci_hci_create_pipe(struct nci_dev *ndev, u8 = dest_host, =20 pr_debug("pipe created=3D%d\n", pipe); =20 + if (pipe >=3D NCI_HCI_MAX_PIPES) + pipe =3D NCI_HCI_INVALID_PIPE; return pipe; } =20 --=20 2.45.2