Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp29144pxj; Wed, 16 Jun 2021 19:21:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuHrDyRAmKVKkZFJI9u+Auu82qOGue9bkzk34EnDNWZxPojAR2D53I1rO94FqbUiyYufed X-Received: by 2002:a92:9503:: with SMTP id y3mr1616424ilh.43.1623896506830; Wed, 16 Jun 2021 19:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623896506; cv=none; d=google.com; s=arc-20160816; b=Xn03m05mdDtEcKYkpP7M4OaDVq14zVeeL43PugxtxkPpxig0w5lsMUxtvWOmQ8LeMM ZVzpgix3mkiD/7cDBiAho1x5nsoV04cfMSJgfB9EE/f77vBfAHiHv1BoLAYH5khZCa7t cMczIbB17cTER+ijNe+rlsugAl9QuWYu76TGsXOw5uuRJ/mJ3EQWMLltUa2cZuwlA1Tq 1iGg7AGS3bO7/0q5GFKOi+qn0wELQ5pb+sMNzXNsnUVKGbX5dDKmYeN8QaBV5Ro68vng 32krYnQkMrhSSGF94PexJV11FalDTIA5F37pJDjSd8rGHHjIrSrGuAG9cqjQAH9YMKRA jQGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UHEpO/p4mphV1bVFcaFoH3CcTJgorPlChGXXuQ9ZIXY=; b=pvCpzZP66V1YJ2RQLaR+KNL4aTwKKdzT+4cWTz1oXSGyElXKAUQ4Kj47DpMlN/aRQb fG/25eMKP843JzgGP5uEuk3++UN2Y7yJqwaLJOuLcTHYOfkYI7++shnH0CeCfU4tYIfY i+450JGBHs4s8GpKF3G241fypdZm4Aie1TIYKh6KOwJZSoRdF0Pcv/RdHy9x5IIbWQIP i0gN32HdyMVjItL9rlIRuriOv36P1Z6W8O9RLvte15ylaJVUTqxKVAu2u4HMoyCztu4r YTIpP5eQkuOXzzAih31OwBwU79/cF35BdDygMSEbA5F7pqsYCz47p55x0wF9h7pCyWT6 XiXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="F9u6gy/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si4111556iob.78.2021.06.16.19.21.35; Wed, 16 Jun 2021 19:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="F9u6gy/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233664AbhFPUrZ (ORCPT + 99 others); Wed, 16 Jun 2021 16:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233639AbhFPUrV (ORCPT ); Wed, 16 Jun 2021 16:47:21 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E032C061574 for ; Wed, 16 Jun 2021 13:45:13 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id ho18so5939876ejc.8 for ; Wed, 16 Jun 2021 13:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UHEpO/p4mphV1bVFcaFoH3CcTJgorPlChGXXuQ9ZIXY=; b=F9u6gy/i0U+gAlXpRnOajPU0M92RhboG967hQIeJJOU/4+90HIPvkNWUdvQBVU9Vo9 IhP7wBN3MCi7lwz8foxZo/pVTaE4Wpg0DDxRIzOns2pT3toJbU9hUVoesn9RWS+YJBRt vLodejI8Bk5yzwI3LFoNUijuDi+QyKzza8/R4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UHEpO/p4mphV1bVFcaFoH3CcTJgorPlChGXXuQ9ZIXY=; b=LdeVTHZ0CFtpEXTyh2x2F0FuonkEcYU02hnBrSAVYpuTPg/O2KxjKrcz7jqAhb1d9r coCVVFGmzL6rhJX3g4f+Ohh/Fmm8j1quurE9T79GhpmzRAIuZO6h6os4PZ24YShFpISN GfGX5CIeCNv2i/EI8ZokgVb0KnRieit+yDMglYU/tXQYPoIzLXM17OI9TOPxSQAXg8ts aToR9+Nb1tvPq+3VCqNFU3PawzgDxW2IGw0l4a4Jo7y1fLMKJ1zXy1KS8IBVfeu/slF+ Ni5YM9xzYXaplSAWe84wGK7D01+TOh9ntjLsdrNzXo3TIbVD3cxOuyT/3fLZV4X/GbVC 4y8w== X-Gm-Message-State: AOAM533QFct3ZPXi4QS07QY2qQHB7n+XK0rNc6Ml9p+QgPcHglLAv/Z8 dHOekP+PrnzjuotsquyA/8CL2iSDZP6ab5eSmPM= X-Received: by 2002:a17:906:a18b:: with SMTP id s11mr1478914ejy.8.1623876311870; Wed, 16 Jun 2021 13:45:11 -0700 (PDT) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com. [209.85.221.53]) by smtp.gmail.com with ESMTPSA id q16sm2686299edt.26.2021.06.16.13.45.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Jun 2021 13:45:11 -0700 (PDT) Received: by mail-wr1-f53.google.com with SMTP id v9so4116890wrx.6 for ; Wed, 16 Jun 2021 13:45:11 -0700 (PDT) X-Received: by 2002:a2e:2ac6:: with SMTP id q189mr1436691ljq.61.1623875865511; Wed, 16 Jun 2021 13:37:45 -0700 (PDT) MIME-Version: 1.0 References: <87sg1p30a1.fsf@disp2133> <87pmwsytb3.fsf@disp2133> <87sg1lwhvm.fsf@disp2133> <6e47eff8-d0a4-8390-1222-e975bfbf3a65@gmail.com> <924ec53c-2fd9-2e1c-bbb1-3fda49809be4@gmail.com> <87eed4v2dc.fsf@disp2133> <5929e116-fa61-b211-342a-c706dcb834ca@gmail.com> <87fsxjorgs.fsf@disp2133> <87zgvqor7d.fsf_-_@disp2133> <87mtrpg47k.fsf@disp2133> <87pmwlek8d.fsf_-_@disp2133> <87k0mtek4n.fsf_-_@disp2133> In-Reply-To: From: Linus Torvalds Date: Wed, 16 Jun 2021 13:37:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] alpha/ptrace: Record and handle the absence of switch_stack To: "Eric W. Biederman" Cc: Michael Schmitz , linux-arch , Jens Axboe , Oleg Nesterov , Al Viro , Linux Kernel Mailing List , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Geert Uytterhoeven , linux-m68k , Arnd Bergmann , Ley Foon Tan , Tejun Heo , Kees Cook Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 16, 2021 at 1:00 PM Linus Torvalds wrote: > > And even for debugging, I think it would be both easier and cheaper to > just add a magic word to the entry stack instead. IOW, just add a unsigned long magic; to "struct switch_stack", and then make the stack switch code push that value. That would be cheap enough to be just unconditional, but you could make it depend on a debug config option too, of course. It helps if 'xyz' is some constant that is easyish to generate. It might not be a constant - maybe it could be the address of that 'magic' field itself, so you'd just generate it with stq $r,($r) and it would be equally easy to just validate at lookup for that WARN_ON_ONCE(): WARN_ON_ONCE(switch_stack->magic != (unsigned long)&switch_stack->magic); or whatever. It's for debugging, not security. So it doesn't have to be some kind of super-great magic number, just something easy to generate and check (that isn't a common value like "0" that trivially exist on the stack anyway). Linus