Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1282271ybt; Tue, 7 Jul 2020 11:46:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTh0usfNlqPJ8EIRLvFjM5xtYD+m8nIF8oKG2WWmf+6Ktp7dMlQf9iUEt4DU52DrzHhE1T X-Received: by 2002:a05:6402:8da:: with SMTP id d26mr55395811edz.109.1594147592971; Tue, 07 Jul 2020 11:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594147592; cv=none; d=google.com; s=arc-20160816; b=Qsb5Rkrak84GE96qElmFqdOo7RyWpLNB/Kzyv4lTf4G2csVmxC/09EWURCDHEr3qFG WEhn+snE6HnPaFCoP1f44ODMDPZ9m1U0Dtm4GXL4wHgGe2RdUspuDbZ10+NF8e1jnjEL 9CIbtfGaMUtV5+DSQo+tOOUvAwtEt3JkNDRU8dEQmUDpNEyMIIGvWxGuvCDLqDHKDWOm /Rktpbb1yGp+12ZszUacS1yC3bYU8cHamsOblHSgV5/VvyTLc30A7mqVKzJUQu7sHtDF jwmOJ+/VRCebEXBPYUVRS9Ukiy+wytL1+YPbdt9mqiD2mVTTTOmLvmEU6fKIAy3Il7NB nAJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=3UnYJ2AepeqtDjdppPnwImocnyjjQoFyo1qwV4IYv9s=; b=Ng1UHVKpc7ett68SA1ieiVwsNk3V7rBX1buFal9VOknnwOB4t3TWpSgvY38FZboaU/ Lx+5xQU4p9DnqhEHNObO7qbeNwa0e/FYxo3rNp8W4SqIoYVVX//W0G/8gZ5lnyEu5yrH qUhDBWwcwTz5FIJ6xro6yjBBHCr1b2lm5WFFXrnhsMkT0dYRHkt4DfsjI0FCiv9vFYgs p8twZaldHliWGP8q+h8BqwbAIDg9hA0e3kklmMzyoDN+D6FREsTxl6/s5608Ju3GoPj+ knabV6VVcr6VaffdOuwRq5Oz+fdKRuRcOnIT5tv08owwrBHAtW3CrbPsTfPeayRCCnBH PKPw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g22si16139433edq.111.2020.07.07.11.46.09; Tue, 07 Jul 2020 11:46:32 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728487AbgGGSno (ORCPT + 99 others); Tue, 7 Jul 2020 14:43:44 -0400 Received: from mga12.intel.com ([192.55.52.136]:37149 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728191AbgGGSno (ORCPT ); Tue, 7 Jul 2020 14:43:44 -0400 IronPort-SDR: Xf4pQbsE/SO5dntnJ54HNLw4unDGsfkMEV3p0GzdcqsLG4bPMX1eUbfWIfANFhv2oe3JNhTNNj zTBXVIDph1RQ== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="127270614" X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="127270614" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 11:43:43 -0700 IronPort-SDR: tE+2wPm6K9iFIacUOg/CLMFS7F3o0A/U57Q/REyznxMLWP6DfLC9mbDVGuTFmLQbBKrGQ2xHoi WCUff1u5CFuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,324,1589266800"; d="scan'208";a="323625145" Received: from djiang5-mobl1.amr.corp.intel.com (HELO [10.212.176.45]) ([10.212.176.45]) by orsmga007.jf.intel.com with ESMTP; 07 Jul 2020 11:43:43 -0700 Subject: Re: [PATCH] libnvdimm/security: Fix key lookup permissions To: Dan Williams , linux-nvdimm@lists.01.org Cc: Vishal Verma , Ira Weiny , David Howells , linux-kernel@vger.kernel.org References: <159297332630.1304143.237026690015653759.stgit@dwillia2-desk3.amr.corp.intel.com> From: Dave Jiang Message-ID: Date: Tue, 7 Jul 2020 11:43:42 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <159297332630.1304143.237026690015653759.stgit@dwillia2-desk3.amr.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/23/2020 9:35 PM, Dan Williams wrote: > As of commit 8c0637e950d6 ("keys: Make the KEY_NEED_* perms an enum rather > than a mask") lookup_user_key() needs an explicit declaration of what it > wants to do with the key. Add KEY_NEED_SEARCH to fix a warning with the > below signature, and fixes the inability to retrieve a key. > > WARNING: CPU: 15 PID: 6276 at security/keys/permission.c:35 key_task_permission+0xd3/0x140 > [..] > RIP: 0010:key_task_permission+0xd3/0x140 > [..] > Call Trace: > lookup_user_key+0xeb/0x6b0 > ? vsscanf+0x3df/0x840 > ? key_validate+0x50/0x50 > ? key_default_cmp+0x20/0x20 > nvdimm_get_user_key_payload.part.0+0x21/0x110 [libnvdimm] > nvdimm_security_store+0x67d/0xb20 [libnvdimm] > security_store+0x67/0x1a0 [libnvdimm] > kernfs_fop_write+0xcf/0x1c0 > vfs_write+0xde/0x1d0 > ksys_write+0x68/0xe0 > do_syscall_64+0x5c/0xa0 > entry_SYSCALL_64_after_hwframe+0x49/0xb3 > > Cc: Dan Williams > Cc: Vishal Verma > Cc: Dave Jiang > Cc: Ira Weiny > Suggested-by: David Howells > Fixes: 8c0637e950d6 ("keys: Make the KEY_NEED_* perms an enum rather than a mask") > Signed-off-by: Dan Williams Reviewed-by: Dave Jiang > --- > drivers/nvdimm/security.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/nvdimm/security.c b/drivers/nvdimm/security.c > index 89b85970912d..4cef69bd3c1b 100644 > --- a/drivers/nvdimm/security.c > +++ b/drivers/nvdimm/security.c > @@ -95,7 +95,7 @@ static struct key *nvdimm_lookup_user_key(struct nvdimm *nvdimm, > struct encrypted_key_payload *epayload; > struct device *dev = &nvdimm->dev; > > - keyref = lookup_user_key(id, 0, 0); > + keyref = lookup_user_key(id, 0, KEY_NEED_SEARCH); > if (IS_ERR(keyref)) > return NULL; > >