Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2266519imm; Thu, 7 Jun 2018 07:57:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLBEj2ffhX5IEzQ9gDVFn7FhdxsiQeWGVxkRct3SD5oT7iHNDCMJI6rayibvZCC71p4w0RH X-Received: by 2002:a65:654a:: with SMTP id a10-v6mr1854314pgw.107.1528383478407; Thu, 07 Jun 2018 07:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383478; cv=none; d=google.com; s=arc-20160816; b=Ar3oJpzS8TzKJc7bdo7Vy/IQaj5e3VMf6F/QLfXe/a2jemwPxGdIfc+5SHsT+AFEbL hS2zi1wDDOLBFjQ8CslV+4psgJesX2twu5bHQV0jWKL1maEMfxnC7ZAlAqfBeNrr5GFf vSqncQFJzKM+uvv3f4+ysTz56tJJY7C0WNqNTg6zVZBZq90e1BCfLakqhmmTUX5wnl7L CcaHhKSUfmaLuOOjL5MvEMDAStpKkLoysC5LJ6b4tqJZOfo8W8xM8NuyLVBwb6zKPEaO nQIVk/vQKhM4p1an9witHFuAUAgfAzYTMS1PPvecwdxGSF5aAFpD7ocwAsd0UMQSP/xX VDsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=aVoRgDPaPU/hnER7QTDgikcu7zzhQPrNznl49Uz9PCw=; b=F/ifahzt3v4K9P0ogVAA+6I+VPun4CDE3ZOOhOkOXce5IFL/ZYr4Srx/gu/KFWPRyW rZW8sWLoN6SCqILJXXV/lDldfHIl0E+cqjAenT904BlKgk5TFx1lAUjOs/Hk/lJFdzlE GOIHljn2Q7ZID0lvWBLyAh1oewT9IOxb7fOt3P1UDsBkpJZRRFf3JigfXzareAVOKtym 9eVBSThoIERYEKy5NmGjyvlnluFyDhH/WaGc5vjhzvTZTYjJJNBAakTwjfQ39Py9NtPt w9YU//hXThvcmPheioFdOkbQp1CyQIxohOPOcXiGxAasZMSQpGAhKooRAT8SA3aHTwhL O4ag== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64-v6si20588924ply.476.2018.06.07.07.57.44; Thu, 07 Jun 2018 07:57:58 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753756AbeFGO4t (ORCPT + 99 others); Thu, 7 Jun 2018 10:56:49 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41105 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753663AbeFGO4r (ORCPT ); Thu, 7 Jun 2018 10:56:47 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbo-0005Zi-Ud; Thu, 07 Jun 2018 15:09:49 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb2-0002rK-D7; Thu, 07 Jun 2018 15:09:00 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Arnd Bergmann" , "Jonas Bonn" , "Stefan Kristiansson" , "Stafford Horne" , openrisc@lists.librecores.org, "Eric W. Biederman" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 125/410] signal/openrisc: Fix do_unaligned_access to send the proper signal In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: "Eric W. Biederman" commit 500d58300571b6602341b041f97c082a461ef994 upstream. While reviewing the signal sending on openrisc the do_unaligned_access function stood out because it is obviously wrong. A comment about an si_code set above when actually si_code is never set. Leading to a random si_code being sent to userspace in the event of an unaligned access. Looking further SIGBUS BUS_ADRALN is the proper pair of signal and si_code to send for an unaligned access. That is what other architectures do and what is required by posix. Given that do_unaligned_access is broken in a way that no one can be relying on it on openrisc fix the code to just do the right thing. Fixes: 769a8a96229e ("OpenRISC: Traps") Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: Arnd Bergmann Cc: openrisc@lists.librecores.org Acked-by: Stafford Horne Signed-off-by: "Eric W. Biederman" Signed-off-by: Ben Hutchings --- arch/openrisc/kernel/traps.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/arch/openrisc/kernel/traps.c +++ b/arch/openrisc/kernel/traps.c @@ -302,12 +302,12 @@ asmlinkage void do_unaligned_access(stru siginfo_t info; if (user_mode(regs)) { - /* Send a SIGSEGV */ - info.si_signo = SIGSEGV; + /* Send a SIGBUS */ + info.si_signo = SIGBUS; info.si_errno = 0; - /* info.si_code has been set above */ - info.si_addr = (void *)address; - force_sig_info(SIGSEGV, &info, current); + info.si_code = BUS_ADRALN; + info.si_addr = (void __user *)address; + force_sig_info(SIGBUS, &info, current); } else { printk("KERNEL: Unaligned Access 0x%.8lx\n", address); show_registers(regs);