Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 198aac25 authored by Joel Fernandes's avatar Joel Fernandes
Browse files

Revert "UPSTREAM: mm: Add an F_SEAL_FUTURE_WRITE seal to memfd"

This reverts commit 1dc8ca44.

Change-Id: I513034073c278e2ae58a53352cc2553a256a7ee0
parent 3a49374a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@
#define F_SEAL_SHRINK	0x0002	/* prevent file from shrinking */
#define F_SEAL_GROW	0x0004	/* prevent file from growing */
#define F_SEAL_WRITE	0x0008	/* prevent writes */
#define F_SEAL_FUTURE_WRITE	0x0010  /* prevent future writes while mapped */
/* (1U << 31) is reserved for signed error codes */

/*
+1 −21
Original line number Diff line number Diff line
@@ -150,8 +150,7 @@ static unsigned int *memfd_file_seals_ptr(struct file *file)
#define F_ALL_SEALS (F_SEAL_SEAL | \
		     F_SEAL_SHRINK | \
		     F_SEAL_GROW | \
		     F_SEAL_WRITE | \
		     F_SEAL_FUTURE_WRITE)
		     F_SEAL_WRITE)

static int memfd_add_seals(struct file *file, unsigned int seals)
{
@@ -220,25 +219,6 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
		}
	}

	if ((seals & F_SEAL_FUTURE_WRITE) &&
	    !(*file_seals & F_SEAL_FUTURE_WRITE)) {
		/*
		 * The FUTURE_WRITE seal also prevents growing and shrinking
		 * so we need them to be already set, or requested now.
		 */
		int test_seals = (seals | *file_seals) &
				 (F_SEAL_GROW | F_SEAL_SHRINK);

		if (test_seals != (F_SEAL_GROW | F_SEAL_SHRINK)) {
			error = -EINVAL;
			goto unlock;
		}

		spin_lock(&file->f_lock);
		file->f_mode &= ~(FMODE_WRITE | FMODE_PWRITE);
		spin_unlock(&file->f_lock);
	}

	*file_seals |= seals;
	error = 0;