Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9929656imu; Sun, 30 Dec 2018 08:31:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN5rLrx9DKK9mK37bjSeT771JzPU59qGvvaoclFu+m+eYFcbb/9SPOBXz3/7UUIk4NmmGv2Y X-Received: by 2002:a17:902:ba8b:: with SMTP id k11mr34325087pls.177.1546187465888; Sun, 30 Dec 2018 08:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546187465; cv=none; d=google.com; s=arc-20160816; b=W0LztMVVdgn5Qosk5nUFIcfP/V6CAyYEaZneQ5quHTtlFCxCVx2zbPQdbDBm9578KF RfxP5g9XR5T1WEc9bNwbwmzUmqMg6Q8VGiHXL0HGsS7fLRGAWDnZoXUyFrNI90udvsxB JfKPPcfEgPURbaQ/1vhFJTpd9ql3dV1ujEeFrzaSA42bigm4fFYNTGhqFhJG3TjYEzgF Xd3+J2cZZlP+fzKOZKtzOAn6FmayrwHPSETgiMdSFVPhVWl7QuXoV2rx4NMneoZ0wGBx XowLAjL5yVgLY6pj2thuEwgRuquDwT8UfVQCPgquUjMVDWrBdKi3rpc3Drwk2l5D0lZA xBSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=KGXNkZpesb6jgK6+6SheJIOw04oSf4N4LZT7M7w0o+E=; b=pP8x6dwbMv3I3wTNpulb1ppIAbwFwhoJTRGPnSVFuJEWTWD/ezXHOkexxAztIJ+nNy z+mlWFdCgWD8IAZ1TWfC0IW2acWdiIghH8NjAsq9CpNGICnkLsbI/gIjImMjIHFkVEga Xl5aZOOndaVYMy+hPEQbJ0kq24/uoKa8Yc+VfzsCLFjT74U827+qyN851mjbShtgSVA5 vJt9JUjp/lJCkpkJ0DJifItjo7fI2uub7spTw8XVUalnqDH9GH8NkrZZyYFTaQqHe6cl uKEEyg1gTEK1yN5rEQzUH/b1XvcDhRRjz+fz1q1MX4JEXTlRp/1M/i2/2kckp9/xzAQn m/8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=iki.fi Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p23si5427578plo.7.2018.12.30.08.30.37; Sun, 30 Dec 2018 08:31:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=iki.fi Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726332AbeL3Q3J (ORCPT + 99 others); Sun, 30 Dec 2018 11:29:09 -0500 Received: from emh04.mail.saunalahti.fi ([62.142.5.110]:39382 "EHLO emh04.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725954AbeL3Q3I (ORCPT ); Sun, 30 Dec 2018 11:29:08 -0500 Received: from darkstar.musicnaut.iki.fi (85-76-80-127-nat.elisa-mobile.fi [85.76.80.127]) by emh04.mail.saunalahti.fi (Postfix) with ESMTP id 57BD7300BD; Sun, 30 Dec 2018 18:29:06 +0200 (EET) Date: Sun, 30 Dec 2018 18:29:06 +0200 From: Aaro Koskinen To: "Theodore Y. Ts'o" , Jaegeuk Kim , David Howells Cc: linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org Subject: Bug report: unaligned access with ext4 encryption Message-ID: <20181230162906.GI27785@darkstar.musicnaut.iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, When using ext4 encryption on SPARC, there's plenty of dmesg noise about unaligned access: [ 167.269526] Kernel unaligned access at TPC[5497a0] find_and_lock_process_key+0x80/0x120 [ 167.270152] Kernel unaligned access at TPC[5497a0] find_and_lock_process_key+0x80/0x120 [ 181.087451] log_unaligned: 5 callbacks suppressed [ 181.087511] Kernel unaligned access at TPC[5497a0] find_and_lock_process_key+0x80/0x120 [ 181.092435] Kernel unaligned access at TPC[5497a0] find_and_lock_process_key+0x80/0x120 [ 181.095816] Kernel unaligned access at TPC[5497a0] find_and_lock_process_key+0x80/0x120 And also seen on an ARM machine: $ cat /proc/cpu/alignment User: 0 System: 1028193 (find_and_lock_process_key+0x84/0x10c) Skipped: 0 Half: 0 Word: 1028193 DWord: 0 Multi: 0 User faults: 0 (ignored) Looks like user_key_payload layout is not optimal when data address is used for fscrypt_key... I tried the below change and got rid of the messages. Not sure what the proper fix should be? A. diff --git a/include/keys/user-type.h b/include/keys/user-type.h index e098cbe27db5..6495ffcfe510 100644 --- a/include/keys/user-type.h +++ b/include/keys/user-type.h @@ -31,7 +31,7 @@ struct user_key_payload { struct rcu_head rcu; /* RCU destructor */ unsigned short datalen; /* length of this data */ - char data[0]; /* actual data */ + char data[0] __aligned(4); /* actual data */ }; extern struct key_type key_type_user;