From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5DF5C05027 for ; Fri, 20 Jan 2023 19:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674241404; h=from:from:sender:sender: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uHpbeB+iIR+IvgVl3W1UtjyT1DcI1D1Ty+xu3z0wohk=; b=QcCwZjAnhqZ9LO3XMDVoESY46uLfg7fM6rPWUfSDRrOkgtKWS88gJI6/frlh7uZeJE355n wz25RB91cNbVUkEWkjxlE4Lg0GcsgDK4qXYDeGsPsv0gBls4CcQvSJknaRZsPhrBk4gsC5 LzYtTQrIqcLdR5TBqS5KySIcqimvmo0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-20-EnIflEbjP1es7xjtxCYe0w-1; Fri, 20 Jan 2023 14:03:23 -0500 X-MC-Unique: EnIflEbjP1es7xjtxCYe0w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D1F38805AC5; Fri, 20 Jan 2023 19:02:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF87553AA; Fri, 20 Jan 2023 19:02:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AFA591946A78; Fri, 20 Jan 2023 19:02:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B9D5C1946588 for ; Fri, 20 Jan 2023 14:38:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1E89A40C2006; Fri, 20 Jan 2023 14:38:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1700340C2064 for ; Fri, 20 Jan 2023 14:38:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EBB6E3815F87 for ; Fri, 20 Jan 2023 14:38:20 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-531-kEyAeFauOBmHBUwqRlcY7g-1; Fri, 20 Jan 2023 09:38:19 -0500 X-MC-Unique: kEyAeFauOBmHBUwqRlcY7g-1 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 94904B827E7; Fri, 20 Jan 2023 14:29:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 237E9C4339B; Fri, 20 Jan 2023 14:29:33 +0000 (UTC) Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id c179fd18 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 20 Jan 2023 14:29:31 +0000 (UTC) Date: Fri, 20 Jan 2023 15:29:14 +0100 From: "Jason A. Donenfeld" To: Yann Sionneau Subject: Re: [RFC PATCH v2 12/31] kvx: Add other common headers Message-ID: References: <20230120141002.2442-1-ysionneau@kalray.eu> <20230120141002.2442-13-ysionneau@kalray.eu> MIME-Version: 1.0 In-Reply-To: <20230120141002.2442-13-ysionneau@kalray.eu> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mailman-Approved-At: Fri, 20 Jan 2023 19:02:49 +0000 X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marc =?utf-8?B?UG91bGhpw6hz?= , linux-doc@vger.kernel.org, Peter Zijlstra , Catalin Marinas , Atish Patra , Jiaxun Yang , Julien Hascoet , Clement Leger , linux-mm@kvack.org, devicetree@vger.kernel.org, Louis Morhet , Krzysztof Kozlowski , linux-riscv@lists.infradead.org, Will Deacon , Guangbin Huang , Alex Michon , Thomas Costis , Jonathan Corbet , Jonathan Borne , Marc Zyngier , Huacai Chen , bpf@vger.kernel.org, Ingo Molnar , linux-arch@vger.kernel.org, Jean-Christophe Pince , Waiman Long , Bharat Bhushan , Qi Liu , Alexey Dobriyan , Luc Michel , John Garry , Ashley Lesdalons , Albert Ou , Kees Cook , Arnd Bergmann , Samuel Jones , Boqun Feng , Guillaume Thouvenin , Julian Vetter , Nick Piggin , Shaokun Zhang , Rob Herring , Bibo Mao , Paul Walmsley , WANG Xuerui , linux-audit@redhat.com, Thomas Gleixner , Marius Gligor , Janosch Frank , Julien Villette , Jules Maselbas , Christian Brauner , Benjamin Mugnier , Vincent Chardon , Guillaume Missonnier , Oleg Nesterov , Eric Paris , linux-kernel@vger.kernel.org, Mark Brown , Palmer Dabbelt , Eric Biederman , "Aneesh Kumar K.V" , Andrew Morton Errors-To: linux-audit-bounces@redhat.com Sender: "Linux-audit" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Yann, On Fri, Jan 20, 2023 at 03:09:43PM +0100, Yann Sionneau wrote: > +#include > +#include > + > +extern unsigned long __stack_chk_guard; > + > +/* > + * Initialize the stackprotector canary value. > + * > + * NOTE: this must only be called from functions that never return, > + * and it must always be inlined. > + */ > +static __always_inline void boot_init_stack_canary(void) > +{ > + unsigned long canary; > + > + /* Try to get a semi random initial value. */ > + get_random_bytes(&canary, sizeof(canary)); > + canary ^= LINUX_VERSION_CODE; > + canary &= CANARY_MASK; > + > + current->stack_canary = canary; > + __stack_chk_guard = current->stack_canary; > +} You should rewrite this as: current->stack_canary = get_random_canary(); __stack_chk_guard = current->stack_canary; which is what the other archs all now do. (They didn't used to, and this looks like it's simply based on older code.) > +#define get_cycles get_cycles > + > +#include > +#include > + > +static inline cycles_t get_cycles(void) > +{ > + return kvx_sfr_get(PM0); > +} Glad to see this CPU has a cycle counter. Out of curiosity, what is its resolution? Also, related, does this CPU happen to have a "RDRAND"-like instruction? (I don't know anything about kvx or even what it is.) Jason -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit