Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8507537imu; Fri, 28 Dec 2018 20:36:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4CldGK2g2EWV0sev9fNtNX6vdYLdPI9hpHt/0tqKBV8SlCFds20grPaG7fmCGyaQgyoxmr X-Received: by 2002:a17:902:b707:: with SMTP id d7mr28735355pls.29.1546058209485; Fri, 28 Dec 2018 20:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546058209; cv=none; d=google.com; s=arc-20160816; b=OIVzUReSesSxOBlEYQYALk7t0a1ok4JmgHO0N+MP6+5k/gCuO9zFX35X3Ou9FpRAE8 kO4cWnsRBAKfKXiqvPVYMBrUPq7dtn84UJgDorsVR/tKVF41emGEsIosBOkuqoa+2rAn sSmwOv6inEOa8IseEzRvl/j/p9Berq31ef1vsdsazKHzTwaMThXRG1JSu/f8DS8UHQLL aiJrFbS9nUYZU33EnSN3mDStHqgdm8D+nqj1DJ+3dPZ1bTo8rtODUzFQnLn7N//+veLo iMPMerOAhb+NS7lJr6xNkt3CGiSFvsLwneREw9xiXR9ok7mKXSD2KgfKuh4PauSUg2Us P2dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NXoE1G1kR3FwIkUeOtNmtyPXOlBUgJQPuQ+I/7Fmd/I=; b=JnTvaSV9886idi7DevY/ngmz9cRhRiaSlMIRd7TJcD6GWHi2FnjdCqx9wWqnp2ED5T HrTkBLEVXANkXMPXHB9/GTIQ8jlvQU+fnvG9QQzWqH2bzcoL8l1mjsW/n+WkIAbDIbnV YXrS4FxSvm5wzB5zuKlOxZNILf8vIcrlmOGH1g+rcAGXW/SAQnDiavaOyhZSR2VtFewQ 149N5wSQ9PVKjU8as7zCMM0QQsQNFaH6QG2bV3JPYKyvQWRz8oYdx0yvss+76FLWhqqj 4k5IarHHLDEIGN+1qY7WXQ0q6yiViQJNH/BjJHuVpBpIuv53ithWU3/u/ptk17siN99n TkrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l80q3zRr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 124si40636626pgg.397.2018.12.28.20.36.33; Fri, 28 Dec 2018 20:36:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l80q3zRr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729323AbeL1P0P (ORCPT + 99 others); Fri, 28 Dec 2018 10:26:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:50284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729314AbeL1P0P (ORCPT ); Fri, 28 Dec 2018 10:26:15 -0500 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2739721872 for ; Fri, 28 Dec 2018 15:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546010774; bh=MktodN6LfpP5c2RyxKeHRrnNbEE1p/4Fth/u500O+Js=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=l80q3zRr0qeic4eLjPtjQtwU4ib1MCFC/HM4YmSauzbNug5dsoZOo2z+TcDhQVpkb 8fQF4e6CI4l2Vx3uVTDQ8ikB4Jo9/B2ZNJKzQYk3LJz0CG2Q0BGKdqucNp8ZfontN1 qYTwwTfrclOwyyNqCOR4pjAx7RhzDHkQKMn0Wh1M= Received: by mail-wm1-f49.google.com with SMTP id m22so20061102wml.3 for ; Fri, 28 Dec 2018 07:26:14 -0800 (PST) X-Gm-Message-State: AA+aEWbEZnSxawX30/vpoe48FGA9Rwg0vabRg+eDQAzxBM90aB63nvYS 4u2API73s5Qzhpsdj1unwashsXlN8oXLtq6oyINJfQ== X-Received: by 2002:a1c:f112:: with SMTP id p18mr23342434wmh.83.1546010772484; Fri, 28 Dec 2018 07:26:12 -0800 (PST) MIME-Version: 1.0 References: <87bm56vqg4.fsf@mid.deneb.enyo.de> In-Reply-To: <87bm56vqg4.fsf@mid.deneb.enyo.de> From: Andy Lutomirski Date: Fri, 28 Dec 2018 07:26:00 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: d_off field in struct dirent and 32-on-64 emulation To: Florian Weimer Cc: Linux FS Devel , Linux API , linux-ext4@vger.kernel.org, LKML , V9FS Developers , libc-alpha , "qemu-devel@nongnu.org Developers" , Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , "H. Peter Anvin" , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [sending again, slightly edited, due to email client issues] On Thu, Dec 27, 2018 at 9:25 AM Florian Weimer wrote: > > We have a bit of an interesting problem with respect to the d_off > field in struct dirent. > > When running a 64-bit kernel on certain file systems, notably ext4, > this field uses the full 63 bits even for small directories (strace -v > output, wrapped here for readability): > > getdents(3, [ > {d_ino=3D1494304, d_off=3D3901177228673045825, d_reclen=3D40, d_name=3D= "authorized_keys", d_type=3DDT_REG}, > {d_ino=3D1494277, d_off=3D7491915799041650922, d_reclen=3D24, d_name=3D= ".", d_type=3DDT_DIR}, > {d_ino=3D1314655, d_off=3D9223372036854775807, d_reclen=3D24, d_name=3D= "..", d_type=3DDT_DIR} > ], 32768) =3D 88 > > When running in 32-bit compat mode, this value is somehow truncated to > 31 bits, for both the getdents and the getdents64 (!) system call (at > least on i386). > ... > > However, both qemu-user and the 9p file system can run in such a way > that the kernel is entered from a 64-bit process, but the actual usage > is from a 32-bit process: I imagine that at least some of the problems you're seeing are due to this = bug: https://lkml.org/lkml/2018/10/18/859 Presumably the right fix involves modifying the relevant VFS file operations to indicate the relevant ABI to the implementations. I would guess that 9p is triggering the =E2=80=9Cnot really in the syscall yo= u think you=E2=80=99re in=E2=80=9D issue.