Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp378716pxj; Fri, 7 May 2021 10:33:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhhvHhDek0qQTaHjBnvztnq7U8b8VAEd/0sq0RGSBtJ6XEIBYvFL16/nw/JmiGYYEPrYV8 X-Received: by 2002:aa7:cb10:: with SMTP id s16mr12698941edt.313.1620408780950; Fri, 07 May 2021 10:33:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620408780; cv=none; d=google.com; s=arc-20160816; b=F1IhItU+eZ/H2f9ZN2bYpte5ebFCwITwfCYMSaap6rxj1tKzL2zjoi3BtNpz5ZT/RC PaOERpm+eDNR7CBm+Dgn0VN/vpxz3R2qQxLwns4rNxIgm8+pIsDEigITllhAiLcxcnJT GzRAES97nwYn9gDTqBWp4hYHgqSiyftZug5aLAc2SLaUjkIOW+hVPdRxJsQF2wgCfb5D HdR4CCcTMwdfQOORFetlPmyC+JhzamwhFP5YR7+rJPyibZxQDeJN1JRIE0tsYKytPbwM dCc8m9LqQt9MuIcNy/ARxXr3f2rm5/FDOFNoY8BkwOYzwbYZuyh9tCGFNGksqL5nAYfu V9qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=1WJinTcd5PQrGxAnjm55cTVNnQEjZjXh34NLVkNxseE=; b=Umd9wWCRlIRf0j7+i2Y8murAbg7ZmOfCTEyIEsFk8UtqpklweIgrUzjLmGM9eg4ApS R94JdGdlANRQ9Yxka9HldCcI3RLGWRt72R9rACXgMzQJbPTn++J/9icOf+f7CgqxlzTT NGmj4izUOaVu5VHu0lyWY+2AozH5H21kEipP5hEx5R8F8XERRkfX4Kd+hFtcBNS8Kkxr f6TokHmkx1/r6K77LIy+MrILQxQtHXkdjXen4+/abo12vWAUfvSfsjPSZSWutGJkqJUM Y+ht+3U+SKRvqgBlW9o+LIM6aZfbCmcLr6T2pHxSuNofisSoUOThttaW+z+1byMwv/Rh 5tZg== 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 gx23si2016527ejb.149.2021.05.07.10.32.35; Fri, 07 May 2021 10:33:00 -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 S231745AbhEGP5b (ORCPT + 99 others); Fri, 7 May 2021 11:57:31 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:47803 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231130AbhEGP53 (ORCPT ); Fri, 7 May 2021 11:57:29 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 147FuMnA007370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 7 May 2021 11:56:23 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 342B215C39BD; Fri, 7 May 2021 11:56:22 -0400 (EDT) Date: Fri, 7 May 2021 11:56:22 -0400 From: "Theodore Ts'o" To: Eric Biggers Cc: harshad shirwadkar , Andreas Dilger , Ext4 Developers List , Harshad Shirwadkar Subject: Re: [PATCH] e2fsck: fix portability problems caused by unaligned accesses Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, May 06, 2021 at 11:45:09PM -0700, Eric Biggers wrote: > Just to be clear (looking at the latest patches on the list which are copying > whole structs), by "the memcpy() approach does get optimized properly", I meant > that it gets optimized properly in implementations of get_unaligned_le16(), > get_unaligned_le32(), put_unaligned_le32(), etc., where a single word (or less > than a word) is loaded or stored. I don't know how reliably the compilers will > optimize out the copy if you memcpy() a whole struct instead of a single word. > > Even if they don't optimize it out, I don't expect that it would be a > performance problem in this context, so it's probably still fine to solve the > problem. But I just wanted to clarify what I meant here. For the most recent patch that sent out, we really needed to copy out the whole structure since we're then passing it to ext2fs library functions. I agree that it's not likely going to be a performance problem, and at this point, I'm more concerned about code clarity and correctness. Especially since apparently the problems which Harshad's change and my most recent commit addressed were not picked up by UBSAN (either using gcc or clang), --- and IMHO they really should have. So we can't count on UBSAN to find all possible alignment problems. Lesson learned, before I do future releases, I should do a build and "make check" on a armhf chroot running on a arm-64 machine, as well as on a sparc64 machine, since these seem to be the most sensitive to alignment issues. And if I miss anything, fortunately Debian's autobuilders on a large cross-section of architectures will catch them since we run the regression test suite as part of the package build. - Ted P.S. Harshad, could you prepare patches to kernel files in ext4 and jbd2 to make similar alignment portability fixes? Thanks!!