summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@kernel.org>2026-06-18 22:10:08 -0700
committerEric Biggers <ebiggers@kernel.org>2026-07-20 10:39:25 -0700
commitdbca1290258ff20b5742a3a3e294fc95df941939 (patch)
tree2356b4ffda260a33ddd404f4879a426c73f692e1
parent928a1e6ba3201bcc21ecbc680500b0636530532b (diff)
downloadlinux-stable-dbca1290258ff20b5742a3a3e294fc95df941939.tar.gz
linux-stable-dbca1290258ff20b5742a3a3e294fc95df941939.zip
fscrypt: Remove workaround for bug in gcc 7 and earlier
Since the kernel's minimum gcc version is now 8.1, the workaround for a strange gcc bug in fscrypt_ioctl_set_policy() is no longer needed. Link: https://patch.msgid.link/20260619051008.51223-1-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
-rw-r--r--fs/crypto/policy.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 9915e39362db..f40fb5924e75 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -507,7 +507,6 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
union fscrypt_policy policy;
union fscrypt_policy existing_policy;
struct inode *inode = file_inode(filp);
- u8 version;
int size;
int ret;
@@ -518,21 +517,9 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
if (size <= 0)
return -EINVAL;
- /*
- * We should just copy the remaining 'size - 1' bytes here, but a
- * bizarre bug in gcc 7 and earlier (fixed by gcc r255731) causes gcc to
- * think that size can be 0 here (despite the check above!) *and* that
- * it's a compile-time constant. Thus it would think copy_from_user()
- * is passed compile-time constant ULONG_MAX, causing the compile-time
- * buffer overflow check to fail, breaking the build. This only occurred
- * when building an i386 kernel with -Os and branch profiling enabled.
- *
- * Work around it by just copying the first byte again...
- */
- version = policy.version;
- if (copy_from_user(&policy, arg, size))
+ if (copy_from_user((u8 *)&policy + 1, (const u8 __user *)arg + 1,
+ size - 1))
return -EFAULT;
- policy.version = version;
if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
return -EACCES;