From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752970AbbEAJTl (ORCPT ); Fri, 1 May 2015 05:19:41 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:48565 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145AbbEAJTj (ORCPT ); Fri, 1 May 2015 05:19:39 -0400 Date: Fri, 1 May 2015 11:19:21 +0200 From: Peter Zijlstra To: Palmer Dabbelt Cc: mingo@redhat.com, oleg@redhat.com, akpm@linux-foundation.org, richard@nod.at, paulmck@linux.vnet.ibm.com, bobby.prani@gmail.com, vdavydov@parallels.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] Fix a misaligned load inside ptrace_attach() Message-ID: <20150501091921.GA5029@twins.programming.kicks-ass.net> References: <1430453997-32459-1-git-send-email-palmer@dabbelt.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430453997-32459-1-git-send-email-palmer@dabbelt.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 30, 2015 at 09:19:54PM -0700, Palmer Dabbelt wrote: > I ran across what I believe is a bug in some asm-generic code while > working on the RISC-V Linux port. Essentially the problem is that > wait_on_bit() takes a void *, but then perfroms long-aligned > operation. As far as I can tell, this bug could manifest on any other > architecture that doesn't support misaligned operations and uses this > particular asm-generic implementation. > > The patch set is split into three parts: > > * #1 fixes the bug by making task_struct.jobctl an unsigned long, > which ensures wait_on_bit() always ends up with a long-aligned > argument. > > * #2 changes the prototype of wait_on_bit() and friends to take a > "unsigned long *" instead of a "void *", with the intent of > ensuring these problems don't happen again. > > * #3 is a bit more intrusive: it goes and changes all uses of > task_struct.jobctl from int to long. > > I'm not sure if #3 has gone too far, but I think #1 and #2 are sane. > The cost is making task_struct larger on machines where > sizeof(long)>sizeof(int), but since it's so big already this isn't too > much cost. I thought about making test_bit() perform byte-aligned > accesses to avoid this cost, but since there are very similar looking > atomic functions I thought that would be too odd. Fair enough. Thanks!