Skip to content

Commit b36995b

Browse files
WOnder93pcmoore
authored andcommitted
lsm: fix default return value for inode_getsecctx
-EOPNOTSUPP is the return value that implements a "no-op" hook, not 0. Without this fix having only the BPF LSM enabled (with no programs attached) can cause uninitialized variable reads in nfsd4_encode_fattr(), because the BPF hook returns 0 without touching the 'ctxlen' variable and the corresponding 'contextlen' variable in nfsd4_encode_fattr() remains uninitialized, yet being treated as valid based on the 0 return value. Cc: [email protected] Fixes: 98e828a ("security: Refactor declaration of LSM hooks") Reported-by: Benjamin Coddington <[email protected]> Signed-off-by: Ondrej Mosnacek <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 866d648 commit b36995b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ LSM_HOOK(void, LSM_RET_VOID, release_secctx, char *secdata, u32 seclen)
273273
LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode)
274274
LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen)
275275
LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen)
276-
LSM_HOOK(int, 0, inode_getsecctx, struct inode *inode, void **ctx,
276+
LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode, void **ctx,
277277
u32 *ctxlen)
278278

279279
#if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)

0 commit comments

Comments
 (0)