Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2693427lqp; Mon, 25 Mar 2024 06:53:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3Z+zA+EiIRaYwJkzNpRFgAyq18DxKfxr6xeSoJSIdKRED0yKnfJ+Qn/sV3k74+CSFu9P4+PXxtkiE9zAtP4GQ96nDgXUM2S74xzpvhw== X-Google-Smtp-Source: AGHT+IEP2ZZu7V7vBaXY1SkK7c6IP6CylvTOY9jnn+ePnE8ulXK8TXLyPM9ZHiXNMuNMBte6iAgW X-Received: by 2002:a05:6a00:18aa:b0:6e7:7fc6:1484 with SMTP id x42-20020a056a0018aa00b006e77fc61484mr10021828pfh.10.1711374810028; Mon, 25 Mar 2024 06:53:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711374810; cv=pass; d=google.com; s=arc-20160816; b=k2YITwlLWqHqlQmpe44adcpuGxSEe2vt3xi2vWBMbRii3TnB0gkZZl8SjSuQYdtpj+ K6i4PQmpghsxXBb4S+YYL0PDWKrsuvvxGqwGobJektCOLddAev6BmoMSTeraCJwOYxW+ hNLnyYzl2O1TCnw5dHWAiZDKAwWsGJqXB2gGQjlKzxVB8EgTiK7e9xAHgsGWfOLqiXpK 4AOgIcgb/fUf0rBGeluD+c2aFMlLYsTNJxyEvfinCRdWVtUBwM71D34BHLtsgl2otohy VnVoRi2ICCE7IgS+DXZuAcUHaoD6jsJBtUoo+ztGYOQhWUMJfZ5H3ALMFwdQjjk/o+dc jGlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=Y8rz1BfKkECiJkW1+pbPxCnQ661QHd66E/ukE6cKevc=; fh=oX7b956e4BZJb3zQBjQrAC96kvX+WHukNGnUw2DBAss=; b=kBg6/K7+bH8jmMZzDXKkpzQUPa0La3/HMArozzBWmWKovu57HgPJ4OtiaOHJvzyywC rSUOzK+KrW6XbfH5s+ubq3oyVxtAcLqn1Y990ZrtSZeYOTZUUNMUd1j3gfs1sCRcAL9s 9GI7usF7XfY2UIjbAOeBQV1JteTxqNur6GSgu9aRXIaMCI6x3pORXEq8ukNCPfSvAJx/ t/k66DGq2DtpN5QdeqvmID5vVDgUkKxVCsgujmPxEVR+SXd5+BtWwd/FcG7bfgN40Mku dzmjHF1/2lDTJXvQZcnB82J1a5dAV0BhZNJv7q8OlkB8ltqvACFXt2QzYGPU0bgWgwZj sGBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-116708-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116708-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p37-20020a634f65000000b005dc12a99c6esi7473316pgl.355.2024.03.25.06.53.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 06:53:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116708-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-116708-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116708-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3F62B2C8C6E for ; Mon, 25 Mar 2024 13:44:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4243313C9A0; Mon, 25 Mar 2024 10:28:06 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5028413C9BA for ; Mon, 25 Mar 2024 08:43:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711356196; cv=none; b=pTKnZKX/QnD2npCc7chQoswqd4lo9P88oP2JNPHiP8iiEbjMWWfR3TLfBV3pDW1SX9vMHCXaYKUKCyVkYiv7YQoWCLfM97FYdvILZtj3ss9wZAvL6cZ8mTnqiNIqGB1l1QBmtnww2bd2/fogk/Cpsh7sCBNznVusPhqaMSVSd/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711356196; c=relaxed/simple; bh=pzbzpSguYIEzkMi8viaS6qMY2ddR/vtNt7Vl1aYuKM0=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=dptBFsh46yC0mOM+kUk0ld1g1e4cDVGzDR49X4PPVy2igu1Hkmu5MKbEaA1LiGmtE7VfzugKHmIDVAMF+qNs6QBizFwDobcQfe42ERIUqt6T/URomhzvMzdnbXllXj9WzjC1mwqeT8+MNOB7cAk+MOHPGMxanaY1TKIKf6pls5U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4V35wx4MzVzwQ9k; Mon, 25 Mar 2024 16:40:33 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id 982F018007C; Mon, 25 Mar 2024 16:43:11 +0800 (CST) Received: from [10.174.178.209] (10.174.178.209) by dggpemd200001.china.huawei.com (7.185.36.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Mon, 25 Mar 2024 16:43:10 +0800 Message-ID: Date: Mon, 25 Mar 2024 16:43:10 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH] ubifs: fix incorrect UBIFS_DFS_DIR_LEN macro definition To: Zhihao Cheng , , , , , , CC: , , , References: <20240324120333.3837837-1-wangzhaolong1@huawei.com> From: ZhaoLong Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemd200001.china.huawei.com (7.185.36.224) Thank you very much for your comments and suggestions. >> A previous attempt to fix this issue in commit be076fdf8369 ("ubifs: fix >> snprintf() checking") by modifying the snprintf return value check range is >> insufficient. It avoids the premature function return but does not address >> the root cause of the problem. If the buffer length is inadequate, snprintf >> will truncate the output string, resulting in incorrect directory names >> during filesystem debugging. >> > > I don't think 'snprintf' ever truncated the output string in dbg_debugfs_init_fs(), even before be076fdf8369 ("ubifs: fix snprintf() checking"). The 'UBIFS_DFS_DIR_LEN' contains trailing zero byte according to the comments, but actually all callers treat it as real string length without '\0' terminated(eg. dbg_debugfs_init_fs, ubifs_sysfs_register). > So there are no actual problems here. The only problem is that the comment of 'UBIFS_DFS_DIR_LEN' is not consistent with its' usage, the simpliest way is modifying comments. If you still want to cleanup the code, please remove the wrong fixing tags. Regarding my original commit message, I realize that the statement "If the buffer length is inadequate, snprintf will truncate the output string, resulting in incorrect directory names during filesystem debugging." is inaccurate. `snprintf` does indeed stop writing when it reaches the specified buffer size and appends a null character (`'\0'`) after the last character. However, since the buffer size passed to `snprintf` is sufficiently large, the directory names are not actually truncated in the buffer. > If you want to clean up code, modifying sysfs related code(ubifs_sysfs_register) is needed too. That's a good suggestion, I'll go through that part of the code and make the necessary changes for consistency. Thanks again for your valuable feedback. I'll take all your suggestions into consideration and adjust my patch accordingly. I'll resend the patch once I have an updated version ready. Best regards, ZhaoLong Wang