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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 461A7C7EE23 for ; Mon, 5 Jun 2023 13:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233502AbjFENY3 convert rfc822-to-8bit (ORCPT ); Mon, 5 Jun 2023 09:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbjFENY1 (ORCPT ); Mon, 5 Jun 2023 09:24:27 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 730B7EA for ; Mon, 5 Jun 2023 06:24:22 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-2-O5Y6mELAM7an8ptyuTEDNw-1; Mon, 05 Jun 2023 14:24:19 +0100 X-MC-Unique: O5Y6mELAM7an8ptyuTEDNw-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 5 Jun 2023 14:24:07 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Mon, 5 Jun 2023 14:24:07 +0100 From: David Laight To: 'Kees Cook' , "Dr. David Alan Gilbert" CC: Dave Kleikamp , Christian Brauner , Dave Chinner , "jfs-discussion@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" , "linux-hardening@vger.kernel.org" Subject: RE: [PATCH] jfs: Use unsigned variable for length calculations Thread-Topic: [PATCH] jfs: Use unsigned variable for length calculations Thread-Index: AQHZlKngOBVLl6H9ZkS0fkY79qOf5698NwmA Date: Mon, 5 Jun 2023 13:24:07 +0000 Message-ID: References: <20230204183355.never.877-kees@kernel.org> <63e1486a.050a0220.7001.ca15@mx.google.com> <202306010954.23972A710A@keescook> In-Reply-To: <202306010954.23972A710A@keescook> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook > Sent: 01 June 2023 17:55 > > On Mon, Feb 06, 2023 at 07:50:42PM +0000, Dr. David Alan Gilbert wrote: > > * Kees Cook (keescook@chromium.org) wrote: > > > On Sat, Feb 04, 2023 at 08:25:45PM +0000, Dr. David Alan Gilbert wrote: ... > > > > > - int ssize; /* source pathname size */ > > > > > + u32 ssize; /* source pathname size */ > > > > > > > > Had you considered using size_t - this is set from a strlen and used by a memcpy > > > > that both talk size_t. > > > > > > I considered that, but I've had other maintainers upset about doubling > > > the variable size. > > > > I bet at least on some platforms it's cheaper as the 64 bit. > > > > > I opted to keep the variable 32-bit here, so the > > > machine code would only change to lose signed-ness. On x86-64 'unsigned int' and 'signed long' are likely to generate the best code. If you use 'signed int' it will to have to be sign extended if used in a 64-bit expression (eg as an array index). (That is probably true of most 64bit arch.) OTOH 'unsigned long' always requires a REX prefix - making the code that bit larger. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)