Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97b58fae authored by Al Viro's avatar Al Viro Committed by Greg Kroah-Hartman
Browse files

VT_RESIZEX: get rid of field-by-field copyin



[ Upstream commit 1b3bce4d6bf839304a90951b4b25a5863533bf2a ]

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c306a081
Loading
Loading
Loading
Loading
+27 −41
Original line number Original line Diff line number Diff line
@@ -850,58 +850,44 @@ int vt_ioctl(struct tty_struct *tty,


	case VT_RESIZEX:
	case VT_RESIZEX:
	{
	{
		struct vt_consize __user *vtconsize = up;
		struct vt_consize v;
		ushort ll,cc,vlin,clin,vcol,ccol;
		if (!perm)
		if (!perm)
			return -EPERM;
			return -EPERM;
		if (!access_ok(VERIFY_READ, vtconsize,
		if (copy_from_user(&v, up, sizeof(struct vt_consize)))
				sizeof(struct vt_consize))) {
			return -EFAULT;
			ret = -EFAULT;
			break;
		}
		/* FIXME: Should check the copies properly */
		/* FIXME: Should check the copies properly */
		__get_user(ll, &vtconsize->v_rows);
		if (!v.v_vlin)
		__get_user(cc, &vtconsize->v_cols);
			v.v_vlin = vc->vc_scan_lines;
		__get_user(vlin, &vtconsize->v_vlin);
		if (v.v_clin) {
		__get_user(clin, &vtconsize->v_clin);
			int rows = v.v_vlin/v.v_clin;
		__get_user(vcol, &vtconsize->v_vcol);
			if (v.v_rows != rows) {
		__get_user(ccol, &vtconsize->v_ccol);
				if (v.v_rows) /* Parameters don't add up */
		vlin = vlin ? vlin : vc->vc_scan_lines;
					return -EINVAL;
		if (clin) {
				v.v_rows = rows;
			if (ll) {
				if (ll != vlin/clin) {
					/* Parameters don't add up */
					ret = -EINVAL;
					break;
			}
			}
			} else 
				ll = vlin/clin;
		}
		}
		if (vcol && ccol) {
		if (v.v_vcol && v.v_ccol) {
			if (cc) {
			int cols = v.v_vcol/v.v_ccol;
				if (cc != vcol/ccol) {
			if (v.v_cols != cols) {
					ret = -EINVAL;
				if (v.v_cols)
					break;
					return -EINVAL;
				v.v_cols = cols;
			}
			}
			} else
				cc = vcol/ccol;
		}
		}


		if (clin > 32) {
		if (v.v_clin > 32)
			ret =  -EINVAL;
			return -EINVAL;
			break;
		}


		for (i = 0; i < MAX_NR_CONSOLES; i++) {
		for (i = 0; i < MAX_NR_CONSOLES; i++) {
			if (!vc_cons[i].d)
			if (!vc_cons[i].d)
				continue;
				continue;
			console_lock();
			console_lock();
			if (vlin)
			if (v.v_vlin)
				vc_cons[i].d->vc_scan_lines = vlin;
				vc_cons[i].d->vc_scan_lines = v.v_vlin;
			if (clin)
			if (v.v_clin)
				vc_cons[i].d->vc_font.height = clin;
				vc_cons[i].d->vc_font.height = v.v_clin;
			vc_cons[i].d->vc_resize_user = 1;
			vc_cons[i].d->vc_resize_user = 1;
			vc_resize(vc_cons[i].d, cc, ll);
			vc_resize(vc_cons[i].d, v.v_cols, v.v_rows);
			console_unlock();
			console_unlock();
		}
		}
		break;
		break;