From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 156ACEE14B9 for ; Wed, 6 Sep 2023 18:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243051AbjIFSGK (ORCPT ); Wed, 6 Sep 2023 14:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237196AbjIFSGJ (ORCPT ); Wed, 6 Sep 2023 14:06:09 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D1210F7 for ; Wed, 6 Sep 2023 11:06:03 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68c0d4cc3a4so116510b3a.1 for ; Wed, 06 Sep 2023 11:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694023563; x=1694628363; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=O40bo/gxfF03whhMFXEqEedi7R6NFirN94zwY0Dca7U=; b=ldH5bOXPn4zFGDFzW5RJ6cSXi53LCn7GKh/nbeYhWXeP7hvXu5WhUNCM0XmyfWo0GQ z2JACE9BK5jYzyURVNCafSdVcfi/iFTDyny2gmSFPEITZTpwSgX0gWjJH0QoGIv7bjyD 72fDzimiSxi5I/4TSKrcfJIUjNAWBW6vO8qTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694023563; x=1694628363; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=O40bo/gxfF03whhMFXEqEedi7R6NFirN94zwY0Dca7U=; b=JEL7hAJOFK7z/RyM5hjQIBLBx7fOJLnGFK7pgfuJg32RsHgl64XQd+UGYbxRIAqYjC 7UNxsN7GM+l68EZQPu9EDcHI/0KUTw2NZRKlcvvzSFquidiAs8ZXoTIDkBWVR/3++hq6 oEhamIQulNySTRLqAbxZtvDj89zZKRc3nS7OEgA73hVnbVEE5j5fnIunJF2GCq3V6K6l g8ds+tMP5atLCGQYxpBZ+YQzY7oxbM90Hk7Ybq21hdxUmFpOPNPqO96ZObRH6fo7H8vY 1eMC7VoGrSy056WPm7sFJzerXjngcck7v5MRz6K9V2DbkmNzM9xRGtjm00jyYnlvJ2tP c9IQ== X-Gm-Message-State: AOJu0YyEseJv0+AmrTk2d1vahVo0ttNO8tQHqeGP11Sbwi6C1CTFnY+3 YyJCLjo6l0MN4gXxE7E8cZts/Q== X-Google-Smtp-Source: AGHT+IFVidGBv05UhqX2YIvVWb0IhPX+FPDQhL5+tVhZ0nsxBP5ZEoBlEwgCMn0DOZzFYA3QvqJ9WQ== X-Received: by 2002:a05:6a00:80c:b0:68a:55ff:3a02 with SMTP id m12-20020a056a00080c00b0068a55ff3a02mr17550041pfk.18.1694023563375; Wed, 06 Sep 2023 11:06:03 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id fm14-20020a056a002f8e00b0068c6889e146sm11398521pfb.98.2023.09.06.11.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 11:06:02 -0700 (PDT) Date: Wed, 6 Sep 2023 11:06:02 -0700 From: Kees Cook To: Song Liu , Fangrui Song Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, x86@kernel.org, clang-built-linux , linux-hardening@vger.kernel.org Subject: Re: [PATCH] x86/vmlinux: Fix linker fill bytes for ld.lld Message-ID: <202309061102.DB794AD295@keescook> References: <20230906175215.2236033-1-song@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230906175215.2236033-1-song@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Wed, Sep 06, 2023 at 10:52:15AM -0700, Song Liu wrote: > With ":text =0xcccc", ld.lld fills unused text area with 0xcccc0000. > Example objdump -D output: > > ffffffff82b04203: 00 00 add %al,(%rax) > ffffffff82b04205: cc int3 > ffffffff82b04206: cc int3 > ffffffff82b04207: 00 00 add %al,(%rax) > ffffffff82b04209: cc int3 > ffffffff82b0420a: cc int3 > > Replace it with ":text =0xcccccccc", so we get the following instead: > > ffffffff82b04203: cc int3 > ffffffff82b04204: cc int3 > ffffffff82b04205: cc int3 > ffffffff82b04206: cc int3 > ffffffff82b04207: cc int3 > ffffffff82b04208: cc int3 > > gcc/ld doesn't seem to have the same issue. The generated code stays the > same for gcc/ld. > > Cc: Kees Cook > Cc: x86@kernel.org > Signed-off-by: Song Liu Ah! Thanks for the catch... I wonder if ld.lld should be fixed too? My understanding was that ":text =...." was defined as being explicitly u16? Reviewed-by: Kees Cook -- Kees Cook