Skip to content

Commit

Permalink
cred: get rid of CONFIG_DEBUG_CREDENTIALS
Browse files Browse the repository at this point in the history
commit ae19141 upstream.

This code is rarely (never?) enabled by distros, and it hasn't caught
anything in decades. Let's kill off this legacy debug code.

Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
axboe authored and gregkh committed Dec 20, 2023
1 parent f6a7ce5 commit 207f135
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 312 deletions.
1 change: 0 additions & 1 deletion arch/powerpc/configs/skiroot_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ CONFIG_WQ_WATCHDOG=y
CONFIG_DEBUG_SG=y
CONFIG_DEBUG_NOTIFIERS=y
CONFIG_BUG_ON_DATA_CORRUPTION=y
CONFIG_DEBUG_CREDENTIALS=y
# CONFIG_FTRACE is not set
CONFIG_XMON=y
# CONFIG_RUNTIME_TESTING_MENU is not set
1 change: 0 additions & 1 deletion arch/s390/configs/debug_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,6 @@ CONFIG_DEBUG_IRQFLAGS=y
CONFIG_DEBUG_LIST=y
CONFIG_DEBUG_SG=y
CONFIG_DEBUG_NOTIFIERS=y
CONFIG_DEBUG_CREDENTIALS=y
CONFIG_RCU_TORTURE_TEST=m
CONFIG_RCU_REF_SCALE_TEST=m
CONFIG_RCU_CPU_STALL_TIMEOUT=300
Expand Down
4 changes: 0 additions & 4 deletions fs/nfsd/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
int i;
int flags = nfsexp_flags(rqstp, exp);

validate_process_creds();

/* discard any old override before preparing the new set */
revert_creds(get_cred(current_real_cred()));
new = prepare_creds();
Expand Down Expand Up @@ -81,10 +79,8 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
else
new->cap_effective = cap_raise_nfsd_set(new->cap_effective,
new->cap_permitted);
validate_process_creds();
put_cred(override_creds(new));
put_cred(new);
validate_process_creds();
return 0;

oom:
Expand Down
1 change: 0 additions & 1 deletion fs/nfsd/nfssvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,6 @@ nfsd(void *vrqstp)
rqstp->rq_server->sv_maxconn = nn->max_connections;

svc_recv(rqstp);
validate_process_creds();
}

atomic_dec(&nfsdstats.th_cnt);
Expand Down
9 changes: 1 addition & 8 deletions fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
int host_err;
bool retried = false;

validate_process_creds();
/*
* If we get here, then the client has already done an "open",
* and (hopefully) checked permission - so allow OWNER_OVERRIDE
Expand All @@ -909,7 +908,6 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
}
err = nfserrno(host_err);
}
validate_process_creds();
return err;
}

Expand All @@ -926,12 +924,7 @@ int
nfsd_open_verified(struct svc_rqst *rqstp, struct svc_fh *fhp, int may_flags,
struct file **filp)
{
int err;

validate_process_creds();
err = __nfsd_open(rqstp, fhp, S_IFREG, may_flags, filp);
validate_process_creds();
return err;
return __nfsd_open(rqstp, fhp, S_IFREG, may_flags, filp);
}

/*
Expand Down
3 changes: 0 additions & 3 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,6 @@ struct file *dentry_open(const struct path *path, int flags,
int error;
struct file *f;

validate_creds(cred);

/* We must always pass in a valid mount pointer. */
BUG_ON(!path->mnt);

Expand Down Expand Up @@ -1109,7 +1107,6 @@ struct file *dentry_create(const struct path *path, int flags, umode_t mode,
struct file *f;
int error;

validate_creds(cred);
f = alloc_empty_file(flags, cred);
if (IS_ERR(f))
return f;
Expand Down
50 changes: 0 additions & 50 deletions include/linux/cred.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ static inline int groups_search(const struct group_info *group_info, kgid_t grp)
*/
struct cred {
atomic_long_t usage;
#ifdef CONFIG_DEBUG_CREDENTIALS
atomic_t subscribers; /* number of processes subscribed */
void *put_addr;
unsigned magic;
#define CRED_MAGIC 0x43736564
#define CRED_MAGIC_DEAD 0x44656144
#endif
kuid_t uid; /* real UID of the task */
kgid_t gid; /* real GID of the task */
kuid_t suid; /* saved UID of the task */
Expand Down Expand Up @@ -171,46 +164,6 @@ extern int cred_fscmp(const struct cred *, const struct cred *);
extern void __init cred_init(void);
extern int set_cred_ucounts(struct cred *);

/*
* check for validity of credentials
*/
#ifdef CONFIG_DEBUG_CREDENTIALS
extern void __noreturn __invalid_creds(const struct cred *, const char *, unsigned);
extern void __validate_process_creds(struct task_struct *,
const char *, unsigned);

extern bool creds_are_invalid(const struct cred *cred);

static inline void __validate_creds(const struct cred *cred,
const char *file, unsigned line)
{
if (unlikely(creds_are_invalid(cred)))
__invalid_creds(cred, file, line);
}

#define validate_creds(cred) \
do { \
__validate_creds((cred), __FILE__, __LINE__); \
} while(0)

#define validate_process_creds() \
do { \
__validate_process_creds(current, __FILE__, __LINE__); \
} while(0)

extern void validate_creds_for_do_exit(struct task_struct *);
#else
static inline void validate_creds(const struct cred *cred)
{
}
static inline void validate_creds_for_do_exit(struct task_struct *tsk)
{
}
static inline void validate_process_creds(void)
{
}
#endif

static inline bool cap_ambient_invariant_ok(const struct cred *cred)
{
return cap_issubset(cred->cap_ambient,
Expand Down Expand Up @@ -249,7 +202,6 @@ static inline const struct cred *get_cred(const struct cred *cred)
struct cred *nonconst_cred = (struct cred *) cred;
if (!cred)
return cred;
validate_creds(cred);
nonconst_cred->non_rcu = 0;
return get_new_cred(nonconst_cred);
}
Expand All @@ -261,7 +213,6 @@ static inline const struct cred *get_cred_rcu(const struct cred *cred)
return NULL;
if (!atomic_long_inc_not_zero(&nonconst_cred->usage))
return NULL;
validate_creds(cred);
nonconst_cred->non_rcu = 0;
return cred;
}
Expand All @@ -282,7 +233,6 @@ static inline void put_cred(const struct cred *_cred)
struct cred *cred = (struct cred *) _cred;

if (cred) {
validate_creds(cred);
if (atomic_long_dec_and_test(&(cred)->usage))
__put_cred(cred);
}
Expand Down
Loading

0 comments on commit 207f135

Please sign in to comment.