Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2875788ima; Mon, 22 Oct 2018 18:19:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV636AK0EYnZw0ljBIadQh4OnguqvwZVO/OOJWvSWtJO4HKRrGhdFDYhHbViww3X9gCec8Kwy X-Received: by 2002:a63:db04:: with SMTP id e4-v6mr44883014pgg.280.1540257544656; Mon, 22 Oct 2018 18:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540257544; cv=none; d=google.com; s=arc-20160816; b=s2MNW+gZdP7xuLHcVfD0Wxtc9vC7CYJ2nX9fAJu/85ETpSOX0jfg7E8QUBbkrf5twd 63XpenbYnMpEcorU0CsbrVwwr4Ne96Eot+8zq/JnnRxPw8E+CfDe74kqO5l+rUedJjUu vDU6SFZ/WOCvDZt72uR0xFbp9bs1Xipor+0QrrL2x10zdnHpD5Yuo6vXTCbwgvsTv13w GxRsLvoTWHCPj8NETklbpCWdS4f8WLdcs1AdXDCSsjQU95n8cQogmLQFIBOQCnXmKdGi NFGJSVqdz0ZCHHy+J000Or3pxjV4eFH8zKtCQEYuR/HpiExQ+zXBZVBVv+GlYa598JXy TKTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=cPkuNDmaeL9Za+IgN+ZDhGI/PaL6EwBHhOaHQepZQgE=; b=UOHwmMlc8GtUY9vDYa9gXic5v0EpJ0Z+fgBiie60cSzNTDW1LwtDnjZr54lG1TwrAa RjSRp2PumJ8z+kXDCxJE+/WBeIH7qBe+14WdVPl9jZ/y2RiZ9Ew7knJHjssCNGxBA91c PNbLoDIgO14yJ+dh2kM7So3y322myjfipDxCnneqkE391P/vXjLOZSF6pLRR3efAb333 2L0mOtXM/Lzl/UfF83pK8oGl+L1gH/3UpXxaqfu7y+iaN2RJRmNa+m0WktzZwvT4ihi6 MJAvcMju8YXyhqIeu893wq29prfUvnM69fFQpZxktHx2J0yh29wBSskF+4G9NM04MXav YPiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WiN596Ut; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si37643094plk.368.2018.10.22.18.18.48; Mon, 22 Oct 2018 18:19:04 -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; dkim=pass header.i=@kernel.org header.s=default header.b=WiN596Ut; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbeJWJ1G (ORCPT + 99 others); Tue, 23 Oct 2018 05:27:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:49262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727187AbeJWJ1G (ORCPT ); Tue, 23 Oct 2018 05:27:06 -0400 Received: from devnote (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A0902064C; Tue, 23 Oct 2018 01:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540256768; bh=4Jjj1C6ElfuQVh9qn5XTKaf9YikveYNTtZsYlo6uVGo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WiN596UtcpV8nLePTj0Nn3BJOh2IMzV2IdQl7wb2IOr6ZSOWjT+3gN2WEk/egr8+R 9yTIdRiUQbhkG790n8gtyo4KUpa45UcqTfT0VG/u/oUYLO1HjhVBfh999uO/DDby8I h0ny7fk2j0ZBy7UhJlZBOE6kOvrTgww78frUeH6g= Date: Tue, 23 Oct 2018 10:06:04 +0900 From: Masami Hiramatsu To: Kees Cook Cc: Russell King , William Cohen , Laura Abbott , linux-kernel@vger.kernel.org, Masami Hiramatsu , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] ARM: kprobes: Fix false positive with FORTIFY_SOURCE Message-Id: <20181023100604.ea7a1a9b5c1c8904aab1b36b@kernel.org> In-Reply-To: <20181022093023.GA8920@beast> References: <20181022093023.GA8920@beast> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Oct 2018 02:30:23 -0700 Kees Cook wrote: > 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 Good catch! This looks good to me. Acked-by: Masami Hiramatsu Thank you, > --- > 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. */ > -- > 2.17.1 > > > -- > Kees Cook > Pixel Security -- Masami Hiramatsu