Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7640114ybi; Mon, 22 Jul 2019 17:31:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVEbw69apPZjPb6q0wNs6iX1s4yEMQKe6/xQYlNtScUCAnx75o/g2hrxB3nQmPhV19mEQD X-Received: by 2002:a63:784c:: with SMTP id t73mr75985269pgc.268.1563841863108; Mon, 22 Jul 2019 17:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563841863; cv=none; d=google.com; s=arc-20160816; b=v+6T0tZ6pQdQAMB5P41jDHK/MxUfnyKJ1KPv9uqiLEZrP1ZPVg328igmOcyroZSJxD wNK4gKXboSES8AYb/quZnyfgpkRFmvsKslz8Jly/M6EhXL6ojUAuW4XWIs9jWL6TvKJH upBwhzOlFNiDI0v8VtqJLXMRvlFN4t8QpKO+OjdG8eQPYyOHUlcTkKWdbRmKOjMXVYbe 7RgAFUv22LoLHVtr6+sZrNnumjkYlF5OSe291hjNp00Rn64DxIJVptQC8kn059JDPYG1 ugi0BC77UqSFL+XKB8xPymUnWv4ggGEIuKy9WD0zoBHSX5QVKmJ5iqhkGOzMKVrCx8v/ QKmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=3KR4nSYoeUF6BqcPDxSMB6l7iYSRudrtMO9lDc1iAPY=; b=Wz98zTW/uNsPDErpAJLhD4o4as+eTaGiveRmJRCCaKoiZarQYQg4XgU9/z1U8HLvUI nfMfo6TuZDclpMdL85qF44+6OgKDt0mTjRd/6wiFMCcoDvcL8KdB0PvXinWqxOX1QWaU JMjUcp+X5KrtJKdv9tqH/jTvEg1og7tLtJy+vEi7DOWZnvBe3jVm0jrWUIVDAmf/Sa8j L+qQF0p9lWlbordsZM6TlfDyH7LkVLZV1YHlw9lq+azrRTByGKzuoTM7rdGbQfWEjx/1 2bOJT9EZi8fuK7ChpMEJLdJxh/LMQKbJrPzEQcLEKRL1i6sF5sA6slr1pFVzDeNMnd1X kAEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i97si15453257plb.50.2019.07.22.17.30.47; Mon, 22 Jul 2019 17:31:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729092AbfGVSbp (ORCPT + 99 others); Mon, 22 Jul 2019 14:31:45 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:37855 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbfGVSbo (ORCPT ); Mon, 22 Jul 2019 14:31:44 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hpd5y-0001S0-83; Mon, 22 Jul 2019 20:31:34 +0200 Date: Mon, 22 Jul 2019 20:31:32 +0200 (CEST) From: Thomas Gleixner To: Kees Cook cc: Andy Lutomirski , Sean Christopherson , Andy Lutomirski , Vincenzo Frascino , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [5.2 REGRESSION] Generic vDSO breaks seccomp-enabled userspace on i386 In-Reply-To: <201907221012.41504DCD@keescook> Message-ID: References: <20190719170343.GA13680@linux.intel.com> <19EF7AC8-609A-4E86-B45E-98DFE965DAAB@amacapital.net> <201907221012.41504DCD@keescook> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Jul 2019, Kees Cook wrote: > On Fri, Jul 19, 2019 at 01:40:13PM -0400, Andy Lutomirski wrote: > > > On Jul 19, 2019, at 1:03 PM, Sean Christopherson wrote: > > > > > > The generic vDSO implementation, starting with commit > > > > > > 7ac870747988 ("x86/vdso: Switch to generic vDSO implementation") > > > > > > breaks seccomp-enabled userspace on 32-bit x86 (i386) kernels. Prior to > > > the generic implementation, the x86 vDSO used identical code for both > > > x86_64 and i386 kernels, which worked because it did all calcuations using > > > structs with naturally sized variables, i.e. didn't use __kernel_timespec. > > > > > > The generic vDSO does its internal calculations using __kernel_timespec, > > > which in turn requires the i386 fallback syscall to use the 64-bit > > > variation, __NR_clock_gettime64. > > > > This is basically doomed to break eventually, right? > > Just so I'm understanding: the vDSO change introduced code to make an > actual syscall on i386, which for most seccomp filters would be rejected? No. The old x86 specific VDSO implementation had a fallback syscall as well, i.e. clock_gettime(). On 32bit clock_gettime() uses the y2038 endangered timespec. So when the VDSO was made generic we changed the internal data structures to be 2038 safe right away. As a consequence the fallback syscall is not clock_gettime(), it's clock_gettime64(). which seems to surprise seccomp. Thanks, tglx