From: Yu Watanabe Date: Mon, 13 Mar 2023 14:28:58 +0000 (+0900) Subject: udev: mention that the kernel silently truncates lo_file_name if too long X-Git-Tag: v254-rc1~996^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e551954defe7f782597a2a96b5be9320c5658999;p=thirdparty%2Fsystemd.git udev: mention that the kernel silently truncates lo_file_name if too long Resolves the confusion in https://github.com/systemd/systemd/pull/26693#discussion_r1131151335. --- diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 154cf7000f9..2b2205513b1 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -287,12 +287,14 @@ static int read_loopback_backing_inode( if (isempty((char*) info.lo_file_name) || strnlen((char*) info.lo_file_name, sizeof(info.lo_file_name)-1) == sizeof(info.lo_file_name)-1) - /* Don't pick up file name if it is unset or possibly truncated. (Note: we can't really know - * the file file name is truncated if it uses sizeof(info.lo_file_name)-1 as length; it could - * also just mean the string is just that long and wasn't truncated — but the fact is simply - * that we cannot know in that case if it was truncated or not, hence we assume the worst and - * suppress — at least for now. For shorter strings we know for sure it wasn't truncated, - * hence that's always safe.) */ + /* Don't pick up file name if it is unset or possibly truncated. (Note: the kernel silently + * truncates the string passed from userspace by LOOP_SET_STATUS64 ioctl. See + * loop_set_status_from_info() in drivers/block/loop.c. Hence, we can't really know the file + * name is truncated if it uses sizeof(info.lo_file_name)-1 as length; it could also mean the + * string is just that long and wasn't truncated — but the fact is simply that we cannot know + * in that case if it was truncated or not. Thus, we assume the worst and suppress — at least + * for now. For shorter strings we know for sure it wasn't truncated, hence that's always + * safe.) */ fn = NULL; else { fn = memdup_suffix0(info.lo_file_name, sizeof(info.lo_file_name));