Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3212822pxb; Mon, 9 Nov 2020 05:44:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrVBgtwQpISFD++vK6W9O1Rn0cbmpd6jAer2n622meCj1bQXcu83ZATGfM9z0aBroCgecl X-Received: by 2002:a17:906:1a07:: with SMTP id i7mr14583885ejf.473.1604929478942; Mon, 09 Nov 2020 05:44:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929478; cv=none; d=google.com; s=arc-20160816; b=BTkT6ir93CVwFsljHjCg74YrTHJn7OaqGsXfiPbfw5iTFA55MKlm7X9EJzkaakagOO QI09mo2ZFBy3CEk8tjrVFdr04C0YJgqlkgqDjpqbKZl9OVyBF92Zn57w3cQU+UVd/Ri1 NtYg17H+6h4r//XsypsHuowpZz9O/z8+FurNfAuDrg3WfkjB2nd6+TeSsFZk44iU0pyD dGxXKi8zKCJu8SWaYtJmdAEgCYjVH1Y6H4lRtGqJzpiS8LKcaBtrUtTWPxt1a8prfv/T qmaYPjoydwmwHfa+Xcj7JHdkmmOgfmaQpM4rWTKu5VUkZXjtc46DJd/v7HebDDE61DRv xg2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5qWiuWNkTeW4Hx0XOI/IGogyRRe0kGBvaAw/Hf68f3E=; b=qFUejW1yvMWynCwxKjP61mzV5U+njx/6TDmFpNgrmYgm2qnIUikVfmYikDVzoOm1WV 5h+/htoKkqeueVJacS//JR1Sllq2VyxMvVPg3HKcDxu6gTD3OJoX7NlDvqzecCPigcki YuYakQhfbieFp1QwTxoj1JZl+AZFzR6BH8jpOysf2TVjhRBQQ7oYq2RwGLkgKHCvV+/5 WATd94pgPGalbz7YBuN9MEtSkJfF2cC/9G+506Pw94Os4qDTxwgJMuBtx9BfjNNsx2LU einaXKHoR6bgtFbAEkBvrtwBkz6TwzpN2b/Bie6RaP0x8jBrVGx4Hc8WLQ20PijA0PA/ Z3Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Y5bfnbk; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n22si6889051ejk.683.2020.11.09.05.44.14; Mon, 09 Nov 2020 05:44:38 -0800 (PST) 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=@kernel.org header.s=default header.b=0Y5bfnbk; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730579AbgKINmI (ORCPT + 99 others); Mon, 9 Nov 2020 08:42:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:55188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730549AbgKINBI (ORCPT ); Mon, 9 Nov 2020 08:01:08 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A8FDA20789; Mon, 9 Nov 2020 13:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604926867; bh=99OUfKmhEX8Y8oEVWQie1vocVS/5EWsoArtu+G30j/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Y5bfnbkrO3Bdp5PnVCU7K16yod3ChG8IH5au2GKYLV1Nkujy1ACEynEyMJxGrcXd PqN58xz54LdTntuvIoOoaJoIA6NIJdtfopSBpGNLQofTjc3OBGPRxNjBo9wEVtopf3 GAuN/p+KsQP4Vytm+dn8Q9soOsNzbo+tqAFeifgs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Theodore Tso Subject: [PATCH 4.9 014/117] fscrypt: use EEXIST when file already uses different policy Date: Mon, 9 Nov 2020 13:54:00 +0100 Message-Id: <20201109125026.326180094@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers commit 8488cd96ff88966ccb076e4f3654f59d84ba686d upstream. As part of an effort to clean up fscrypt-related error codes, make FS_IOC_SET_ENCRYPTION_POLICY fail with EEXIST when the file already uses a different encryption policy. This is more descriptive than EINVAL, which was ambiguous with some of the other error cases. I am not aware of any users who might be relying on the previous error code of EINVAL, which was never documented anywhere. This failure case will be exercised by an xfstest. Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/crypto/policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -131,7 +131,7 @@ int fscrypt_ioctl_set_policy(struct file printk(KERN_WARNING "%s: Policy inconsistent with encryption context\n", __func__); - ret = -EINVAL; + ret = -EEXIST; } inode_unlock(inode);