Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1583787ybm; Sat, 30 May 2020 13:42:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSQA1N2yzFJvkcyE8mIjBXfkvLzK8xrBPXRfhqNdOyRdP8Sx4FD9CnkR4CD1Q0tfeCP6YC X-Received: by 2002:aa7:c492:: with SMTP id m18mr14231742edq.249.1590871353956; Sat, 30 May 2020 13:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590871353; cv=none; d=google.com; s=arc-20160816; b=VkCl8UVcxmoKnQyHqz7EuHxhHFhfF8+8tkLcFQv1L31sqMOXSWlSzltaCg964U/3dj wDYgL72Ucv2ibPegTUFhA1XqDIN2Tq00DNobc8MKCxz2mZ2crUoVmd5jbr+PwU1fLtj9 rIiTHcDO0LyD3Z18b5kD+ZoHB28ndZVC6kHXBJawm5WA/09FxELc+G0QnCnIrs9lAibg Q124gMmIvhzIhkMsjQbi+7WHbFkXOJNxPYslI25Iiy2n5cYxte2a+aR7w5RKRZCA6TmP vmuw/6WhBjrGymzn79lTtG4O8pUWzg5Z1TnKtV6X5M5VdMQouz/GmnY1i1TweAeUJ+fp bqzg== 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=4OdrZK2pGyMVHZP9dBAVdzAWc40dh9XQscP29VyVrvM=; b=EWFUJrgNnbgf8P8gAFI5Mc8SRmfp7cQRRG196x7R4Fx+oHu/ZBSTkzbB+rKabcnsWm UuzHygYcY0BE8y8XXmLOXa1ih2wwm18FRGUiWwRF4/Y9Iz5ElcDjOqg4F39gRNxPGz3e PNAo2Y9bHa8ZKgYsL3wxN0n9gTOpi4e60cnXcb24Y1f53VZ72vP4VqbWn2j4WZGjPQOJ VSNlET66Tid/e3qFbLUgap6+9RUxbFq/rQcUdSudHV3qDau32IsJmrnTGjtZjkeAoT7l t9KGWL4sLC4fhsgDmWU1KEwQytIbcUGNM7+EkgbaWSh0VEabZJ+RUKY1GedMmIShe/br OM6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=HZvQiU2Y; 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 nx24si956662ejb.615.2020.05.30.13.42.02; Sat, 30 May 2020 13:42:33 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=HZvQiU2Y; 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 S1729290AbgE3Ulh (ORCPT + 99 others); Sat, 30 May 2020 16:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbgE3Ulh (ORCPT ); Sat, 30 May 2020 16:41:37 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DF5BC03E969; Sat, 30 May 2020 13:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=4OdrZK2pGyMVHZP9dBAVdzAWc40dh9XQscP29VyVrvM=; b=HZvQiU2YlUtBkyi6j0X0sBvcK6 YZbb6RElwJlDvQSoI8EnGgMdqBHoihEOfco2ouCjUP4Lrt9K1yHxN8OR5Caaio7SnY2tGtjpu2vng jr1IQnGoevyNcal8I/kgEqEGTu3l+Zwlh5LVZwcZgiHGb4WD6ut/ABzyv8M2MhE68B0QNvidpnC3Q 2Lj81yDjMRBVamW438WZSQXqIyI6NJY97hDAeLt7m7VQQfHf4EELlTmQSzzKspRVXWPOK0cCOwljZ sJ9Nep2Dn0XzCi79koJwJFZzSkEGkTSq4HO0sQ6syXZ7aNRGYBeUxnVBXkgbEbKIIudGg/NB/2i+7 XqHaEaWg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jf8IO-0000XW-Qx; Sat, 30 May 2020 20:41:32 +0000 Date: Sat, 30 May 2020 13:41:32 -0700 From: Matthew Wilcox To: Eric Biggers Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, stable@vger.kernel.org, Al Viro , Daniel Rosenberg , Gabriel Krisman Bertazi Subject: Re: [PATCH] ext4: avoid utf8_strncasecmp() with unstable name Message-ID: <20200530204132.GE19604@bombadil.infradead.org> 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? void *memcpy_unsafe(void *dst, volatile void *src, __kernel_size_t); It can just call memcpy() of course, but the compiler can't reason about this function because it's not a stdlib function.