[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Zjt6fDIxLupGfglV@kbusch-mbp.dhcp.thefacebook.com>
Date: Wed, 8 May 2024 07:13:32 -0600
From: Keith Busch <kbusch@...nel.org>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Sagi Grimberg <sagi@...mberg.me>, Christoph Hellwig <hch@....de>,
Chaitanya Kulkarni <kch@...dia.com>, linux-nvme@...ts.infradead.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] nvmet: prevent sprintf() overflow in
nvmet_subsys_nsid_exists()
On Wed, May 08, 2024 at 10:43:04AM +0300, Dan Carpenter wrote:
> The nsid value is a u32 that comes from nvmet_req_find_ns(). It's
> endian data and we're on an error path and both of those raise red
> flags. So let's make this safer.
>
> 1) Make the buffer large enough for any u32.
> 2) Remove the unnecessary initialization.
> 3) Use snprintf() instead of sprintf() for even more safety.
> 4) The sprintf() function returns the number of bytes printed, not
> counting the NUL terminator. It is impossible for the return value to
> be <= 0 so delete that.
>
> Fixes: 505363957fad ("nvmet: fix nvme status code when namespace is disabled")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
Thanks, applied to nvme-6.9.
Powered by blists - more mailing lists