Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1575400pxy; Thu, 29 Apr 2021 09:47:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5+x0zzwZEPDEteC9ULcxRS+F4qxvLxYY0YQWao2BavaVatkUUZKhEeJhebpy2oPQM5BXg X-Received: by 2002:a17:906:ecb8:: with SMTP id qh24mr884234ejb.162.1619714844189; Thu, 29 Apr 2021 09:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619714844; cv=none; d=google.com; s=arc-20160816; b=hc4sl8/SfcmlGd1GRMnExnIx+Dz+DlWpLzh4PHCMdCWvi9kw1DQo5xTkEHC7GP64wy qkvKwBlQfoPm18hSwVZH7ei+uxYCjm4CFW8oBFrmw6Rd5l/Km0N2KbJsQ63iHLUAg4gD 5JtT5cdY5Dyj1+ro8OTUIgIyd95B2uFzFlVAaCNDiHhVcLzPlySHQ0bq1wMUl2/wQAnM JTFzEo0+OVrq1QBuF5MQoABH7N/ydOmM5ZCLpIgdRqRZBeZ0GveMi+0kVJU7l8TgJpHy +fbxg9d2+0u2Sbh9Q3+sJEO6zAVB03bINy26YxR9uV6m/DgNkb2qPDYpYBdjQrOou4pD I2IQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+ad63PVCcTY8G5quIEl9VpmY7+0tV15lo66Ty6GyFEc=; b=YhfRBC9R7OzeSsWFN7n1sPkAVXog1lbs4hl2moglhSGOLJaOX4cYZvsf+JZZQQZFjA 17E9Kr9RmMb3Sl5iaPWMC3amG1OFIg20+mEC5s5zx2k9MkQ9P9/sGBF57SFYgRil0mmS pG+nc7D1qkpHDmVUms2UL9va39gogDkM4TG9KdNMCY4ooW3StRbbVS7BZouUvtWXObtM nJlq9PDBV29U++cRZKPbOAyZpdXWm87t2mcz7Kyr0XsHNDPsIBiLHLifPeY7tzElNrf+ 5r9tjVAhvkNFaOpQ3l4IWDK+zGrMauVf0RQDw8Yj6UlhxJQB4pBL+8UYDGqXau11MBnx o9Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=WllWCfTK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si3496066edd.170.2021.04.29.09.46.59; Thu, 29 Apr 2021 09:47:24 -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=@alien8.de header.s=dkim header.b=WllWCfTK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240875AbhD2Qqm (ORCPT + 99 others); Thu, 29 Apr 2021 12:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232724AbhD2Qqk (ORCPT ); Thu, 29 Apr 2021 12:46:40 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCB09C06138B; Thu, 29 Apr 2021 09:45:53 -0700 (PDT) Received: from zn.tnic (p200300ec2f0a4f00c0c5be88e2edfd96.dip0.t-ipconnect.de [IPv6:2003:ec:2f0a:4f00:c0c5:be88:e2ed:fd96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 253F71EC0266; Thu, 29 Apr 2021 18:45:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1619714752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=+ad63PVCcTY8G5quIEl9VpmY7+0tV15lo66Ty6GyFEc=; b=WllWCfTKHtk2grwTb0bcROdTjEBFSTbW4IXMbRR95A5UWvb7B3LcyCQW5zVPfLHYDOLscW jsc6FXvL4pMBHB6B4gOUdPm+a6YuR+cRRSAow3GJ7FqHIB60Joq69Zy9+HQF+gB0Efqk/F eXiJMErDV5h38KquyvNSKrSczvhY63o= Date: Thu, 29 Apr 2021 18:45:49 +0200 From: Borislav Petkov To: "Yu, Yu-cheng" 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 , 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 , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang Subject: Re: [PATCH v26 22/30] x86/cet/shstk: Add user-mode shadow stack support Message-ID: References: <20210427204315.24153-1-yu-cheng.yu@intel.com> <20210427204315.24153-23-yu-cheng.yu@intel.com> <3a0ed2e3-b13d-0db6-87af-fecd394ddd2e@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 29, 2021 at 09:17:06AM -0700, Yu, Yu-cheng wrote: > The lock applies to both shadow stack and ibt. So maybe just "locked"? Sure. > vm_munmap() returns error as the following: > > (1) -EINVAL: address/size/alignment is wrong. > For shadow stack, the kernel keeps track of it, this cannot/should not > happen. You mean nothing might corrupt cet->shstk_base cet->shstk_size ? I can't count the ways I've heard "should not happen" before and then it happening anyway. So probably not but we better catch stuff like that instead of leaking. > Should it happen, it is a bug. Ack. > The kernel can probably do WARN(). Most definitely WARN. You need to catch funsies like that. But WARN_ONCE should be enough for now. > (2) -ENOMEM: when doing __split_vma()/__vma_adjust(), kmem_cache_alloc() > fails. > Not much we can do. Perhaps WARN()? You got it. Bottom line is: if you can check for this and it is cheap, then definitely. Code changes, gets rewritten, reorganized, the old assertions change significance, and so on... Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette