From patchwork Mon Oct 22 09:30:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10651871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B35B113A9 for ; Mon, 22 Oct 2018 09:30:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2DC0288AD for ; Mon, 22 Oct 2018 09:30:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97597288B2; Mon, 22 Oct 2018 09:30:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25855288AD for ; Mon, 22 Oct 2018 09:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=HYWtb5X8R1+aGyGsFFeMmHcnublswew2W5ElncT7Qu8=; b=dP6i5kByF5lz7o yytZ27jxMsDd+thmPrfym5DXNNw/CJEIQ1K62YqYHRd+r/uzW1VxbPBPSFNRdRXz0u1rlAEHLUQA5 H7O57cUQ9qVsijgror8I5/LKIBPCLBj1k+SzslPxgMHg/e/rJFRnIYHVX/e32Zlyikyl/1urkeo7T yZbpdHT96qLHx8rL5TD9qvJ8x/Wdsn8dmnjmbHoO2w0HHi0sbeKVlstphMOON4cNgnJNankTb36ac oYZ/5XmVXKiNE/U5K4IqTodf0YOewHTIENCpWSaRIC7n3aOhGChP2CNmhsbouJiwTjn2rSePyTFWX B5s6uU7aZrjfB4/ZrrUg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gEWXp-0006Fa-JP; Mon, 22 Oct 2018 09:30:41 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gEWXl-0006Es-VW for linux-arm-kernel@lists.infradead.org; Mon, 22 Oct 2018 09:30:39 +0000 Received: by mail-pg1-x544.google.com with SMTP id s3-v6so5521933pga.12 for ; Mon, 22 Oct 2018 02:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=To+WyIIzyyRIFrMQmM5CMsM2mkFborbgY0/EuHOt5aU=; b=IFYBHeJ/h367/QmpioEtjjzUJ23OEJNDNNuqdnvAXrw0jACHqfFtIy1BlJRx7Tuo4K W/uv5g9BjVM7j1E3MJFOogKNnVEuECKluegWXEoec/TzdJp4oBcGFenrnqkh2zpV3x3l uECDzYiELVS/sbueHqEKKiup86p988hhpSOzk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=To+WyIIzyyRIFrMQmM5CMsM2mkFborbgY0/EuHOt5aU=; b=WU6DDbJkHWgMe0TJwR76DbmX1caIS7PzbEnYuJcvTURDC2LFUhDjNkaA+KRqWRBfQh Mv8SY23jCFjdPSn778uRd9jj8Rv+7GKwOFpiRasNRMMJExbgs1JpjpZK3HU/uIx872mX YwqNrCT5ElaNYdGesobWI5XgqxEsrVSb8DCBECsuuoFVSTjhLTE6EH3w0FjjpD8YzPDM vp4L/iatM9+1eJbkEVlGxt9H+5MgpxtoJvP24VUMIOcUYSCTirEHTCEmeN/fJ8zWkR2P dY0paD0Mb+27afr9QBbkFcVpNwKalgOL+Z7r8k8kNREiD4i4dFu89YXIsYOOMZGoVBVt pozQ== X-Gm-Message-State: ABuFfoiniiBPEcNO5IIEDvM5soAT8Fh2h5NJznn2WyWqU3W4FGD9aZMX /5g5sXq+NxJk0Ttq+1oe39I3qw== X-Google-Smtp-Source: ACcGV60GG6xF+kQyVodSmag2kEUxmqKsh5ysnPWIEG6sDg8B/1CNOWtzfaAhsdYkQxHmP8qsvNdlVg== X-Received: by 2002:a63:9409:: with SMTP id m9-v6mr40841018pge.93.1540200626907; Mon, 22 Oct 2018 02:30:26 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id l129-v6sm42968121pfc.155.2018.10.22.02.30.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Oct 2018 02:30:25 -0700 (PDT) Date: Mon, 22 Oct 2018 02:30:23 -0700 From: Kees Cook To: Russell King Subject: [PATCH] ARM: kprobes: Fix false positive with FORTIFY_SOURCE Message-ID: <20181022093023.GA8920@beast> MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181022_023038_041069_3BD70ACA X-CRM114-Status: GOOD ( 13.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: William Cohen , Laura Abbott , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Masami Hiramatsu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The arm compiler internally interprets an inline assembly label as an unsigned long value, not a pointer. As a result, under CONFIG_FORTIFY_SOURCE, the size of the array pointed to by an address of a label is 4 bytes, which was tripping the runtime checks. Instead, we can just cast the label (as done with the size calculations earlier) to avoid the problem. Reported-by: William Cohen Fixes: 6974f0c4555e ("include/linux/string.h: add the option of fortified string.h functions") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook Acked-by: Laura Abbott Acked-by: Masami Hiramatsu Acked-by: Masami Hiramatsu --- arch/arm/probes/kprobes/opt-arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/probes/kprobes/opt-arm.c b/arch/arm/probes/kprobes/opt-arm.c index b2aa9b32bff2..2c118a6ab358 100644 --- a/arch/arm/probes/kprobes/opt-arm.c +++ b/arch/arm/probes/kprobes/opt-arm.c @@ -247,7 +247,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *or } /* Copy arch-dep-instance from template. */ - memcpy(code, &optprobe_template_entry, + memcpy(code, (unsigned char *)optprobe_template_entry, TMPL_END_IDX * sizeof(kprobe_opcode_t)); /* Adjust buffer according to instruction. */