Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4660663pxu; Tue, 13 Oct 2020 04:13:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaE7rvQJxp6EfVBAlcN1X5qlvm9/DbQkDZBTFd9RLYUALV0gvs5PwcVsCOrB9Bkoxfz+Ks X-Received: by 2002:a17:906:395a:: with SMTP id g26mr31622596eje.147.1602587608409; Tue, 13 Oct 2020 04:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602587608; cv=none; d=google.com; s=arc-20160816; b=vaqH89R5tNEOVhCDDCpbcvTeEdFyoJRb3uQF1Sz512AWEAU19RnFCr+WD1Rkr2bCRh KzLjwSAeXI2gUKTRVjdcLXQh+jrpxd8sXcvM8Pmx46/f4gDE1kIbwkTkiUbI8bh+/KNl IyRyPa7ZP5u1/7zGwMaOpuVE0qRQNq8D1Ygc0NHc+1BljR/ewkAq+AYcsGba6g6IAxC8 2nL5b6K38XlYk3MC8WqND10vlCnaDW9WYY5G+GuFUjV8qwXPie3uO1zMlA9Hp/g3r60B PeEvGfv6JlREhTd6c1Nd7qFzOeHWAElm9o6ID6PfvdcbgVn7sA5OonDdCWxeZOHL1CG1 ZDIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=LAP1T1JAnG2HJETBGKHtI+zO8NC5NvDJAklkJA95KlI=; b=B3VbU/d7bJC1eLQlT+Uw5iYoD9NgmapBQUOrywbIILRR4LemUElS22Lm9shQzw8XkY 5Oh0uro+hHLK0pQRbsMfYn5DST36EVHShfkF4Mv1O+EeZXyj/OiN51RhH2XIYsqdDCra 87SqxaqDZlF2nz6msqp902SexIpnrd2F8XCwaJXvj1GKgzSpoR2zq1I3NbKLLo992Sxd 5KU4mPa2beKGrpX3Io+4ILuNgZ4wxJrpG/VLmA63uhUGAXyICsMBGHWHo+oQg9gZoBDy 4UcXfKVXyBlLDHAD/nY5c/HP8SygumOBm6eej/POkSEyc8N4O3D0eEBjjraDRwtV+87/ zi3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ArQzbOgJ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si13496021ede.379.2020.10.13.04.13.04; Tue, 13 Oct 2020 04:13:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ArQzbOgJ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726197AbgJMAJG (ORCPT + 99 others); Mon, 12 Oct 2020 20:09:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32195 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbgJMAJE (ORCPT ); Mon, 12 Oct 2020 20:09:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602547743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LAP1T1JAnG2HJETBGKHtI+zO8NC5NvDJAklkJA95KlI=; b=ArQzbOgJaZA5ABYdXmcW9O2hcHC3XS6KfBQVtYCCzNiuKGJEKSRFKAuIf/h/Wi73u9g3HD iKiUUpxbhFxyjZ69nGvdJW5rOjsbUq0MZPyLNtQrUymkbISKFlHVWqLuhE4boTqm17aWaY YUmXkGPKkBV9ezrmSrxTxMVHaI9c23E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-XEu3x5wSOryDNKrHD3xpGA-1; Mon, 12 Oct 2020 20:08:59 -0400 X-MC-Unique: XEu3x5wSOryDNKrHD3xpGA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4CE71018F63; Tue, 13 Oct 2020 00:08:57 +0000 (UTC) Received: from [10.3.114.107] (ovpn-114-107.phx2.redhat.com [10.3.114.107]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B0B65C269; Tue, 13 Oct 2020 00:08:56 +0000 (UTC) Subject: Re: [PATCH v3 RESEND] fcntl: Add 32bit filesystem mode To: Linus Walleij , Theodore Ts'o , Andreas Dilger Cc: Peter Maydell , linux-api@vger.kernel.org, qemu-devel@nongnu.org, Florian Weimer , Andy Lutomirski , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org References: <20201012220620.124408-1-linus.walleij@linaro.org> From: Eric Blake Organization: Red Hat, Inc. Message-ID: Date: Mon, 12 Oct 2020 19:08:55 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20201012220620.124408-1-linus.walleij@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 10/12/20 5:06 PM, Linus Walleij wrote: > It was brought to my attention that this bug from 2018 was > still unresolved: 32 bit emulators like QEMU were given > 64 bit hashes when running 32 bit emulation on 64 bit systems. > > This adds a flag to the fcntl() F_GETFD and F_SETFD operations > to set the underlying filesystem into 32bit mode even if the > file handle was opened using 64bit mode without the compat > syscalls. > > Programs that need the 32 bit file system behavior need to > issue a fcntl() system call such as in this example: > > #define FD_32BIT_MODE 2 > > int main(int argc, char** argv) { > DIR* dir; > int err; > int fd; > > dir = opendir("/boot"); > fd = dirfd(dir); > err = fcntl(fd, F_SETFD, FD_32BIT_MODE); This is a blind set, and wipes out FD_CLOEXEC. Better would be to do a proper demonstration of the read-modify-write with F_GETFD that portable programs will have to use in practice. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org