Patch "nvmet: re-fix tracing strncpy() warning" has been added to the 6.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nvmet: re-fix tracing strncpy() warning

to the 6.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nvmet-re-fix-tracing-strncpy-warning.patch
and it can be found in the queue-6.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6ad4815ce78401e60b8247c3d0f53635b8901655
Author: Arnd Bergmann <arnd@xxxxxxxx>
Date:   Wed Jan 3 16:56:55 2024 +0100

    nvmet: re-fix tracing strncpy() warning
    
    [ Upstream commit 4ee7ffeb4ce50c80bc4504db6f39b25a2df6bcf4 ]
    
    An earlier patch had tried to address a warning about a string copy with
    missing zero termination:
    
    drivers/nvme/target/trace.h:52:3: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
    
    The new version causes a different warning with some compiler versions, notably
    gcc-9 and gcc-10, and also misses the zero padding that was apparently done
    intentionally in the original code:
    
    drivers/nvme/target/trace.h:56:2: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
    
    Change it to use strscpy_pad() with the original length, which will give
    a properly padded and zero-terminated string as well as avoiding the warning.
    
    Fixes: d86481e924a7 ("nvmet: use min of device_path and disk len")
    Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
    Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/target/trace.h b/drivers/nvme/target/trace.h
index 6109b3806b12..155334ddc13f 100644
--- a/drivers/nvme/target/trace.h
+++ b/drivers/nvme/target/trace.h
@@ -53,8 +53,7 @@ static inline void __assign_req_name(char *name, struct nvmet_req *req)
 		return;
 	}
 
-	strncpy(name, req->ns->device_path,
-		min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
+	strscpy_pad(name, req->ns->device_path, DISK_NAME_LEN);
 }
 #endif
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux