From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64901C4338F for ; Tue, 27 Jul 2021 13:55:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 473B961220 for ; Tue, 27 Jul 2021 13:55:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232428AbhG0Nzl (ORCPT ); Tue, 27 Jul 2021 09:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232185AbhG0Nzk (ORCPT ); Tue, 27 Jul 2021 09:55:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ECABC061757; Tue, 27 Jul 2021 06:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=l4bB1NlxVXKcS4LQH7ZeuR6Hp+on28hni4p/W0kSjD4=; b=oNBSHh/gHXG3Z45AYhgsq+WS9p eK3d75tBcu835JmU9D3E0+CNOwhAI3icsXwtzMWlgPhe5EZSK9qUO8RUOZwHIM8OyibmnLxmEUG0g AKMZWpoOIBkah6xZnXUsKIjhlbIxlvFtQW8Q1VLSLzIbXISvBgkqB7yRYzi3xpuUaG/75QpKxLTKn 0goXwnJ6MEKbCHFftBPhwIHzWrHIOF8jN5GbNMbk0CtEmWX6S2LaOsUHD1KMs2Vsz4M6MMsvB78Mk boKi0VSeKtI2CojJPZ6Lgb3wUv2A2I4Zp+xbWQDPzLX+RxY6wrYecuPuqzfr+ON/qXkKWhwXScxqB nH07UwCA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8NWR-00F4Fh-RU; Tue, 27 Jul 2021 13:53:50 +0000 Date: Tue, 27 Jul 2021 14:53:27 +0100 From: Matthew Wilcox To: Greg Kroah-Hartman Cc: Andy Shevchenko , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jordy Zomer , "Ahmed S. Darwish" , Peter Zijlstra , Eric Biggers Subject: Re: [PATCH v2] fs: make d_path-like functions all have unsigned size Message-ID: References: <20210727120754.1091861-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jul 27, 2021 at 03:30:55PM +0200, Greg Kroah-Hartman wrote: > On Tue, Jul 27, 2021 at 02:14:37PM +0100, Matthew Wilcox wrote: > > On Tue, Jul 27, 2021 at 02:56:53PM +0200, Greg Kroah-Hartman wrote: > > > And my mistake from earlier, size_t is the same as unsigned int, not > > > unsigned long. > > > > No. > > > > include/linux/types.h:typedef __kernel_size_t size_t; > > > > include/uapi/asm-generic/posix_types.h: > > > > #ifndef __kernel_size_t > > #if __BITS_PER_LONG != 64 > > typedef unsigned int __kernel_size_t; > > #else > > typedef __kernel_ulong_t __kernel_size_t; > > #endif > > #endif > > > > size_t is an unsigned long on 64-bit, unless otherwise defined by the > > arch. > > ugh, ok, so there really is a problem, as we have a size_t value being > passed in as an int, and then it could be treated as a negative value > for some fun pointer math to copy buffers around. > > How is this not causing problems now already? Are we just getting > lucky? include/uapi/linux/limits.h:#define PATH_MAX 4096 /* # chars in a path name including nul */ Clearly some places aren't checking that, but _in principle_, you aren't supposed to be able to create a pathname longer than that.