From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753137AbbJWKdZ (ORCPT ); Fri, 23 Oct 2015 06:33:25 -0400 Received: from a.mx.secunet.com ([195.81.216.161]:49879 "EHLO a.mx.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752865AbbJWKdW (ORCPT ); Fri, 23 Oct 2015 06:33:22 -0400 Date: Fri, 23 Oct 2015 12:33:17 +0200 From: Steffen Klassert To: Sowmini Varadhan CC: , , , Subject: Re: [PATCH v2 net-next] xfrm: Fix unaligned access to stats in copy_to_user_state() Message-ID: <20151023103317.GN7701@secunet.com> References: <20151021154722.GA14667@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20151021154722.GA14667@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [10.182.7.102] X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 21, 2015 at 11:48:25AM -0400, Sowmini Varadhan wrote: > > On sparc, deleting established SAs (e.g., by restarting ipsec) > results in unaligned access messages via xfrm_del_sa -> > km_state_notify -> xfrm_send_state_notify(). > > Even though struct xfrm_usersa_info is aligned on 8-byte boundaries, > netlink attributes are fundamentally only 4 byte aligned, and this > cannot be changed for nla_data() that is passed up to userspace. > As a result, the put_unaligned() macro needs to be used to > set up potentially unaligned fields such as the xfrm_stats in > copy_to_user_state() > > Signed-off-by: Sowmini Varadhan > --- > v2: review comment from thread: cannot use PTR_ALIGN as this would break > userspace assumptions about 4 byte alignment. Use *_unaligned() macros > as needed, instead. This works on intel 32-bit and 64-bit as expected. Patch applied to ipsec-next, thanks!