Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1477117ybt; Thu, 2 Jul 2020 06:33:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLOU7geCw25f2qKwk9QPkRVPhCelLJeCM1pDDJcHULNTRneFqeg533hsVNft+q1sea7qUM X-Received: by 2002:a17:906:2c02:: with SMTP id e2mr12204173ejh.64.1593696782667; Thu, 02 Jul 2020 06:33:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593696782; cv=none; d=google.com; s=arc-20160816; b=JK4MsuH5CHpojADLiSJhRnkcWI0RAE2tDfRuo7Y+cE6svMaoO187euw99Ckn4QEV/7 P8ws+AIHdVbkiyYxPnVTrUuvdd7iJ2ZJilwBlSiqDIGFmleTdDj7liWLhyyagNdcgGNf jjc2xLaq1TARjOChQm1AiiLshHZC6dBuqonm+Sx/C8RnBL9ibFZkFuRD9unAmzuRLAkk v/rd+tiHqpzFGEwnIKvwCFF3ywoFr2ttfO1tt5O0/T0G4+w15tGolVMZXskVvRe4JOfq dTmv8RcNGcr2tfiGSlCpxqoGjedUWArKTzU79Qle4jsaGuqfz24jwjfL47NlrLsoloHh VxPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=xLnfsZJIjfISG95UJdhsoqQhe7p6eJsc8gkUDWVf5Nk=; b=Te1QL3secaYzaapIdKA6HUK/XXHga7aJiWeS+7cJCae32QcsKdwjStN3kxaq1gQyJg VcNGRK510WNCbsWWelm8WMiuN2h1huAqG5p1hnKZJalO1O8zh92OX7myCiHX0+j1Kh/P KL9B90Xc47526sPv96Ov7b1V6T+9T2Nms+kbFwFzGL8FPKCMz3rIotZHY5tkbaIZZx2I 3aytcFurXewT9MHDWUmM6maXYT6qjTgtItiX4R3BtjxA5pawdTByfA41cWNA19SXLFX/ vRIrtHJVFAxGDhHBCRJ9kaL/gA3/78BwSqo4UqDTWGQZ1ySR2jHqR+QDxefPmkuzkFeS 11vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=l0MCkVmw; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si5878986ejm.155.2020.07.02.06.32.39; Thu, 02 Jul 2020 06:33:02 -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=@ellerman.id.au header.s=201909 header.b=l0MCkVmw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729324AbgGBNcZ (ORCPT + 99 others); Thu, 2 Jul 2020 09:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbgGBNcY (ORCPT ); Thu, 2 Jul 2020 09:32:24 -0400 Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BBB2C08C5C1 for ; Thu, 2 Jul 2020 06:32:24 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 49yJtC3cNTz9sTb; Thu, 2 Jul 2020 23:32:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1593696740; bh=JqsaKRVlWCzam4qhedKHbnSexxiQI2HEvoXSve9jaPQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=l0MCkVmwk66LBjNPWNN/HjHzeTdjJg8FVXUE7JjBev8vXPAdaEBFv+9QAClUghvRx I2SAEKRi8dpR5gwGC0pck0QDrQUIIM8me/3dmsR3cO52qPMzQEO7uqi19i8m8VPOmj kw3xPTE3Azbhq1eRUCB4qFZ4UlTxxSTEcP1XlAm+NaPyZ/XtgHEHrMMl8clVD8rPel csZDqg/ndAhmUitXVKgjQpHbclC8Ihc1avrM6bhNJ4AjvfP94RvRIKAK/h5YD7XgAo Vkx8cT4g+sld2CZdr4TNUghpvv73m3O+1ke44dKyVRFQ2e4QD1pba5mdZQHpzyDtRS xxv1d3MX/RzLQ== From: Michael Ellerman To: Linus Torvalds , Al Viro , Christophe Leroy Cc: Josh Poimboeuf , Peter Zijlstra , the arch/x86 maintainers , Linux Kernel Mailing List Subject: Re: objtool clac/stac handling change.. In-Reply-To: References: <20200701184131.GI2786714@ZenIV.linux.org.uk> <20200701195914.GK2786714@ZenIV.linux.org.uk> Date: Thu, 02 Jul 2020 23:34:31 +1000 Message-ID: <87lfk26nx4.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds writes: > On Wed, Jul 1, 2020 at 12:59 PM Al Viro wrote: >> On Wed, Jul 01, 2020 at 12:04:36PM -0700, Linus Torvalds wrote: >> > >> > That's actually for the access granting. Shutting the access down ends >> > up always doing the same thing anyway.. >> >> #define user_read_access_end prevent_current_read_from_user >> #define user_write_access_end prevent_current_write_to_user >> static inline void prevent_current_read_from_user(void) >> { >> prevent_user_access(NULL, NULL, ~0UL, KUAP_CURRENT_READ); >> } >> >> static inline void prevent_current_write_to_user(void) >> { >> prevent_user_access(NULL, NULL, ~0UL, KUAP_CURRENT_WRITE); >> } >> >> and prevent_user_access() has instances that do care about the direction... > > Go and look closer. > > There are three cases: > > (a) the 32-bit book3s case. It looks like it cares, but when you look > closer, it ends up not caring about the read side, and saving the > "which address to I allow user writes to" in current->thread.kuap > > (b) the nohash 32-bit case - doesn't care > > (c) the 64-bit books case - doesn't care > > So yes, in the (a) case it does make a difference between reads and > writes, but at least as far as I can tell, it ignores the read case, > and has code to avoid the unnecessary "disable user writes" case when > there was only a read enable done. Yeah that's my understanding too. Christophe is the expert on that code so I'll defer to him if I'm wrong. > Now, it's possible that I'm wrong, but the upshot of that is that even > on powerpc, I think that if we just made the rule be that "taking a > user exception should automatically do the 'user_access_end()' for us" > is trivial. I think we can do something to make it work. We don't have an equivalent of x86's ex_handler_uaccess(), so it's not quite as easy as whacking a user_access_end() in there. Probably the simplest option for us is to just handle it in our unsafe_op_wrap(). I'll try and come up with something tomorrow. cheers