Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1977738rwl; Sun, 26 Mar 2023 13:05:02 -0700 (PDT) X-Google-Smtp-Source: AKy350bvxUzUAzqzJ6dsXUPDBBRdquQNn9uPr9N12gVrhGskCWwxMLjGIWJPKVJDjrjvvt0Wa9wE X-Received: by 2002:a17:90b:1b46:b0:237:5834:294b with SMTP id nv6-20020a17090b1b4600b002375834294bmr9823233pjb.41.1679861102221; Sun, 26 Mar 2023 13:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679861102; cv=none; d=google.com; s=arc-20160816; b=tk/pGN4TolG7Ud+ZTsEXnAh2+f1UHzja2mRm0n5rfTTo+cHSr9Qe82tN8ONN/kr6qn H3IuMao6DAOWA8ibj1GXEAsOzO774b3Ql1YzuGK7lgC8Zo+opzlZgIT0lCIenv1/vh44 TgXno9hrBmB3V2muO7MSOPoUiF4ijcwz0XNHlcSBys+j2340taBlcBSpZv/QwUSmLV6R vPHgkzaims/ioGCm0Q9QwlwpjicesPoR//T3UZuojVE7wz0nHiZRzfdWvb/XvlkSwI5x Euz94cVrIiPUXDFU+aBxVXlhcxXm1ZdgJG6bzE7xQhM1WU+S/j3o1ql361+xD9SlZ0A9 oUMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4UKQ6k6yj5hWcg4z/RhipNHInZBtyGBT7gTdGwQ6ryc=; b=LBo1PVKvfB15Genw6GmOKEHEZZjUpIQ9mfIJpz2hdfVSKsw0MyjBQT+ih8Il3vOyGk XjTsqIcy5vqe9iZRIGMef35G5A6LPxqiwezLizxgmgaWPd/57nAJVuzxO8A2jHruJTJu qoF3/ADPrDimE6oh98cAsU7p1NnlUdJ79pkUFcf7PdCaTR7LqLKn4l2rRq3O1RC9numT ksK+orfRnwWFiNt79TMgPCiAdoaKNQeWKNvWdFsg4wchzYEcwshqwtFfPhcjguCXxphw hCB/JpI2dQZHu2D2t/mTsOoyWh42YwolDIWFmW3pA8BCYRnBVbBrPkJqYS+ez+T7+AaI 6dfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qFOYTJgz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a17090ac09300b00225c475b3d2si4782101pjs.55.2023.03.26.13.04.51; Sun, 26 Mar 2023 13:05:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qFOYTJgz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbjCZTio (ORCPT + 99 others); Sun, 26 Mar 2023 15:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjCZTin (ORCPT ); Sun, 26 Mar 2023 15:38:43 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C65474696 for ; Sun, 26 Mar 2023 12:38:42 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id y4so27641891edo.2 for ; Sun, 26 Mar 2023 12:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679859521; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=4UKQ6k6yj5hWcg4z/RhipNHInZBtyGBT7gTdGwQ6ryc=; b=qFOYTJgz6vzNJl4fZSOb8yy1eAHwk/MjKRtNfdAAUtFklK1dM9T8pjH1XOQq9yzPAF FGHsfz2B/kCybtxOHsSAeJRkQbuPOmyeNv8gLcF2KsFmwfrvM20mIGqn28pgl9TxZs+q eNLjyLqKY3+yD/pjYKemHsXVuHSJGOnn4qiDC67ig2bUtrldYKH8Qd/2VDrPCtdFKtWc arY6QY2NnSEhM4kyzn1cmML8CDaQ6XciYrdGKUJlY9AEzZQThhtojbCBadPp0QJImUCy Pp2fdjumdFRXqwJJujk7JgW/IFmT3QJu94CVSN8uUBGRuG2P2+14c5F//lnPbsFVYvKE RbxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679859521; h=in-reply-to:content-transfer-encoding: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=4UKQ6k6yj5hWcg4z/RhipNHInZBtyGBT7gTdGwQ6ryc=; b=bnqV5oXnLvJkA1SiiMW+lpNPBTPXokQMO3PjhT1P7f4vjY00ryBpFJeAK/WCqDUWI9 BSjkVe7fPqWR2dllpNBZUSikYzP5+RcZRjyWh7Hz38X+kOq130QMpGsNa6GtgiMgFRd+ hozgMcvB2MW/bqRj+yo8gekWKsqcn97ViPtx9TUDXnXOH11TT/t9bZXILG5OsVmAH2az P0shq+qmZTQsYusaCQvFwxVlJvkOGPSQlLfZj4Iq0hRNcMjZgqzKpniOLBW62Ztqpuap he8AXvyq+qthEn459r9qyYahtwMCdCep1WXnqs40YpSUbOH6XaSQ6YG/t9WRrrfgZJjr rFPg== X-Gm-Message-State: AAQBX9cWGyRq/Cx2vnldmxDgxsVC5I8K13cPdXN2HLCtcotLMzDNW9gi CayAqqx4ucHQeGfksdbM86BFFP8pJg== X-Received: by 2002:a17:906:fe45:b0:944:5e49:a9aa with SMTP id wz5-20020a170906fe4500b009445e49a9aamr2037074ejb.21.1679859521246; Sun, 26 Mar 2023 12:38:41 -0700 (PDT) Received: from p183 ([46.53.253.224]) by smtp.gmail.com with ESMTPSA id g13-20020a170906198d00b008c16025b318sm13231282ejd.155.2023.03.26.12.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 12:38:40 -0700 (PDT) Date: Sun, 26 Mar 2023 22:38:39 +0300 From: Alexey Dobriyan To: Willy Tarreau Cc: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , "Paul E. McKenney" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/8] tools/nolibc: tests: add test for -fstack-protector Message-ID: References: <89a960c7-0c9b-43ab-9fc8-a68405f7ed6a@p183> <8e156377-e7d9-48ec-a7ee-292aba002201@t-8ch.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 26, 2023 at 08:45:04PM +0200, Willy Tarreau wrote: > On Sun, Mar 26, 2023 at 01:42:35PM -0500, Thomas Weißschuh wrote: > > > > Mar 26, 2023 13:30:21 Alexey Dobriyan : > > > > > Willy Tarreau wrote: > > >> #if defined(__clang__) > > >> __attribute__((optnone)) > > >> #elif defined(__GNUC__) > > >> __attribute__((optimize("O0"))) > > >> #endif > > >> static int smash_stack(void) > > >> { > > >>     char buf[100]; > > >> > > >>     for (size_t i = 0; i < 200; i++) > > >>         buf[i] = 'P'; > > >> > > >>     return 1; > > >> } > > > > > > If you want to corrupt the stack, corrupt the stack! > > > > I do! > > > > > asm( > > > ".globl f\n" > > > "f:\n" > > > "movq $0, (%rsp)\n" > > > "ret\n" > > > ".type f,@function\n" > > > ".size f,.-f" > > > ); > > > > No problems with optimisation levels. > > > > Wouldn't this be architecture-specific? > > Yes it would. Which is OK. Corrupting return address is very arch-specific. > I'm not seeing any issue with your approach instead, let's > keep it as-is for now (also it does what the stack protector is supposed > to catch anyway). There are no guarantess about stack layout and dead writes. The test doesn't corrupt stack reliably, just 99.99% reliably.