Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp4948110ybn; Sat, 28 Sep 2019 10:18:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsFiZS5xPCW7hcnMMiUVQ5S2HUQIOxc/Mq9NkrFpEgULv8jyVRUhu7sbg8ox4MlXvsJYR7 X-Received: by 2002:a50:aa96:: with SMTP id q22mr10968278edc.179.1569691121977; Sat, 28 Sep 2019 10:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569691121; cv=none; d=google.com; s=arc-20160816; b=LykmFgn/MR/v8O3PQlAU+Ef/RcdDYYXcv11WLotcDAL4IcEWep5fpP8pfGgwIo4zM7 z3RtC0ruOazFIWLLM6F0a61CCehUoRhM1xh42phRh3u91clX7RcQBpRs83V4IUmrgpVR pk2CwzH9mDSSDmmf5Mjacb1xVRxMLPdiYMly8Fetdk5eVdwZLC0N65Ft7xrf/L334xnG OPLP8csuIGmcTItbDdwDoPSBHuHHsAsxvxYX/LWeSEs3bqhnxM0L2YdXo2Q9Rwd3yjna u0tRcMmErhbkCe/MjMXB4GYMesXNDlVZaSq7bvgckBXtjUUEkdvKcDG2QgIektKOEY69 VF3w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=7u/X3ZsFh4QCXB1aDRlTZlN8LRgGRgqAHEMfX3+HruA=; b=OSAR9dIGDpessjrK3jbby1FqouJDVXVYQomllAgeRQnIMKhuov3Ziw2VqMBUxlDZjZ d38xtlQWHrCV3cPPtieI9rIs8Cpp8SxtvoY/odrngcD8BW2wL08R3Z9icfv6fWbq/DGf PPWIIuWFaJ3vv5vaN1vhYbeDEze4BX0GJIhjjqwX1Gc1ZeBCWH4jnBEEbxta5ZsGhJ3K wPsDPsP8lCLqCpumxJmeCcOa6nGTQJW44bRsecqOX0DpP/7bJERaf4ghFr6cBIYUDbmP XAe6z2ZVINcvqnDFEkRrNSFF+96EybBhob9GOa83XgkExeb+T+ag4LKKOuQDFAvj+SDk pyKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=bTV6Vuwq; 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 f8si4404476ejd.270.2019.09.28.10.18.14; Sat, 28 Sep 2019 10:18:41 -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=@rasmusvillemoes.dk header.s=google header.b=bTV6Vuwq; 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 S1728604AbfI1RSA (ORCPT + 99 others); Sat, 28 Sep 2019 13:18:00 -0400 Received: from mail-ed1-f43.google.com ([209.85.208.43]:39353 "EHLO mail-ed1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726155AbfI1RR7 (ORCPT ); Sat, 28 Sep 2019 13:17:59 -0400 Received: by mail-ed1-f43.google.com with SMTP id a15so4987457edt.6 for ; Sat, 28 Sep 2019 10:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=7u/X3ZsFh4QCXB1aDRlTZlN8LRgGRgqAHEMfX3+HruA=; b=bTV6VuwqQqIF1Ma73g7wCouckooUqmlm9owfdFD4H6eYXsBN0Rb/vG/+TRh+BprT9p OnZakAH4YHab3eGQt1mh894EwjNMSYHtUYMxdNFysuETUzHj5NXIx/3ekY1M4VgMUCCC 6ENAGFIdIeNzZAtB+L33z3vstoYkwuyU6Kkic= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7u/X3ZsFh4QCXB1aDRlTZlN8LRgGRgqAHEMfX3+HruA=; b=s+oOLyNvJQ3Bg7LMP0vALMbkKokoAAm7lYdDTZ/vvEuBaBkotSC9774HoIwnjHpTu4 4Wae+DxUbIBVz01X1vpC5mopYmYpe85AyVTDqqz2IDtIJgUL4duoXTFWyeM4f+3+3G/D L1IPPDHYTJ/oqUYZr4qgCRWXAV8lBd5/AT9T8u1eK0Ski8MsszxPOXi7MZtqXwnU7Tmh Hrbgrfd+1eTI36+v+k2ZJNStJLi4/CdEZLIdktVTNy2GhILNvPq/Y+yKJM3/q4RDegMq N+E3W0fKSRMt+kG5aXLawRKj+oH6wLoZ61ziPhoW38IiAHjIn+FigV/NjSg7oFRjCs8s o3wQ== X-Gm-Message-State: APjAAAUNafknvVd+TLzWTaww3Jl06ubZqsug6W8MR7NUpwc+im/lqsGe DFlapyBPgz9KkaK/JODXDQHRkSVWdhcycw== X-Received: by 2002:a17:906:b84c:: with SMTP id ga12mr12894606ejb.0.1569691077724; Sat, 28 Sep 2019 10:17:57 -0700 (PDT) Received: from [192.168.1.149] (ip-5-186-115-35.cgn.fibianet.dk. [5.186.115.35]) by smtp.gmail.com with ESMTPSA id p4sm1309608edc.38.2019.09.28.10.17.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Sep 2019 10:17:57 -0700 (PDT) Subject: Re: x86/purgatory: undefined symbol __stack_chk_fail To: Andreas Smas , linux-kernel@vger.kernel.org References: From: Rasmus Villemoes Message-ID: Date: Sat, 28 Sep 2019 19:17:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/2019 17.50, Andreas Smas wrote: > Hi, > > For me, kernels built including this commit > b059f801a937 (x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS) > > results in kexec() failing to load the kernel: > > kexec: Undefined symbol: __stack_chk_fail > kexec-bzImage64: Loading purgatory failed > > Can be seen: > > $ readelf -a arch/x86/purgatory/purgatory.ro | grep UND > 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND > 51: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND __stack_chk_fail > > Using: gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) Ubuntu's gcc has -fstack-protector enabled by default, so this happens if one doesn't pass -fno-stack-protector (which I guess is implied by -ffreestanding) explicitly. > Adding -ffreestanding or -fno-stack-protector to ccflags-y in > arch/x86/purgatory/Makefile > fixes the problem. Not sure which would be preferred. Probably -fno-stack-protector, guarded by CONFIG_CC_HAS_STACKPROTECTOR_NONE (because not all gccs understand -fno-stack-protector), so ifdef CONFIG_CC_HAS_STACKPROTECTOR_NONE ccflags-y += -fno-stack-protector endif Rasmus