netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Christophe Ricard <christophe.ricard@gmail.com>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] NFC: nci: Add bounds checking in nci_hci_create_pipe()
Date: Wed, 22 Jan 2025 10:11:03 +0000	[thread overview]
Message-ID: <20250122101103.GD385045@kernel.org> (raw)
In-Reply-To: <bcf5453b-7204-4297-9c20-4d8c7dacf586@stanley.mountain>

On Fri, Jan 17, 2025 at 12:38:41PM +0300, Dan Carpenter wrote:
> 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_connect_gate")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Hi Dan,

Based on your analysis, which I agree with, this looks good.

Reviewed-by: Simon Horman <horms@kernel.org>

But this is a limited review, as I am not sufficiently familiar with NFC
to go by much more than your analysis. A review by Krzysztof would be great.

> ---
>  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,
>  
>  	pr_debug("pipe created=%d\n", pipe);
>  
> +	if (pipe >= NCI_HCI_MAX_PIPES)
> +		pipe = NCI_HCI_INVALID_PIPE;

Ceci n'est pas une pipe [1]

>  	return pipe;
>  }

[1] https://en.wikipedia.org/wiki/The_Treachery_of_Images

  reply	other threads:[~2025-01-22 10:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-17  9:38 [PATCH] NFC: nci: Add bounds checking in nci_hci_create_pipe() Dan Carpenter
2025-01-22 10:11 ` Simon Horman [this message]
2025-01-22 12:33 ` Krzysztof Kozlowski
2025-01-23  4:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250122101103.GD385045@kernel.org \
    --to=horms@kernel.org \
    --cc=christophe.ricard@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=krzk@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sameo@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).