Skip to content

Commit ae19141

Browse files
axboetorvalds
authored andcommitted
cred: get rid of CONFIG_DEBUG_CREDENTIALS
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>
1 parent f8fa5d7 commit ae19141

15 files changed

Lines changed: 17 additions & 313 deletions

File tree

arch/powerpc/configs/skiroot_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ CONFIG_WQ_WATCHDOG=y
301301
CONFIG_DEBUG_SG=y
302302
CONFIG_DEBUG_NOTIFIERS=y
303303
CONFIG_BUG_ON_DATA_CORRUPTION=y
304-
CONFIG_DEBUG_CREDENTIALS=y
305304
# CONFIG_FTRACE is not set
306305
CONFIG_XMON=y
307306
# CONFIG_RUNTIME_TESTING_MENU is not set

arch/s390/configs/debug_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@ CONFIG_DEBUG_IRQFLAGS=y
834834
CONFIG_DEBUG_LIST=y
835835
CONFIG_DEBUG_SG=y
836836
CONFIG_DEBUG_NOTIFIERS=y
837-
CONFIG_DEBUG_CREDENTIALS=y
838837
CONFIG_RCU_TORTURE_TEST=m
839838
CONFIG_RCU_REF_SCALE_TEST=m
840839
CONFIG_RCU_CPU_STALL_TIMEOUT=300

fs/nfsd/auth.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
2626
int i;
2727
int flags = nfsexp_flags(rqstp, exp);
2828

29-
validate_process_creds();
30-
3129
/* discard any old override before preparing the new set */
3230
revert_creds(get_cred(current_real_cred()));
3331
new = prepare_creds();
@@ -81,10 +79,8 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
8179
else
8280
new->cap_effective = cap_raise_nfsd_set(new->cap_effective,
8381
new->cap_permitted);
84-
validate_process_creds();
8582
put_cred(override_creds(new));
8683
put_cred(new);
87-
validate_process_creds();
8884
return 0;
8985

9086
oom:

fs/nfsd/nfssvc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ nfsd(void *vrqstp)
955955
rqstp->rq_server->sv_maxconn = nn->max_connections;
956956

957957
svc_recv(rqstp);
958-
validate_process_creds();
959958
}
960959

961960
atomic_dec(&nfsdstats.th_cnt);

fs/nfsd/vfs.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,6 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
901901
int host_err;
902902
bool retried = false;
903903

904-
validate_process_creds();
905904
/*
906905
* If we get here, then the client has already done an "open",
907906
* and (hopefully) checked permission - so allow OWNER_OVERRIDE
@@ -926,7 +925,6 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
926925
}
927926
err = nfserrno(host_err);
928927
}
929-
validate_process_creds();
930928
return err;
931929
}
932930

@@ -943,12 +941,7 @@ int
943941
nfsd_open_verified(struct svc_rqst *rqstp, struct svc_fh *fhp, int may_flags,
944942
struct file **filp)
945943
{
946-
int err;
947-
948-
validate_process_creds();
949-
err = __nfsd_open(rqstp, fhp, S_IFREG, may_flags, filp);
950-
validate_process_creds();
951-
return err;
944+
return __nfsd_open(rqstp, fhp, S_IFREG, may_flags, filp);
952945
}
953946

954947
/*

fs/open.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,6 @@ struct file *dentry_open(const struct path *path, int flags,
10881088
int error;
10891089
struct file *f;
10901090

1091-
validate_creds(cred);
1092-
10931091
/* We must always pass in a valid mount pointer. */
10941092
BUG_ON(!path->mnt);
10951093

@@ -1128,7 +1126,6 @@ struct file *dentry_create(const struct path *path, int flags, umode_t mode,
11281126
struct file *f;
11291127
int error;
11301128

1131-
validate_creds(cred);
11321129
f = alloc_empty_file(flags, cred);
11331130
if (IS_ERR(f))
11341131
return f;

include/linux/cred.h

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@ static inline int groups_search(const struct group_info *group_info, kgid_t grp)
110110
*/
111111
struct cred {
112112
atomic_long_t usage;
113-
#ifdef CONFIG_DEBUG_CREDENTIALS
114-
atomic_t subscribers; /* number of processes subscribed */
115-
void *put_addr;
116-
unsigned magic;
117-
#define CRED_MAGIC 0x43736564
118-
#define CRED_MAGIC_DEAD 0x44656144
119-
#endif
120113
kuid_t uid; /* real UID of the task */
121114
kgid_t gid; /* real GID of the task */
122115
kuid_t suid; /* saved UID of the task */
@@ -172,46 +165,6 @@ extern int cred_fscmp(const struct cred *, const struct cred *);
172165
extern void __init cred_init(void);
173166
extern int set_cred_ucounts(struct cred *);
174167

175-
/*
176-
* check for validity of credentials
177-
*/
178-
#ifdef CONFIG_DEBUG_CREDENTIALS
179-
extern void __noreturn __invalid_creds(const struct cred *, const char *, unsigned);
180-
extern void __validate_process_creds(struct task_struct *,
181-
const char *, unsigned);
182-
183-
extern bool creds_are_invalid(const struct cred *cred);
184-
185-
static inline void __validate_creds(const struct cred *cred,
186-
const char *file, unsigned line)
187-
{
188-
if (unlikely(creds_are_invalid(cred)))
189-
__invalid_creds(cred, file, line);
190-
}
191-
192-
#define validate_creds(cred) \
193-
do { \
194-
__validate_creds((cred), __FILE__, __LINE__); \
195-
} while(0)
196-
197-
#define validate_process_creds() \
198-
do { \
199-
__validate_process_creds(current, __FILE__, __LINE__); \
200-
} while(0)
201-
202-
extern void validate_creds_for_do_exit(struct task_struct *);
203-
#else
204-
static inline void validate_creds(const struct cred *cred)
205-
{
206-
}
207-
static inline void validate_creds_for_do_exit(struct task_struct *tsk)
208-
{
209-
}
210-
static inline void validate_process_creds(void)
211-
{
212-
}
213-
#endif
214-
215168
static inline bool cap_ambient_invariant_ok(const struct cred *cred)
216169
{
217170
return cap_issubset(cred->cap_ambient,
@@ -264,7 +217,6 @@ static inline const struct cred *get_cred_many(const struct cred *cred, int nr)
264217
struct cred *nonconst_cred = (struct cred *) cred;
265218
if (!cred)
266219
return cred;
267-
validate_creds(cred);
268220
nonconst_cred->non_rcu = 0;
269221
return get_new_cred_many(nonconst_cred, nr);
270222
}
@@ -290,7 +242,6 @@ static inline const struct cred *get_cred_rcu(const struct cred *cred)
290242
return NULL;
291243
if (!atomic_long_inc_not_zero(&nonconst_cred->usage))
292244
return NULL;
293-
validate_creds(cred);
294245
nonconst_cred->non_rcu = 0;
295246
return cred;
296247
}
@@ -312,7 +263,6 @@ static inline void put_cred_many(const struct cred *_cred, int nr)
312263
struct cred *cred = (struct cred *) _cred;
313264

314265
if (cred) {
315-
validate_creds(cred);
316266
if (atomic_long_sub_and_test(nr, &cred->usage))
317267
__put_cred(cred);
318268
}

0 commit comments

Comments
 (0)