Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp248560ybg; Sun, 31 May 2020 23:45:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylXCRQZlAW99+y8qnMy8qGoJgGyJmbYxB76Xj4Zr7km53TtoHm9XOkhpFzssdNnIdwsX5+ X-Received: by 2002:aa7:d613:: with SMTP id c19mr7406644edr.321.1590993949690; Sun, 31 May 2020 23:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590993949; cv=none; d=google.com; s=arc-20160816; b=g5L5AQRgBDxuPFAb2al5hNDmULf3IvCJjVOsb4vUPRgvy6by3b00sgvDyq0CSJbC6h Vun+OIQpGFLxR2REeplCLLXLWIFlG1IB56Jxgu+hnOmbf1AA+MZbQ27LP7dZq1kjUzAn zjaFQQrcYj+DiXY0qP5jh1anhsbtEIdoIRtXooTTdrfq++wwAzBzrwM7V1TP3ws0WL6I VKSK0ugmlLFvwakB/UNFgkdGD/JZOFZy3oS3OxDhsThDMpAoHVfahS5A0Imw3AZohlvQ oDmZny9BDNkYVyhtGWHxYhNtET6ifdEE49aoBZT6MzDElsTa32CLpRfR6fojN4DAq4jB BuXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=V3Muhqi4RgIADnlgY17wOFAb5vUds6UnImNsEuAM8kM=; b=TdoOHTFJC+2sJzg8Uy8BqO/ZnhYK7KOqsbuW1tBYII45iZmjo6vRvUeGEgIJTTyeEC zI6N0JDlKSw+jMsk0YHAGqeIke/r82xBHetXPrHC30AYJPheZG4DWHvvGvmZeIUmSdxL xug67bG1MoH2oyzwy3ZMmbM65Mw9zWUIw4t0W2olvGjbD0WwruFQPx+khcBov6th1iT5 DU5e72w3wtXZ34FF8pbWavPoJ7F6u9xun6sy5EVI/lccRqSNEdDKa00lmUNq2ERnVdPM A03fphXUNWDtwGDUilY7MXHSQZQSIHtFffliZ2dxhP1x6o10pBszYJJ9dWgT2hGq2wLm Nqdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FFKfplnD; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si9681566edv.486.2020.05.31.23.45.22; Sun, 31 May 2020 23:45:49 -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=@kernel.org header.s=default header.b=FFKfplnD; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726110AbgFAGpQ (ORCPT + 99 others); Mon, 1 Jun 2020 02:45:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:42742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726076AbgFAGpP (ORCPT ); Mon, 1 Jun 2020 02:45:15 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 72D46206C3; Mon, 1 Jun 2020 06:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590993915; bh=zfYAnnOMkuQXZpA+G/MMKrf7YexWrDaV0EqmTcf7Kaw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FFKfplnDcJ3+nxndceXPwzR2M/jR5K/qxfXBsvkZAJzdDCb74SueskNAYqAs33Vk3 aepTFVKI0QPR+J5wWfSJQF5/tsz99wlBYoa9QC69vAvtmGepUojbFvMA5EA8HXV/l+ 7Z1fKoGzdAEknCR10jfE8XtiTzQs3f6/WMt4QQEE= Date: Sun, 31 May 2020 23:45:14 -0700 From: Eric Biggers To: Al Viro Cc: Matthew Wilcox , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, stable@vger.kernel.org, Daniel Rosenberg , Gabriel Krisman Bertazi Subject: Re: [PATCH] ext4: avoid utf8_strncasecmp() with unstable name Message-ID: <20200601064514.GC11054@sol.localdomain> References: <20200530060216.221456-1-ebiggers@kernel.org> <20200530171814.GD19604@bombadil.infradead.org> <20200530173547.GA12299@sol.localdomain> <20200530175907.GP23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200530175907.GP23230@ZenIV.linux.org.uk> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sat, May 30, 2020 at 06:59:07PM +0100, Al Viro wrote: > On Sat, May 30, 2020 at 10:35:47AM -0700, Eric Biggers wrote: > > On Sat, May 30, 2020 at 10:18:14AM -0700, Matthew Wilcox wrote: > > > On Fri, May 29, 2020 at 11:02:16PM -0700, Eric Biggers wrote: > > > > + if (len <= DNAME_INLINE_LEN - 1) { > > > > + unsigned int i; > > > > + > > > > + for (i = 0; i < len; i++) > > > > + strbuf[i] = READ_ONCE(str[i]); > > > > + strbuf[len] = 0; > > > > > > This READ_ONCE is going to force the compiler to use byte accesses. > > > What's wrong with using a plain memcpy()? > > > > > > > It's undefined behavior when the source can be concurrently modified. > > > > Compilers can assume that it's not, and remove the memcpy() (instead just using > > the source data directly) if they can prove that the destination array is never > > modified again before it goes out of scope. > > > > Do you have any suggestions that don't involve undefined behavior? > > Even memcpy(strbuf, (volatile void *)str, len)? It's been a while since I've > looked at these parts of C99... That doesn't make sense. memcpy() takes a non-volatile pointer, so the pointer just gets implicitly cast back to (void *), and you get a compiler warning. - Eric