From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 60C1F80031 for ; Thu, 19 Nov 2026 12:04:59 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AJC3bgu023617; Thu, 19 Nov 2026 15:03:38 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AJC3bgu023617 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1795089819; bh=aUWF+7ObdNqRsLYHfVUEVVRQidTehziHYkXS6R9AmSc=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=QltUU0GSu0KvrzJNEswi4+OyJHVYe2o8YEoEO9M/vFA/7sOuH7quYrRyR5WmWqXVX II+qtYi0u8kTe6P7N6KIPbODklbkEQXPFNQ8K+EBRANSCyamKwxnGyl/ZQFztqcNcs YKM3nPrHT29QRfuMyA8rRWYzAC7j9cOP3/rJHNcIeGdd3c3jIsHVqRoYKSw3Cg9ePR +6pB/fFde93nnVftosLKFqJ0x+y4CjShpuMcwGYGISEGKFMUNbSRl6bG2Zowh7MVoM dbYF66lUX96+OFoq3PJhZQN9ryfXdpXtXfmSD/EubQ+V/BrL57GVlIqLIB2jYhHJ+A Y55h5fYvA2PCg== Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AJC3WL0023576 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 19 Nov 2026 15:03:32 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AJC3WL0023576 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="YiJpXPcP" Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c429d9d05f0so216543566b.1 for ; Thu, 19 Nov 2026 04:03:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHgMUFKdGEEhdYwrGnYjYkI6/TD/mpd9NoOzv+LCb+jMWp5v3wfLhbbnR5YKLfBLr8VvXQuGQ==@openvz.org X-Gm-Message-State: APuU4Z9wi/5Rq7mv3dNTcjIMZXOsDqrv61EAV5BKkM0z3ef+DCJvYjOf aT7caoYBmXRbmxLGyW9i9JW5cFGNcx8csNJC4wlGoNM1UGtOWbFwsIq4DZGGbgm9pMHcrJlt/KF hv382Ypm5al5ZdULTPvQu6u0s1J6LtgoMWXg7eN4WY2UWqTUXmuhCvw== X-Gm-Gg: AYBFou1iRj1Z2+R/rEGwbV5pjzAlL/084jSxazxNwsfNoOhLMDtDA7TNpH1P6/FM0qa LIJkVR4Avr1sicfOCVLoB2qI7/4hLpTcdZsEav2BIgDHAaOqrGSppvZ2yQSYteatD7KhXG7EN7s OxNrB1ygaaEywal4YLE2HT6Q7pjLGqo5+xhMKkxLC23T+VlvvMtR2QhDsabfkuW4vGAtbhqqXiz qDcNn/hcRiCCNglIAI3UJnICUcvzuxrHTVRWqc4GLy0jDsL648S8/FGkmxgdo4dt+PLTemL66rf 4f0CSXSNqg== X-Received: by 2002:a17:906:4fcb:b0:c2a:34fe:ea4d with SMTP id a640c23a62f3a-c510e358f88mr512273366b.25.1795089812179; Thu, 19 Nov 2026 04:03:32 -0800 (PST) X-Received: by 2002:a17:906:4fcb:b0:c2a:34fe:ea4d with SMTP id a640c23a62f3a-c510e358f88mr512268266b.25.1795089811516; Thu, 19 Nov 2026 04:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795089811; cv=none; d=google.com; s=arc-20260327; b=KAx4pTVjtnoqIn+ZDhOsymKy2N0vG/4aM7grMvSYFUik3T2EMZsEDeiA7LilQzIBhg 5zDmS8Rw/sJPfS4rNdqWskJBOK6LV/Cg0T+KnLbwZ4yrBqkc8b8Au6t69+OQCZl7pdnB qkvH/0qcFfH/cD5KQ1MlLhh2T7PT9rCtgy/zRJf7W6vIC4pcuRz+TrpkMEK87ezS8LcK cZgk8vOzqWUwftvkOaC73aj4K49qWy1CHzXyBxCdTTz2neXzh3EbL9l9WxUcUmUuoFAO zdsGEr56PUoSBjBW6fTYjfONFb3/6g610WPNtC7p0XEb7/wTfdi1lQJ9qR8aQKQvXwRC wxTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=830M35VEpoT2wmOF/kFZk6qjFbpiWkPYkOLRUtFNV/k=; fh=jynoinQ3iqAxGuE51huYhT8Ce2BSV1BrXclcVK01VwA=; b=giffKZFYKT3TgvPY/b9rHAgoGI4AAKbHdQYgnKWpqJDnJo1wc1afGttnGGQjMzoYhQ mD0lpXNanxZO95APfKfwfImnLSR2Dnj3sHau9EqDXWmFvXaeXsPpQL2vZDJx4D3AwduR rjbwqPEl9iIPLz572TV97Zhg3ZeXy3AeDqbjlh8TGSwo9u8dbu/LGtJrI7tQeJ9kpQQB eWXlQ7qpw3H6ejjLC+lxMWTV9xbSgarNVRmjOjC6+4hxKbN6htgmkvJKzufC54108PKN QEtDybFwrI0mXStXct4bXcG1zPPcl+KnbHugyFWqWUweXktF9CD8hXwPHm+tpK0KdYWg btlQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=YiJpXPcP; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a640c23a62f3a-c51235c5526sor79606566b.14.2026.11.19.04.03.31 for (Google Transport Security); Thu, 19 Nov 2026 04:03:31 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 as permitted sender) client-ip=2a06:5b06:b600:300:989f:a206:d03d:c3d5; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=YiJpXPcP; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1795089811; x=1795694611; darn=openvz.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=830M35VEpoT2wmOF/kFZk6qjFbpiWkPYkOLRUtFNV/k=; b=YiJpXPcPsU1+ISQ0bJjOWF1mAgv3BZZWv/Xp4cnK6RWo9i3m20S268e+hf5UygFHzC OqBrbJuIvfCkE0c250U2cjZKhI51b0q2xd00X4Jl/lpBG74LdOdnlwyvzvCVgzqHZzW+ gjdbEpWaxYDIFCMPff/geTGtNGugLNto0a3NP9UIl7yf4CngUV2Uz7CGKsQn5GDcceNb YYmmpsFgEnye9aUTZmlQZjAu9zfjR8xgvwV+LvPqvMK+BNfEYbbPyBaUaXAulH6OLewn Co5cDjT6VV7rghCcmYiBjAHiV7h592K/mIcSMCtEY4UNnogtRb2jLZ5/Dsf0mAJKhH91 FzFg== X-Forwarded-Encrypted: i=1; AL+hErHcEmsbH8W+f+TdyKw2P3zqMQJzTncLq4mvL72IJWnpOmKU8TlnUvOrU47s8gC6fydVY2W8qw==@openvz.org X-Received: by 2002:a05:6402:693:b0:6b8:fda:a28c with SMTP id 4fb4d7f45d1cf-6b887ebeb12mr3822722a12.17.1795089810847; Thu, 19 Nov 2026 04:03:30 -0800 (PST) Received: from artemis.sw.ru ([2a06:5b06:b600:300:989f:a206:d03d:c3d5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4a65541f3f7sm11036112f8f.24.2026.11.19.04.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2026 04:03:30 -0800 (PST) From: "Denis V. Lunev" To: ptikhomirov@virtuozzo.com, vasileios.almpanis@virtuozzo.com Date: Thu, 19 Nov 2026 13:03:19 +0100 Message-ID: <20261119120325.792064-3-den@openvz.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261119120325.792064-1-den@openvz.org> References: <20261119120325.792064-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 2/8] ms/ext4: fix string copying in parse_apply_sb_mount_options() X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Fedor Pchelkin strscpy_pad() can't be used to copy a non-NUL-term string into a NUL-term string of possibly bigger size. Commit 0efc5990bca5 ("string.h: Introduce memtostr() and memtostr_pad()") provides additional information in that regard. So if this happens, the following warning is observed: strnlen: detected buffer overflow: 65 byte read of buffer size 64 WARNING: CPU: 0 PID: 28655 at lib/string_helpers.c:1032 __fortify_report+0x96/0xc0 lib/string_helpers.c:1032 Modules linked in: CPU: 0 UID: 0 PID: 28655 Comm: syz-executor.3 Not tainted 6.12.54-syzkaller-00144-g5f0270f1ba00 #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:__fortify_report+0x96/0xc0 lib/string_helpers.c:1032 Call Trace: __fortify_panic+0x1f/0x30 lib/string_helpers.c:1039 strnlen include/linux/fortify-string.h:235 [inline] sized_strscpy include/linux/fortify-string.h:309 [inline] parse_apply_sb_mount_options fs/ext4/super.c:2504 [inline] __ext4_fill_super fs/ext4/super.c:5261 [inline] ext4_fill_super+0x3c35/0xad00 fs/ext4/super.c:5706 get_tree_bdev_flags+0x387/0x620 fs/super.c:1636 vfs_get_tree+0x93/0x380 fs/super.c:1814 do_new_mount fs/namespace.c:3553 [inline] path_mount+0x6ae/0x1f70 fs/namespace.c:3880 do_mount fs/namespace.c:3893 [inline] __do_sys_mount fs/namespace.c:4103 [inline] __se_sys_mount fs/namespace.c:4080 [inline] __x64_sys_mount+0x280/0x300 fs/namespace.c:4080 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x64/0x140 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e Since userspace is expected to provide s_mount_opts field to be at most 63 characters long with the ending byte being NUL-term, use a 64-byte buffer which matches the size of s_mount_opts, so that strscpy_pad() does its job properly. Return with error if the user still managed to provide a non-NUL-term string here. Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Fixes: 8ecb790ea8c3 ("ext4: avoid potential buffer over-read in parse_apply_sb_mount_options()") Cc: stable@vger.kernel.org Signed-off-by: Fedor Pchelkin Reviewed-by: Baokun Li Reviewed-by: Jan Kara Message-ID: <20251101160430.222297-1-pchelkin@ispras.ru> Signed-off-by: Theodore Ts'o (cherry picked from commit ee5a977b4e771cc181f39d504426dbd31ed701cc) https://virtuozzo.atlassian.net/browse/VSTOR-155988 Feature: fix ms/ext4 Signed-off-by: Denis V. Lunev --- fs/ext4/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index b10bfec7499b..bf42593efcea 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2494,7 +2494,7 @@ static int parse_apply_sb_mount_options(struct super_block *sb, struct ext4_fs_context *m_ctx) { struct ext4_sb_info *sbi = EXT4_SB(sb); - char s_mount_opts[65]; + char s_mount_opts[64]; struct ext4_fs_context *s_ctx = NULL; struct fs_context *fc = NULL; int ret = -ENOMEM; @@ -2502,7 +2502,8 @@ static int parse_apply_sb_mount_options(struct super_block *sb, if (!sbi->s_es->s_mount_opts[0]) return 0; - strscpy_pad(s_mount_opts, sbi->s_es->s_mount_opts); + if (strscpy_pad(s_mount_opts, sbi->s_es->s_mount_opts) < 0) + return -E2BIG; fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL); if (!fc) -- 2.55.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel