Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18422210rwd; Tue, 27 Jun 2023 17:13:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Ju+2CtSsy2Ls4R8Y/gKcb6HQlzI5FxSkgZN+qdAZlKKdxJa30rTJXZHNcNFDwSUsZ+CT1 X-Received: by 2002:a17:907:31ca:b0:982:487c:7508 with SMTP id xf10-20020a17090731ca00b00982487c7508mr27600183ejb.38.1687911223953; Tue, 27 Jun 2023 17:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687911223; cv=none; d=google.com; s=arc-20160816; b=ZrX5QRn9ZGqcAx3aGY6ZZEMa5yAtSvazwHIpFx9tFFJFf7s0IJIGNJSOedv1BTiNT9 XnfKVZZ+YNREgWjQQoOrwRnG9YL7jV8e4lufT4lk2+r/T99rx/+nfdOUhOMVn3/kq225 aKg0ah4qPmAbz/k9rI9svhSmJIwNZauEe4lb6nGkOWa+V3HrWsS78CJrBzGVL3IS1pgo VeI1598yxvfaGtnNfswO0hFHyXocOUEKNeHYA0YkJcalf02It9xdcISfJkgCskekDfya XeqcsFzRijNAO3vs3QcAFnWVsO5NF5XzxmoH+gPY5qFnKmStZKVSalfcKyH0Yah5TAjr tnvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=nQ66hOLk1EB/Vn5W15HHXt3vsl6UfE70hsJ2Sl1V9GI=; fh=arPSFrkWUPvMsj4DWxXPWxenN+ODkRzyvrUp37O5jGo=; b=h5wR3kJX92DJ5VciNjVuJDiVD2Mx8hudj85NNvdP/m2ncN6c09zZ9YVr4RZ3Y4+17R 9MnIIUr+DEi5kobU86Q8GCnTRd5DVNH2e6klz1LLCaLDaVkRfsNBcEtN/qbtS8C2WYVE NMF05J5PeFGrDhybQ83MBfVz+kEvMXAdVKZjB17buj4r1NI10n2wzglWn3594cGpzah5 F3gtRLn1X4afVS08rOZIG3NA90ZXNKFMbmuYmveRDupxIUHGIDiNntgbg7NgdXajrX4R ob02DM5FyfdgCI2vVcz6wj2iGXGwTKyC6sUBmU8nfuKoeDtN9e2/xt4vgyJKoNavHNxU tHLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TtHLiNcP; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gr6-20020a170906e2c600b0098886d50308si4516903ejb.490.2023.06.27.17.13.18; Tue, 27 Jun 2023 17:13:43 -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=@intel.com header.s=Intel header.b=TtHLiNcP; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbjF0XqF (ORCPT + 99 others); Tue, 27 Jun 2023 19:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjF0XqD (ORCPT ); Tue, 27 Jun 2023 19:46:03 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA81C199E; Tue, 27 Jun 2023 16:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687909562; x=1719445562; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=JwRZ15P1mfvGvsAhRba9m3i1avJ8D0VfdP6uCJ0rkDA=; b=TtHLiNcPMlyYOWoOu/MKtHtUZDOP23bJW0ac5anl00RRS+Z3acvLi0NV QNYcUCNh2fSgFni6CkOzFf+rhrZBrs2QBCgji66N4lApGjGidcoj1prJ4 U0o7QuPBY6cgQGBjqohgzO2io1nFYE+lZRJNfrP8A1cc+mht4SpUkt8od AHQfgSI4TRIuwV0ke6NBwK6rGd2CxuNcNgyq0pzxm30oyExvTyKE57X59 d+iTaA/NGCU4LVtGD54lhl0fUg6rJ1MX/Ogm+4vJmqfhLA1HqExui/bqq n/svSmEMcflUEhg8o0OLvO4QpgaMEUsCfJXYYfs9HihyAmfrUwsy6Sq1n g==; X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="342046596" X-IronPort-AV: E=Sophos;i="6.01,163,1684825200"; d="scan'208";a="342046596" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2023 16:46:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="716711566" X-IronPort-AV: E=Sophos;i="6.01,163,1684825200"; d="scan'208";a="716711566" Received: from btalbott-mobl.amr.corp.intel.com (HELO [10.212.238.85]) ([10.212.238.85]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2023 16:46:01 -0700 Message-ID: Date: Tue, 27 Jun 2023 16:46:00 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v9 28/42] x86/shstk: Add user-mode shadow stack support Content-Language: en-US To: Mark Brown , Rick Edgecombe Cc: x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, david@redhat.com, debug@rivosinc.com, szabolcs.nagy@arm.com, torvalds@linux-foundation.org, Yu-cheng Yu , Pengfei Xu References: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> <20230613001108.3040476-29-rick.p.edgecombe@intel.com> <76a87cdf-4d4f-4b3f-b01f-0540eab71ac7@sirena.org.uk> From: Dave Hansen In-Reply-To: <76a87cdf-4d4f-4b3f-b01f-0540eab71ac7@sirena.org.uk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 6/27/23 10:20, Mark Brown wrote: > On Mon, Jun 12, 2023 at 05:10:54PM -0700, Rick Edgecombe wrote: > >> +static void unmap_shadow_stack(u64 base, u64 size) >> +{ >> + while (1) { >> + int r; >> + >> + r = vm_munmap(base, size); >> + >> + /* >> + * vm_munmap() returns -EINTR when mmap_lock is held by >> + * something else, and that lock should not be held for a >> + * long time. Retry it for the case. >> + */ >> + if (r == -EINTR) { >> + cond_resched(); >> + continue; >> + } > This looks generic, not even shadow stack specific - was there any > discussion of making it a vm_munmap_retry() (that's not a great name...) > or similar? I didn't see any in old versions of the thread but I > might've missed something. Yeah, that looks odd. Also odd is that none of the other users of vm_munmap() bother to check the return value (except for one passthrough in the nommu code). I don't think the EINTR happens during contention, though. It's really there to be able break out in the face of SIGKILL. I think that's why nobody handles it: the task is dying anyway and nobody cares. Rick, was this hunk here for a specific reason or were you just trying to be diligent in handling errors?