From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030401AbbD1O2L (ORCPT ); Tue, 28 Apr 2015 10:28:11 -0400 Received: from mga11.intel.com ([192.55.52.93]:6859 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030271AbbD1O2I (ORCPT ); Tue, 28 Apr 2015 10:28:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,664,1422950400"; d="scan'208";a="720480218" Message-ID: <553F98F2.3030006@intel.com> Date: Tue, 28 Apr 2015 07:28:02 -0700 From: Dave Hansen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Fenghua Yu , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , Asit K Mallick , Glenn Williamson CC: linux-kernel , x86 , Fengguang Wu Subject: Re: [PATCH Bugfix v2 2/4] x86/xsaves: Define and use user_xstate_size for xstate size in signal context References: <1429678319-61356-1-git-send-email-fenghua.yu@intel.com> <1429678319-61356-3-git-send-email-fenghua.yu@intel.com> In-Reply-To: <1429678319-61356-3-git-send-email-fenghua.yu@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/21/2015 09:51 PM, Fenghua Yu wrote: > +static int copy_to_user_xstate(void __user *buf_fx, struct xsave_struct *xsave) > +{ ... > + if (__copy_to_user(buf_fx + user_offset, > + xsave + kernel_offset, size)) > + return -1; > + } > + } > + 0day found this, but I'm replying to the original thread. > [ 13.595511] BUG: KASan: out of bounds access in save_xstate_sig+0x1bf/0x470 at addr ffff880000184208 > [ 13.596280] Read of size 8 by task init/1 copy_to_user_xstate() gets inlined in to save_xstate_sig(). The read probably means that this was an access to 'xsave' since we are reading a kernel structure out to userspace. 'xsave' is a 'struct xsave_struct *' and yet it's being incremented like 'buf_fx' which is a 'void *'.