Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1505997ybm; Sat, 30 May 2020 11:01:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjqzDc9P5D4BJnRWAhqgKw6/L2Jhb9xW9gz6+HtTaj5+YGUh3/1sShqB9KEEYaaZGLRZmB X-Received: by 2002:a17:906:7e56:: with SMTP id z22mr12386911ejr.60.1590861679527; Sat, 30 May 2020 11:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590861679; cv=none; d=google.com; s=arc-20160816; b=bC1YK0NqAfFAa8YIu8oaIlkEIVqRJYJr4Nh6iwkD0wFHqMf+kVC2fvIynDsMSTC65H NhPZRyNah2oI5dRewOMfE32OTd5QXMwUNsEzT8d5oOfah0BvIFoL6gqYzCKScSFA3btb jXoe/k9jz2v0x2kdCb9Ej8+ABlRixDzKjEU8VKxtm9Azuks846sUIRWPCR61fThs3H+m MQRBrun33dB/Pm7PcpZeQkM7232C720VY49x2m2CrmVVP4nmiIznTJ+7grJ5d/tibuTd DWmLitwpVxN15v4bHKv2OMr4r5ofP8ougOwSHeHjDEKChyrA3nyb0oZy2Vwb0EpFb2Su wp4Q== 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; bh=I4Sl+k52E/CqXyjyic29wBCN4bpKoi5wMYDvduKAFNw=; b=T7D/m3DXIMH20y5UfFn75Y9YYr38yczW3WUMGS2BPXc6Fvg4/t9D795CU+kemguviA CtxSUo3l5U5RQbyk84PecpSANtwrdm+6iH6Ew8hd7vnAPzGE2oBc+RG38adbc8sohHRf /6GJ7wIlHDaPMrbkc3Cn5TPFeWgUbZbsDa2fTwGFKTYT7rmCPh6/KWTVK8kjLYdJATZT pG3cO3RaARl/b+BoL6VezpuBzw35vL+Ts08TE09071j0BhJZ5FNU7Stet5byot8OXFfo jBazobY2CrG5M4SsiWxMd4bHVIwCtW+fQUhiZl2zJUMNYa6dg00gesfz/RNuj+SfJalc ZwUQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si7817648ejb.268.2020.05.30.11.00.46; Sat, 30 May 2020 11:01:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729264AbgE3R7N (ORCPT + 99 others); Sat, 30 May 2020 13:59:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729006AbgE3R7N (ORCPT ); Sat, 30 May 2020 13:59:13 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D818C03E969; Sat, 30 May 2020 10:59:13 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jf5lD-000X31-I7; Sat, 30 May 2020 17:59:07 +0000 Date: Sat, 30 May 2020 18:59:07 +0100 From: Al Viro To: Eric Biggers 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: <20200530175907.GP23230@ZenIV.linux.org.uk> References: <20200530060216.221456-1-ebiggers@kernel.org> <20200530171814.GD19604@bombadil.infradead.org> <20200530173547.GA12299@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200530173547.GA12299@sol.localdomain> 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 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...