Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp779176pxb; Thu, 21 Oct 2021 09:18:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2hLZr3D+0kxcaw/h32uByvPol8oV1rQqQ6UmZypbpPrdmsLJMLdNAIxMuX9dImWjQLuc1 X-Received: by 2002:a05:6402:16d2:: with SMTP id r18mr8912231edx.363.1634833105588; Thu, 21 Oct 2021 09:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634833105; cv=none; d=google.com; s=arc-20160816; b=WWz2ZXx5nMrMYAiEocpLgSkJQVZhoN5a3qnt9Kjq2xZl0WaSxEDyeasri05tF7AH/L vXDFV1XAKhB1j3ixUJintO3k6az7Wy4YWFVwH9i120HfqFsd+jLXOnX7Kq5Wz4z2tk7O kAGBmyb5QWzfaraGBKUfnbBOULIMWEVRX9o1xc5o6Qz76fDhn5GfHIiwyGuX9VIZW4Jb 3dkfHU8xEztmH9uB6qxOIntHWlx5hL8yz5dgrIeJFXW3lwAxSmnxvij3YwdCgC96HZ2r hPDkrQI8s/5k8QaOqTF57TaU90hSHjNC6AyZJgfXMYmEdQ2RlQXcSKazaW/rWeg/ZIGW PbmA== 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=BnP3QIjaR7JnabL4Ln7V26GIHfumLzivJQweHaSc0TY=; b=CpzPwpQ6+sLc0EMj9zsNf0SfFvkTB0O8O+ukzk+C49J3wh7UOxns1NUn8lG/zX8gjw ljv39XQmEytIy/AF1ud/XODSrYap6358E2yq/0BMgd6FmnUJTV9WKBuFTd8bpFtjlz4j lbLXx5ZyT+UQVuZwV7FwLAi8oUfljARaeGV7blANevROO/aHlsisTqF3puM53qgGrIIC VFgl8re0Uzw50zImuvjUsZtljaP0lYJhdmtDHCvCxRC7oWa0llaaxCq5FIa6M/bvkTXr RMpUERZssigpARKgU5zBqwqmne96JpF02z4jRWlkN0YQkUOFwtwmLgBngNYeky0kAEol 1I3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UBKO7odz; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si9818051edx.280.2021.10.21.09.18.01; Thu, 21 Oct 2021 09:18:25 -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=@chromium.org header.s=google header.b=UBKO7odz; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbhJUQRZ (ORCPT + 99 others); Thu, 21 Oct 2021 12:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbhJUQRY (ORCPT ); Thu, 21 Oct 2021 12:17:24 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66A43C061348 for ; Thu, 21 Oct 2021 09:15:08 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id y4so801610plb.0 for ; Thu, 21 Oct 2021 09:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BnP3QIjaR7JnabL4Ln7V26GIHfumLzivJQweHaSc0TY=; b=UBKO7odzSPY8clMHdQmGPBJ+ZxoNV2g6Yb6uDXVIZfwmaI1U55bkabRNRsh+BmuTzy Q/cP/XunCz/WKkEz6QDvY1kE8YqvVgF0YBumI3W/ovL+ELAwUf5lida08f566HsMG4GF Ftg7LzdrVIvFSmkqKjhWVGXItAnkAA07iJIbc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BnP3QIjaR7JnabL4Ln7V26GIHfumLzivJQweHaSc0TY=; b=fQ1r3a7dQC5YEI/Mu98/EVXSxEqOE8ox/mbAc2tBvmHnjCDvWH9WAD7UFLHyW+my4P je8VTuF9VUxrjB9SV+Hi62DJ1HsYgKlS+yDmuHya3gnro8XBCZyPxog4i9Yp3jxnmU+b 8/EgHmCfmtoS6NsCbFb4xvCNR0Ff+wx0V3jMZNS+Yv+Zw+/47SrjIx6scVclTtmhZnpJ zyHFSj+Z8oJQ/MwCvkcVzZ2TOz48r7CSThGZDGvMRR2cmCEelq/WTHRmUpldF6EAIPRE aUmt4eap5Qhu4gl+c7nYoCQ6+Hu9KHNqkzCKGzcyFQJ46smbKIzZFBULFzQRA5YUvTq8 3Ghw== X-Gm-Message-State: AOAM533wOmSlX7dAgHOCeIojettau/UvONEZXEaydFshVrHavVpuDLCk jkYvEAlZy509UilYOL+lGhGMMu9F7t01yg== X-Received: by 2002:a17:902:8a97:b0:13e:6e77:af59 with SMTP id p23-20020a1709028a9700b0013e6e77af59mr6092858plo.4.1634832907872; Thu, 21 Oct 2021 09:15:07 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id u24sm5865109pgo.73.2021.10.21.09.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:15:07 -0700 (PDT) Date: Thu, 21 Oct 2021 09:15:06 -0700 From: Kees Cook To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Linus Torvalds , Oleg Nesterov , Al Viro , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, H Peter Anvin Subject: Re: [PATCH 09/20] signal/vm86_32: Replace open coded BUG_ON with an actual BUG_ON Message-ID: <202110210914.59245E29CF@keescook> References: <87y26nmwkb.fsf@disp2133> <20211020174406.17889-9-ebiederm@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211020174406.17889-9-ebiederm@xmission.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 20, 2021 at 12:43:55PM -0500, Eric W. Biederman wrote: > The function save_v86_state is only called when userspace was > operating in vm86 mode before entering the kernel. Not having vm86 > state in the task_struct should never happen. So transform the hand > rolled BUG_ON into an actual BUG_ON to make it clear what is > happening. If this is actually not a state userspace can put itself into: Reviewed-by: Kees Cook Otherwise, this should be a WARN+kill. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: x86@kernel.org > Cc: H Peter Anvin > Signed-off-by: "Eric W. Biederman" > --- > arch/x86/kernel/vm86_32.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c > index e5a7a10a0164..63486da77272 100644 > --- a/arch/x86/kernel/vm86_32.c > +++ b/arch/x86/kernel/vm86_32.c > @@ -106,10 +106,8 @@ void save_v86_state(struct kernel_vm86_regs *regs, int retval) > */ > local_irq_enable(); > > - if (!vm86 || !vm86->user_vm86) { > - pr_alert("no user_vm86: BAD\n"); > - do_exit(SIGSEGV); > - } > + BUG_ON(!vm86 || !vm86->user_vm86); > + > set_flags(regs->pt.flags, VEFLAGS, X86_EFLAGS_VIF | vm86->veflags_mask); > user = vm86->user_vm86; > > -- > 2.20.1 > -- Kees Cook