Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1398013rwd; Tue, 16 May 2023 17:04:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ySCYVLyu5vLF1505jSE99n8lL7ak58JYgVk6rmuv0lrr/TqxNRWVOnqgaJdHBOuWl1J5Q X-Received: by 2002:a17:902:f68e:b0:1ad:e8f5:7c7b with SMTP id l14-20020a170902f68e00b001ade8f57c7bmr21065122plg.62.1684281843188; Tue, 16 May 2023 17:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684281843; cv=none; d=google.com; s=arc-20160816; b=Av012a9e2XXWrPS6rPiXbGXrX/LvqhYujYSr9PblBagxbLk0gXpqItCMcrp4ey0gHb ow74k8jIRP33Ws2KbMQVvV+3CwCVLQ4j71BvvIMWJwYJZeTLSstHo9wCuZP6SFqcBu8U 2hYNaX20gJJbyqYEbyOXo5kFroQjpYb1nDJlWIYzqRm5vreu/JXqxDo0JY28B38SeAaK neJ04puuOpE7mbNYwfKhJx/YcC7uX1a33FlpVA9pZbGh3YR/bHMQGmaYDNKj2TxOHET3 B01gN+v7SGDyWo+T3hPEklHKUeBjXK+7t/BjxzhbFEUDqKLpFYSsmsPf+a7XxVOSvj4D SIig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=6VevJ1vGUj20/tD3Yj2GGzM81HOY6lYpsXDwoLyRLgo=; b=YiPj109mxE413f83i6HYomFLnfMRIWpbH4lRZ3IjFQvgIyahwEbjq6VpBq3GYBH6x5 dpF6R0p30fZ+I57AoXMK+/BMq+Gi/DJvQ9v1purTK6wF7DLlRCqLx4FgdWPEUpibXEas dMt1y4LhS2aWxRg6WyxwmRpRa3hV7zt5t9aBEdJ01ymYO826WT2kQwBOJffI0ySkRkCF 1kRq8aDZvLnqHi5V6f51pOExO2l2TSJLFszD5foPSigyIYvVm816rJxZgj2Euq0X7U6T N5apfj8CLVwzXskl1v+WQRxR0G2pa2URMJVhSP7svcI0YTHAjI2QyFsnvBGBpVDE0E8s wOZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GZXmWHOI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h22-20020a170902f7d600b001ae0691dff4si7715273plw.630.2023.05.16.17.03.47; Tue, 16 May 2023 17:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GZXmWHOI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231371AbjEPXTS (ORCPT + 99 others); Tue, 16 May 2023 19:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231426AbjEPXTM (ORCPT ); Tue, 16 May 2023 19:19:12 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D96749CC; Tue, 16 May 2023 16:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684279138; x=1715815138; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=aTTXi21fx3EQBbKsXrlszRhCxMf11Htc3j/PZEduJLo=; b=GZXmWHOIkZF+X7U4QaVswU1y/ExSRLC0cMxKDjJRQZW6uyKXW8fT95Gm bgBH04q2HQKwbndbpskD68U88bonOPbG3Ve34S6zaLpF5qcjQ0g7S1JhD OESu5wL2+y1BscJPJlzmbLgHHylf9x2pptVtK86frajI7mVudWaCeq90Z 8eOT1rVOkXQzLOu0g8qTf2ELPL6bwZILpAZ6XtbGTxo7Q1xbOkUCCbwij ty0gn8ZBrOGtXs1GTVoGAVKlRA79lrNJ0s0+G7MWy6rJZEnubq3RF5RDa nFbInCWsApPlIyg91q0UChFOrtIDcNmKdBlUccMcSggLF5cOUgxh/kSfg w==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="417270309" X-IronPort-AV: E=Sophos;i="5.99,280,1677571200"; d="scan'208";a="417270309" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 16:18:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="791257808" X-IronPort-AV: E=Sophos;i="5.99,280,1677571200"; d="scan'208";a="791257808" Received: from mtpanu-mobl1.amr.corp.intel.com (HELO [10.212.203.6]) ([10.212.203.6]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 16:18:57 -0700 Message-ID: <78bb0097-7dca-254f-45a6-5cea6baec0c4@intel.com> Date: Tue, 16 May 2023 16:18:56 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 3/6] PKEY: Apply PKEY_ENFORCE_API to mprotect Content-Language: en-US To: jeffxu@chromium.org, luto@kernel.org, jorgelo@chromium.org, keescook@chromium.org, groeck@chromium.org, jannh@google.com, sroettger@google.com Cc: akpm@linux-foundation.org, jeffxu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org References: <20230515130553.2311248-1-jeffxu@chromium.org> <20230515130553.2311248-4-jeffxu@chromium.org> From: Dave Hansen In-Reply-To: <20230515130553.2311248-4-jeffxu@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/15/23 06:05, jeffxu@chromium.org wrote: > /* > * pkey==-1 when doing a legacy mprotect() > + * syscall==true if this is called by syscall from userspace. > + * Note: this is always true for now, added as a reminder in case that > + * do_mprotect_pkey is called directly by kernel in the future. > + * Also it is consistent with __do_munmap(). > */ > static int do_mprotect_pkey(unsigned long start, size_t len, > - unsigned long prot, int pkey) > + unsigned long prot, int pkey, bool syscall) > { The 'syscall' seems kinda silly (and a bit confusing). It's easy to check if the caller is a kthread or has a current->mm==NULL. If you *really* want a warning, I'd check for those rather than plumb a apparently unused argument in here. BTW, this warning is one of those things that will probably cause some amount of angst. I'd move it to the end of the series or just axe it completely.