Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5980031ybf; Thu, 5 Mar 2020 10:40:27 -0800 (PST) X-Google-Smtp-Source: ADFU+vvPOlbasl2PEN6L4VnF/hTf2HW2/fsQf8P8xdR4z6akF4mAIpo/D4W4YYf29Is6z2919w6A X-Received: by 2002:aca:52c7:: with SMTP id g190mr317354oib.144.1583433626838; Thu, 05 Mar 2020 10:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583433626; cv=none; d=google.com; s=arc-20160816; b=wAHKdOztyyv4oh2AuhJjhxmMGt9bzg4vkvZv9WMS/F7ad0zzrmq/RRQGUoPEmkkFY2 EUVfHnIVghDFwH9pAYOt1mXF7C5DlJG0UhpqxCBXvee+Z1VBx36pxCittXz4BH4+Vt3r N7wjYTHfTK+s/6dL1LCsjEshBY1Owzk5k9T27Ra2x80I5v0G07w5/BNXSKvMu7pXRnMp B/DHSEC9h5LMECiqRvUePYgkR+CspdQOSGcQrVo1Teu8p+fBtXuGdOUYCjgqi9UKFHDM 7t/3fmQNp3XzldYhhXDdSedUnBxQEL5t9q+jhe731X6U0idVndkFd85zOPM2gsQJq8Kc 8mQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=bSM9inO0XUL/aHKZ8mCFI+boS4Y8DDilOWOqau7zZY8=; b=rKq4cic6MgM0Wk3zPgwmbQtLA5pk3sw08hvZ1vwk/3vmpzw1yJxBmyFN1f9+B9s+ty F5tIszgO7SOUMttlB3MoT9BLG06YQeNEnN0AdhLLdrvS0e59Ip/JNCzaWZ+Ofgu+bfKx dWNuJwbYkhfSIxMXdTkeV0ossqqT9PLoa7hmFCw1cM7D/BNM1fWHLQSuwdcfbUogL8b9 Qf2t9/k0OnJKYcfBwz6/rNEJRjOc8j67N8a9jw5SLeeysqHUhzHwBvYzSArCNVRKImpd SkpgSumQEMY12/70BQI8MfZp93yoIuiZDbZ18EhrEFauRyX+M8sksyq8Hb1KaBTRICLz a30w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZinfgwHb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u207si3956749oia.176.2020.03.05.10.40.15; Thu, 05 Mar 2020 10:40:26 -0800 (PST) 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=@google.com header.s=20161025 header.b=ZinfgwHb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbgCESjr (ORCPT + 99 others); Thu, 5 Mar 2020 13:39:47 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:49483 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726092AbgCESjr (ORCPT ); Thu, 5 Mar 2020 13:39:47 -0500 Received: by mail-pg1-f201.google.com with SMTP id b10so3715751pgi.16 for ; Thu, 05 Mar 2020 10:39:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=bSM9inO0XUL/aHKZ8mCFI+boS4Y8DDilOWOqau7zZY8=; b=ZinfgwHbZuJEjlZdJ5XfivpxaMQunf4Z2GS/REK7ruL5Ow6SQc1WS12g1Oq5tjGbxy ghayY9XcSjRpnw/KdgHy+mGTaS8fBm/wQrrF7036yv+jHAuw4ondSOGHaWQ9Lb3MXoOZ WHssGk0Qqo4NrvpcwNflQsMcs2sKv4DgWWhTyTKsuDTOGl4/2JwxngqnlAsWzZtIq4Ti sFi4J7wH+8fAGcfs5mSH4rKl/UFXXK17tDmvc79NKlqfp1fGbMkJ6KX3gyXFYKqmjkwV cNWYyjOyPNI44f+7X8zfUgCGruQQG6qu1AnoCFu/BPM2llVJyntNLdf84JoeS5GvLc7m N+FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=bSM9inO0XUL/aHKZ8mCFI+boS4Y8DDilOWOqau7zZY8=; b=l1GI4TdSY+UrkP5vRJzZeEexDW+nJj5hRl25kRY5F52DPUjNXHxpYLTykskbV72lCK tcXCVNG/Waw/i65a+jEOeNlmZ4b/OV3vBCYDhKO6fiHbdHxQH78bZDcsoYagwJ+roHT7 tOpl0Xa1qNVcZx2ZSY7lpR4yvO8nFa4JhTYEo4UxmfufYI4fpzOYQ4DCMGfVAXvmsvYk 559nq1JkNmC3F1MjQCTQCypYDyV43C7uBcWXuToNMemooKPUTDfGkJO+0C66pktZNOqj 0YV0rq+fvUZ5jC6736+7GvoFbYipRZAzP5XdpzbRNBnQQV4HiO98LxDlP3gx9Ocq4+HK 4QHw== X-Gm-Message-State: ANhLgQ02IVbiLivCeqRSPuGK1+u/AONTtW5Wj9UuEOfmXxgPNZGDuHON 6bB3wOWBCz9hhx5fG/ebpf/rO1hJBQMQXA== X-Received: by 2002:a17:90a:33c2:: with SMTP id n60mr9530807pjb.177.1583433586226; Thu, 05 Mar 2020 10:39:46 -0800 (PST) Date: Thu, 5 Mar 2020 10:39:39 -0800 Message-Id: <20200305183939.256241-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [PATCH] um: Fix overlapping ELF segments when statically linked From: David Gow To: Jeff Dike , Richard Weinberger , Anton Ivanov Cc: brendanhiggins@google.com, trishalfonso@google.com, linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, David Gow Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When statically linked, the .text section in UML kernels is not page aligned, causing it to share a page with the executable headers. As .text and the executable headers have different permissions, this causes the kernel to wish to map the same page twice (once as headers with r-- permissions, once as .text with r-x permissions), causing a segfault, and a nasty message printed to the host kernel's dmesg: "Uhuuh, elf segment at 0000000060000000 requested but the memory is mapped already" By aligning the .text to a page boundary (as in the dynamically linked version in dyn.lds.S), there is no such overlap, and the kernel runs correctly. Signed-off-by: David Gow --- I'm not 100% sure what triggered this -- possibly a change to the host kernel on my machine -- as I'm able to reproduce the issue as far back as in 4.4, but it seems to be reproducible easily on my machine with defconfig + CONFIG_STATIC_LINK=y. arch/um/kernel/uml.lds.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S index 9f21443be2c9..3b6dab3d4501 100644 --- a/arch/um/kernel/uml.lds.S +++ b/arch/um/kernel/uml.lds.S @@ -19,10 +19,10 @@ SECTIONS __binary_start = START; . = START + SIZEOF_HEADERS; + . = ALIGN(PAGE_SIZE); _text = .; INIT_TEXT_SECTION(0) - . = ALIGN(PAGE_SIZE); .text : { -- 2.25.0.265.gbab2e86ba0-goog