Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp765444pxb; Tue, 12 Apr 2022 12:52:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL0unF64WX1rFFLXNZC1rs0ZBIb+VZ/bOMqHeY8Q6PGRgRTK6vDt6JRvAV4FHc91SFsn7r X-Received: by 2002:a63:fd43:0:b0:39c:d17a:62af with SMTP id m3-20020a63fd43000000b0039cd17a62afmr22208483pgj.450.1649793167949; Tue, 12 Apr 2022 12:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649793167; cv=none; d=google.com; s=arc-20160816; b=DsLHgFSyD05x5l2SU28VaDapnUIQ0976BKms6JMgD7/PHUT9+MzVc8H02Wh4gYdQID 9sE7xFQBQaQG44HZ4TsH29UwLczOOk7XFxCl00L55gGsd3jeGS0RcMC7bPkRpbd0q+Jp ENIUhD1eawUI9l80MZFMN+TSReBBkC3/JRsrC8iqB00fgxbWEleLfVmOBiFECLxCQga8 yEJz3cjCrhtyi1Rh8lbfFkyjIfL8rMJqI2lHFa2utPvuyO8X5oR8rVMJ2fpH9fi/gE0Q jBg8OIucwILZN8dKLtQqnB+5FXZBmRJ1Vv1GY4VrhExB4cpaaeDh3wshmbg4L90HZQ87 CRkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ll/XCn4eT+mWamanV6qNk4+X9BXYFUW6oQ8MurM5uWk=; b=WqiaiJrXrE/oXaIz8DHu5b46CpyGn6tKp8MaCt5TUP27IlgM1m3I9UDbJisJqyXHDf VZn4fSsR8pNPZpeagts0W8e12R2MHyfsBuVMyXL62YkOeOvZBYDplAEsvyrNgivf8xT3 3uqt44BZlx51qUYVDcCXEXf4GfYR0kWV1lPCuIU/vDfjz3DhWkX1s2zvX6bjcFwXnFqt xu8Vi9wJG/G3/1y7oVL441SFIER0B/qdMSmQiFThBA8q1grUY92yRvh8ztxlf/rTkCyL 1geHLZQPNhihapDC9doi/x1XjT6rRSEl4U+Ck8akiqeKmSwVNf/mBW9HY4UvojMqPkXx G5lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=fgDQtBam; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o12-20020a170902bccc00b001570d09613esi11525058pls.472.2022.04.12.12.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 12:52:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=fgDQtBam; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 342114C7B5; Tue, 12 Apr 2022 12:48:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348291AbiDLFkn (ORCPT + 99 others); Tue, 12 Apr 2022 01:40:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348274AbiDLFkk (ORCPT ); Tue, 12 Apr 2022 01:40:40 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B4B344F9 for ; Mon, 11 Apr 2022 22:38:23 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id p10so30229603lfa.12 for ; Mon, 11 Apr 2022 22:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ll/XCn4eT+mWamanV6qNk4+X9BXYFUW6oQ8MurM5uWk=; b=fgDQtBam00x6nb34pezhr9TPAf1bSvMtM9E7e+7/EJFJ0nDM4iVhYJw44irfk6xwVf a/rZdmHC8yHQm0YKrnUgWgtnnIIt+39mjQLGJjZI9WcmYGULNEqjt8ngp9lF9MPtXJid 4JXvtH94CmaNaA67XvUEW5RqzRlX4VH/u8qsY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ll/XCn4eT+mWamanV6qNk4+X9BXYFUW6oQ8MurM5uWk=; b=cpTi9rnjeVVfchw622CRw89KiKPz1CdFB2WRK7qsdmkKQFiHQrKM8ZM3hzDeRFDhYJ iv3QHuvRfph26XNvFXrBEyF36bBE6/59YhqbaYnaM5F0GgUoZlfQfayCdSWq0Rcy6N+g mKpP4fTPuDWJnDyjcS7aTHTvwiOdwfkR3hmcIJ4hO0qCgxHQyDB8QPg33XLm5tliNfu3 HMpDCUE/cwIhbcI+bjiqWS8z0IJ/P10YcsqWK5ie5tR8Wh1JUejkdZKhbRtg3dwbRZ7Y HElKjPv9xeTVjBW5hzeIrQTgrhuYLEwxXGOlcgIq377XqfsjfCRZSCfTbnqgI3SgkG8t 2rKA== X-Gm-Message-State: AOAM533enmS59AsYB5faaB0E+x52mPYCYh6muKIjis3BGPh1isKxNt4I T97M6ScpAsiSPAwruhEAj4P9Aj8QEZklX2Uz X-Received: by 2002:a19:8c4b:0:b0:44a:b6a4:4873 with SMTP id i11-20020a198c4b000000b0044ab6a44873mr23636723lfj.549.1649741901175; Mon, 11 Apr 2022 22:38:21 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id j5-20020a196e05000000b0046ba00b5e88sm755475lfc.230.2022.04.11.22.38.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Apr 2022 22:38:20 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id x33so23844465lfu.1 for ; Mon, 11 Apr 2022 22:38:19 -0700 (PDT) X-Received: by 2002:ac2:5483:0:b0:46b:9dc3:cdd4 with SMTP id t3-20020ac25483000000b0046b9dc3cdd4mr8854787lfk.542.1649741899091; Mon, 11 Apr 2022 22:38:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Mon, 11 Apr 2022 19:37:44 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] stat: don't fail if the major number is >= 256 To: Mikulas Patocka Cc: Alexander Viro , linux-fsdevel , Linux Kernel Mailing List , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 11, 2022 at 7:13 AM Mikulas Patocka wrote: > > Should we perhaps hash the number, take 16 bits of the hash and hope > than the collision won't happen? That would "work", but I think it would be incredibly annoying to users with basically random results. I think the solution is to just put the bits in the high bits. Yes, they might be masked off if people use 'MAJOR()' to pick them out, but the common "compare st_dev and st_ino" model at least works. That's the one that wants unique numbers. > For me, the failure happens in cp_compat_stat (I have a 64-bit kernel). In > struct compat_stat in arch/x86/include/asm/compat.h, st_dev and st_rdev > are compat_dev_t which is 16-bit. But they are followed by 16-bit > paddings, so they could be extended. Ok, that actually looks like a bug. The compat structure should match the native structure. Those "u16 __padX" fields seem to be just a symptom of the bug. The only user of that compat_stat structure is the kernel, so that should just be fixed. Of course, who knows what the libraries have done, so user space could still have screwed up. > If you have a native 32-bit kernel, it uses 'struct stat' defined at the > beginning of arch/x86/include/uapi/asm/stat.h that has 32-bit st_dev and > st_rdev. Correct. It's literally the compat structure that has no basis in reality. Or it might be some truly ancient thing, but I really don't think so. Regardless, if we fill in the high 16 bits of that field, in the _worst_ case things will act as if your patch had been applied, but in any sane case you'll have that working "unique st_dev" thing. I'd love to actually use the better "modern" 64-bit encoding (12+20 bits, or whatever it is we do, too lazy to look it up), but hey, that historical thing is what it is. Realistically, nobody uses it. Apparently your OpenWatcom use is also really just fairly theoretical, not some "this app is used by people and doesn't work with a filesystem on NVMe". Linus