View | Details | Raw Unified | Return to bug 195453
Collapse All | Expand All

(-)a/fs/exec.c (-3 / +11 lines)
Lines 1431-1436 static void check_unsafe_exec(struct linux_binprm *bprm) Link Here
1431
{
1431
{
1432
	struct task_struct *p = current, *t;
1432
	struct task_struct *p = current, *t;
1433
	unsigned n_fs;
1433
	unsigned n_fs;
1434
	bool fs_recheck;
1434
1435
1435
	if (p->ptrace)
1436
	if (p->ptrace)
1436
		bprm->unsafe |= LSM_UNSAFE_PTRACE;
1437
		bprm->unsafe |= LSM_UNSAFE_PTRACE;
Lines 1442-1447 static void check_unsafe_exec(struct linux_binprm *bprm) Link Here
1442
	if (task_no_new_privs(current))
1443
	if (task_no_new_privs(current))
1443
		bprm->unsafe |= LSM_UNSAFE_NO_NEW_PRIVS;
1444
		bprm->unsafe |= LSM_UNSAFE_NO_NEW_PRIVS;
1444
1445
1446
recheck:
1447
	fs_recheck = false;
1445
	t = p;
1448
	t = p;
1446
	n_fs = 1;
1449
	n_fs = 1;
1447
	spin_lock(&p->fs->lock);
1450
	spin_lock(&p->fs->lock);
Lines 1449-1460 static void check_unsafe_exec(struct linux_binprm *bprm) Link Here
1449
	while_each_thread(p, t) {
1452
	while_each_thread(p, t) {
1450
		if (t->fs == p->fs)
1453
		if (t->fs == p->fs)
1451
			n_fs++;
1454
			n_fs++;
1455
		if (t->flags & (PF_EXITING | PF_FORKNOEXEC))
1456
			fs_recheck  = true;
1452
	}
1457
	}
1453
	rcu_read_unlock();
1458
	rcu_read_unlock();
1454
1459
1455
	if (p->fs->users > n_fs)
1460
	if (p->fs->users > n_fs) {
1461
		if (fs_recheck) {
1462
			spin_unlock(&p->fs->lock);
1463
			goto recheck;
1464
		}
1456
		bprm->unsafe |= LSM_UNSAFE_SHARE;
1465
		bprm->unsafe |= LSM_UNSAFE_SHARE;
1457
	else
1466
	} else
1458
		p->fs->in_exec = 1;
1467
		p->fs->in_exec = 1;
1459
	spin_unlock(&p->fs->lock);
1468
	spin_unlock(&p->fs->lock);
1460
}
1469
}
1461
- 

Return to bug 195453