From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 29 14:10:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D970BB09 for ; Wed, 29 Jan 2014 14:10:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9B7131CEE for ; Wed, 29 Jan 2014 14:10:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id s0TEA0Dx065130 for ; Wed, 29 Jan 2014 14:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id s0TEA06Q065129; Wed, 29 Jan 2014 14:10:00 GMT (envelope-from gnats) Resent-Date: Wed, 29 Jan 2014 14:10:00 GMT Resent-Message-Id: <201401291410.s0TEA06Q065129@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Svatopluk Kraus Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 11BE28FC for ; Wed, 29 Jan 2014 14:03:26 +0000 (UTC) Received: from oldred.freebsd.org (oldred.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id F1BFB1C91 for ; Wed, 29 Jan 2014 14:03:25 +0000 (UTC) Received: from oldred.freebsd.org ([127.0.1.6]) by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id s0TE3PbX032057 for ; Wed, 29 Jan 2014 14:03:25 GMT (envelope-from nobody@oldred.freebsd.org) Received: (from nobody@localhost) by oldred.freebsd.org (8.14.5/8.14.5/Submit) id s0TE3PVi032056; Wed, 29 Jan 2014 14:03:25 GMT (envelope-from nobody) Message-Id: <201401291403.s0TE3PVi032056@oldred.freebsd.org> Date: Wed, 29 Jan 2014 14:03:25 GMT From: Svatopluk Kraus To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/186236: sigcode not synced on executable stack on icache not coherent archs X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jan 2014 14:10:00 -0000 >Number: 186236 >Category: kern >Synopsis: sigcode not synced on executable stack on icache not coherent archs >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jan 29 14:10:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Svatopluk Kraus >Release: current >Organization: >Environment: >Description: When sigcode (signal trampoline) is copied to user stack during exec, no icache syncing is called. This is problem on architectures where icache is not coherent. >How-To-Repeat: I have noticed the problem after fork(), when parent process was immediately sending signal to child process. As a cache problem, the problem displayed itself rarely. >Fix: I'm attaching simple patch. Another approche is to map user stack without exec privilege, copy sigcode, and then remap the stack with exec privilege. Patch attached with submission follows: Index: sys/kern/kern_exec.c =================================================================== --- sys/kern/kern_exec.c (revision 261262) +++ sys/kern/kern_exec.c (working copy) @@ -1264,9 +1264,12 @@ /* * install sigcode */ - if (szsigcode != 0) + if (szsigcode != 0) { copyout(p->p_sysent->sv_sigcode, ((caddr_t)arginfo - szsigcode), szsigcode); + vm_sync_icache(&(p->p_vmspace->vm_map), ((vm_offset_t)arginfo - + szsigcode), szsigcode); + } /* * Copy the image path for the rtld. >Release-Note: >Audit-Trail: >Unformatted: