From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751837AbbEAE0W (ORCPT ); Fri, 1 May 2015 00:26:22 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:36605 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750904AbbEAE0V (ORCPT ); Fri, 1 May 2015 00:26:21 -0400 From: Palmer Dabbelt To: mingo@redhat.com To: peterz@infradead.org To: oleg@redhat.com To: akpm@linux-foundation.org To: richard@nod.at To: paulmck@linux.vnet.ibm.com To: bobby.prani@gmail.com To: vdavydov@parallels.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH 0/3] Fix a misaligned load inside ptrace_attach() Date: Thu, 30 Apr 2015 21:19:54 -0700 Message-Id: <1430453997-32459-1-git-send-email-palmer@dabbelt.com> X-Mailer: git-send-email 2.0.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.