From patchwork Thu Nov 11 11:05:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 519123 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp115316imj; Thu, 11 Nov 2021 03:12:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8ByAOaq/O+FzRaX0P/lzMC0EaRWqzcZ5VxEkiFqFji1FUv9cRhddUCg2yclf4OJ9b/H6+ X-Received: by 2002:a67:d893:: with SMTP id f19mr9079575vsj.39.1636629127139; Thu, 11 Nov 2021 03:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636629127; cv=none; d=google.com; s=arc-20160816; b=b1YWsCfPMtPmVQPUe4Ijc+B3zv2tV/SRf4t8my387o5Rp//DGQ2lHr7s8La9zhQN4H yrwuTrzEEvryk/nVgQ8W4qitfwMtA7wFO2niewT7Wq+gUA9qTf11TEHXipVgRlJr2HZe 772nqi4qIrxaTIHxNZf2cMbuL3KmvxPlHOyKSqMeuke3fr6Ezt4QMaRlKo6qOSQsxiCZ h2Nb4fzNR94S6w2dnrLo8Qf8J0jXP5gxBSqT++v3XrmhsMe69MyIz0vxsBtPgUkWqOcn 35AcMEsGHITB9c4MomVqxSuBZ90iwjriQ3Z5HwuEugJ0GIn52jpkhgEjd1iYjww7zs8J VfVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=4Ue9aGUavsUkq+ShZeIUgd8duye3YsEvk3s9aGHMy6o=; b=iFFSkkivo5VYitcgnRqKPKSCCA4nkIgWQ7te/GPjwmFxnLRsKAeAFdj9160qLBfzGY dWZs6lm3coOKIdTz7o09fm+nWoBSpyt5xdw7LojLce7qhg1vTLV1cHwFwj0iLUSZrmAv A+9WFk9HyyejrqN5bIAo+jYO3pnIPFD3ZZxmUMLjdZ4Yf1PprQNUCRL3lEZ/BDIwFZjU vlxeIctKTCpdmgjMNGQ2SIRweOIiXj0ZoyRZfzGQB3ATVTeifF7TfmZqSgIaDvv8XOLr uguZ34OEjLH4L8O0yyPnKw4w5LAx3qqy2xJDa9b4mdjKNV7TP4SJRQeeTwx3IyXuzyEJ X2xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t6si5802138uar.51.2021.11.11.03.12.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Nov 2021 03:12:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml7zy-0004PG-Jm for patch@linaro.org; Thu, 11 Nov 2021 06:12:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml7tW-0002b1-51 for qemu-devel@nongnu.org; Thu, 11 Nov 2021 06:05:26 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:34435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml7tS-0001Nw-Df for qemu-devel@nongnu.org; Thu, 11 Nov 2021 06:05:25 -0500 Received: from quad ([82.142.28.210]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N7Qkv-1mdRKl3U6f-017pun; Thu, 11 Nov 2021 12:05:11 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 2/4] linux-user: Always use flexible arrays for dirent d_name Date: Thu, 11 Nov 2021 12:05:02 +0100 Message-Id: <20211111110504.1574242-3-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111110504.1574242-1-laurent@vivier.eu> References: <20211111110504.1574242-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Y7N1/nm7yO02QgfWbhhUhL4aYf/7Q8jdUY37z1DheT+OjE5Y0al hKn9m1LmI+J2HmS5fayEO8bKblA/FfOvM4akdbTxKw9uwpVJB8X1u4QJT8sqf/2KjF4UXiw fE+h0s5QeaipsMZ+sd32DUfPGmn3gRLByV/HDxqKt+HLXI37DkOYMRgapgVLO+8NJ01pRQo 9C0B4oib7BTlHmZQF1SDw== X-UI-Out-Filterresults: notjunk:1;V03:K0:gVWWFhXmH2s=:oIEwGSh7Bu9h44Iag04vSA 3ZV4SFjkxBo8WhyCBY+jEM46UWIB8uLRJcrOI9xViYqRqfyQTENDETFnFDHjT73vFhQWN/tCM +fhUjIQsRgnwGK2uQU8c0cZbT3qxhCkNe9ddeaeRROxg7vOHBFGa+csnIWfrjlvjYqpzhr51O XvljRKLRvcIRg9LCVBuxhpejUqlcGMeeScySMwlei5uAU9ElcOuY7eLYldJTWXrwSsUkoqoLo 3pvcGTAqxU7AoUmILwN4p8n2516xoYNgTZT20IkKXvnZiWqFt0FrlB9boNqG57l5Dv8HPSPyN 9ZSBI1xVxN+WPxV2GL6rHe2H65RwjLx0CHWrmJ6mVQl6GB4htCUx83zeoZbIM1OvNuxwpAkEt NkEyVWKvgsIBz2mRaL8hzIuHm4G6/ZUtFIYxld+QhuubWZoiyQv2a1y09nDX/dDou9Jm+12sU M0D2+IlcSdj+ZDPPcpVkvihzj4OV4CA1HRRnte6TPHNtpJc8ScOLwaBUgnkhyj5MPxbFTXdyk kMEbq5fbPosWwYIoXL8hURRay3mmiVDxOBCapEff4ztlmaSoczy8m0lZkx8xN/x8xJMA0l4iT XCuFsRQAs8IYmTLBILTgDg/WVQAkEnq0cWaQSpLOyHwsI6IaJm2RRb/GaXXL1kciyobymAnG1 JNdgprHLqWil1opcPWNLCQtAhqhF/KU4A4Tlr6nNpXBjdzk5+0KIzaSrO2CXwNIH2Hw4= Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We currently use a flexible array member for target_dirent, but use incorrectly fixed length arrays for target_dirent64, linux_dirent and linux_dirent64. This requires that we adjust the definition of the VFAT READDIR ioctls which hard-code the 256 namelen size into the ioctl constant. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed by: Warner Losh Message-Id: <20211107124845.1174791-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 6 ++++-- linux-user/syscall_defs.h | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a2f605dec4ca..499415ad81b8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -197,8 +197,10 @@ //#define DEBUG_ERESTARTSYS //#include -#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct linux_dirent [2]) -#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct linux_dirent [2]) +#define VFAT_IOCTL_READDIR_BOTH \ + _IOC(_IOC_READ, 'r', 1, (sizeof(struct linux_dirent) + 256) * 2) +#define VFAT_IOCTL_READDIR_SHORT \ + _IOC(_IOC_READ, 'r', 2, (sizeof(struct linux_dirent) + 256) * 2) #undef _syscall0 #undef _syscall1 diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index a5ce487dcc38..98b09ee6d656 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -441,7 +441,7 @@ struct target_dirent64 { int64_t d_off; unsigned short d_reclen; unsigned char d_type; - char d_name[256]; + char d_name[]; }; @@ -2714,7 +2714,7 @@ struct linux_dirent { long d_ino; unsigned long d_off; unsigned short d_reclen; - char d_name[256]; /* We must not include limits.h! */ + char d_name[]; }; struct linux_dirent64 { @@ -2722,7 +2722,7 @@ struct linux_dirent64 { int64_t d_off; unsigned short d_reclen; unsigned char d_type; - char d_name[256]; + char d_name[]; }; struct target_mq_attr {