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=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 67CAAC433DF for ; Mon, 1 Jun 2020 06:45:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FD842076B for ; Mon, 1 Jun 2020 06:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590993917; bh=zfYAnnOMkuQXZpA+G/MMKrf7YexWrDaV0EqmTcf7Kaw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=QlezElYegsH3vdpxIzTbaSwtPD1el26KjiRv4fFzvYL/wIWZd9sPFtTTZnfrVZfUB b/+Ej7VaeAQ1c9f9PZctF9PpY0PBq3oi7bN+0Ark2V7jhzxyq9GkZwuTc795xMHl/c dyksgbc9zMwEVJla/8MvxxHXEhTv0mG94PABpIqU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727803AbgFAGpQ (ORCPT ); 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 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=-0.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 8D42DC433E0 for ; Mon, 1 Jun 2020 06:45:24 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5889B2076B; Mon, 1 Jun 2020 06:45:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="d0n3keId"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="HJ6XmzbS"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="FFKfplnD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5889B2076B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jfeCJ-000144-W0; Mon, 01 Jun 2020 06:45:23 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfeCI-00013x-CY for linux-f2fs-devel@lists.sourceforge.net; Mon, 01 Jun 2020 06:45:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=V3Muhqi4RgIADnlgY17wOFAb5vUds6UnImNsEuAM8kM=; b=d0n3keIdWMkMFbew3530DoBLZc 6X/48MrP94VcsM95GuHEBPq8Txmxmya9b3w6jorIKmNoa2Wfd0YVeX/Ve81qo83ywuHXojkT5vjww vwl9+ovby5099I2B1eQECvhp3SbbT3yzkeAvaJLfn71BbmaslRvYclXYkhXAEIHC2Vu0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=V3Muhqi4RgIADnlgY17wOFAb5vUds6UnImNsEuAM8kM=; b=HJ6XmzbSR9A/3G/YCWqrriRr+P ama6h4jgOFaEJSE2aYrz5g7rrXqoIa0EeLP/Jopy/auxy7CcHCnR9JNoHTJLEMY3EBbAjWxL0Iqfn K/cj0KyTPUdX6iDPpan2EkCbvOcNy98gm8az8qWKL97lepPZcIXYYz0Aq9M+DNi8sQSU=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jfeCH-0038ks-96 for linux-f2fs-devel@lists.sourceforge.net; Mon, 01 Jun 2020 06:45:22 +0000 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 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-Disposition: inline In-Reply-To: <20200530175907.GP23230@ZenIV.linux.org.uk> X-Headers-End: 1jfeCH-0038ks-96 Subject: Re: [f2fs-dev] [PATCH] ext4: avoid utf8_strncasecmp() with unstable name X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Rosenberg , stable@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel