From patchwork Sun Nov 7 12:48:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516842 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp2303416iml; Sun, 7 Nov 2021 04:51:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfZjMJd+2Dg5EEG+ifu2eQLePw2asf/SkT51G2bAm5YJnFkHQs13SD8zgu1uSyEYNnnBB1 X-Received: by 2002:a05:6808:d46:: with SMTP id w6mr32502754oik.40.1636289502286; Sun, 07 Nov 2021 04:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636289502; cv=none; d=google.com; s=arc-20160816; b=vsnjITmyDJrlzgAgd/Uj+3baA0xcQoP0zqzgBQTY95+r4G5LrNaFX56CjXwJKbU5W4 n9AZKwa5c0AAkK0XsbRqxLjzmSdWjHsFvx2aPUj78XScq6+RgKs+0ECjc82xc5E5tsjA O52xGZsWBMVr+Foj3uv8cWSqQWzkiIRILzlOphTtvbjbehOrY+e9yxQmK5vgj5+V8PCG myasYP3RIUZco4/npAPh0vxb4xdZcl4Y0tpfKPxe6AvXdBCBdqmMgnG028MiOs+3sEE+ gdYpif0EccNGKzp7pzQ3TtMXmEKjdI8houNm3DhSEXyyAYZkJIIrr0k51ZZ1oE99YYZ8 0AEw== 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 :dkim-signature; bh=NgWRpb6eD25eDJnCmvoWcYOQSpkeHkzdEszyRb0jyTc=; b=mUYk4PEL+xMp343pjSa1IoYPWTxb6PTRKnXnvlN5LX8BwfRIXZAOI07ycsxkW9VP7j NxKCLKnKCB64fnqxhZn9IDKOOpg9aVwL4z605OlR4iZL1WKA8369nQl2ylDUOfja3pTo 8EBEK3kPTEGlFX7HC8Fx/ffcMRUTuOqsAcrznAJ7xONvEhKtWVC4uJ3Y22iBfuSN192+ 9qXBwQ9b7gkPoJ79uommb8Txx4svNqFt1d9TB4UGzCleJrZq52WhtjLVyeyBeTcsMA9u x3xETw2fTUQvfNXgchNF8HXqxcdzJDHvNy+9o1SujI1i5gBesCW9AI+daIDuedHgBESz +ZXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LHECL2Ax; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1si18454687oiw.56.2021.11.07.04.51.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 07 Nov 2021 04:51:42 -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; dkim=pass header.i=@linaro.org header.s=google header.b=LHECL2Ax; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjhe9-0006X9-MW for patch@linaro.org; Sun, 07 Nov 2021 07:51:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjhbP-000343-9P for qemu-devel@nongnu.org; Sun, 07 Nov 2021 07:48:52 -0500 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:38519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mjhbN-00026G-Ax for qemu-devel@nongnu.org; Sun, 07 Nov 2021 07:48:50 -0500 Received: by mail-qt1-x829.google.com with SMTP id c12so6803358qtd.5 for ; Sun, 07 Nov 2021 04:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NgWRpb6eD25eDJnCmvoWcYOQSpkeHkzdEszyRb0jyTc=; b=LHECL2AxH4ua7CW9c++czvjfYDapl6y+B5lIuI8XiO6N1nTsUJcbZphl9Mrak7QoY6 OrP2iMAhiT3Od+UfrUyOx+wR4dM2JxkaxCzPktxdEGUqaoP1R4Ld5/Mw1D+1lleCVbnQ ld+xQ07OYAvanqgFE/0i85tY8dwy5Tgdfztv30ZcfGYIvYphrNmw3OYH/XwiL5V2UIqN 4lTilUqnl/Q4nH9wtikfTsChP2TjoizrKWiStWtIwO3Op3koPeTAs6DFetB9Bl7MH6OB mq65Vw+YW5rtrsJb8R/tsuktpm0/1yaWMY8KlccFY+NxVKzf0Gxb95lcsmPOUi94QD3N HwDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NgWRpb6eD25eDJnCmvoWcYOQSpkeHkzdEszyRb0jyTc=; b=0B1vJnV5ZvgUh04S4C3CTYjc/eokM4y0TfLE/FWCvwrkEb63YP9l2awFQ9lvjqYYP+ PCmJc7lR//jszA+3rJBFegZXnzQH9ptoSFQC4QKwnn6PHPr36SaMc0WabLamluCKz+1Y uFdFdvZaVGg63FAP3vvW/IytnaSoown0J0CEG1/RcXi5VRQ3rKHA2lgAK74JolXd5sXw BPsgArChwm6z2I4ujymi+dPBqhpYQoORZiO3aF7lB4XQbMaRVypSf2j8lQAkv5LjL2Ta kGadTAC29DIMOGKGi6xU4QI+XAPPmPuhkBd/XN9xNDNmUIdZHcP2lsMawfCxk9NO3U9v VwaQ== X-Gm-Message-State: AOAM530mInmMP9+sReFg9OLFDfDBnPzE1ODOyqd7mcQT1Hv0WX+a0Vg8 WJq2X6qR9Wm06b8265rlMen7BwUZFxAkAQ== X-Received: by 2002:a05:622a:1449:: with SMTP id v9mr56241399qtx.122.1636289327300; Sun, 07 Nov 2021 04:48:47 -0800 (PST) Received: from localhost.localdomain ([38.66.81.217]) by smtp.gmail.com with ESMTPSA id w19sm6917qkw.49.2021.11.07.04.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Nov 2021 04:48:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/4] linux-user: Always use flexible arrays for dirent d_name Date: Sun, 7 Nov 2021 07:48:43 -0500 Message-Id: <20211107124845.1174791-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211107124845.1174791-1-richard.henderson@linaro.org> References: <20211107124845.1174791-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x829.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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: f4bug@amsat.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é --- linux-user/syscall_defs.h | 6 +++--- linux-user/syscall.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index a5ce487dcc..98b09ee6d6 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 { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a2f605dec4..499415ad81 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