Commit 7911b650 authored by Benjamin Berg's avatar Benjamin Berg Committed by Johannes Berg
Browse files

um: remove LDT support



The current LDT code has a few issues that mean it should be redone in a
different way once we always start with a fresh MM even when cloning.

In a new and better world, the kernel would just ensure its own LDT is
clear at startup. At that point, all that is needed is a simple function
to populate the LDT from another MM in arch_dup_mmap combined with some
tracking of the installed LDT entries for each MM.

Note that the old implementation was even incorrect with regard to
reading, as it copied out the LDT entries in the internal format rather
than converting them to the userspace structure.

Removal should be fine as the LDT is not used for thread-local storage
anymore.

Signed-off-by: default avatarBenjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20240703134536.1161108-7-benjamin@sipsolutions.net


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 6d8992e4
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -7,15 +7,9 @@
#define __ARCH_UM_MMU_H

#include <mm_id.h>
#include <asm/mm_context.h>

typedef struct mm_context {
	struct mm_id id;
	struct uml_arch_mm_context arch;
} mm_context_t;

/* Avoid tangled inclusion with asm/ldt.h */
extern long init_new_ldt(struct mm_context *to_mm, struct mm_context *from_mm);
extern void free_ldt(struct mm_context *mm);

#endif
+7 −14
Original line number Diff line number Diff line
@@ -20,11 +20,9 @@ enum stub_syscall_type {
	STUB_SYSCALL_MMAP,
	STUB_SYSCALL_MUNMAP,
	STUB_SYSCALL_MPROTECT,
	STUB_SYSCALL_LDT,
};

struct stub_syscall {
	union {
	struct {
		unsigned long addr;
		unsigned long length;
@@ -32,11 +30,6 @@ struct stub_syscall {
		int fd;
		int prot;
	} mem;
		struct {
			user_desc_t desc;
			int func;
		} ldt;
	};

	enum stub_syscall_type syscall;
};
+0 −8
Original line number Diff line number Diff line
@@ -46,13 +46,6 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
		goto out_free;
	}

	ret = init_new_ldt(to_mm, from_mm);
	if (ret < 0) {
		printk(KERN_ERR "init_new_context_skas - init_ldt"
		       " failed, errno = %d\n", ret);
		goto out_free;
	}

	return 0;

 out_free:
@@ -80,5 +73,4 @@ void destroy_context(struct mm_struct *mm)
	os_kill_ptraced_process(mmu->id.u.pid, 1);

	free_pages(mmu->id.stack, ilog2(STUB_DATA_PAGES));
	free_ldt(mmu);
}
+0 −11
Original line number Diff line number Diff line
@@ -45,17 +45,6 @@ static __always_inline int syscall_handler(struct stub_data *d)
				return -1;
			}
			break;
		case STUB_SYSCALL_LDT:
			res = stub_syscall3(__NR_modify_ldt, sc->ldt.func,
					    (unsigned long) &sc->ldt.desc,
					    sizeof(sc->ldt.desc));
			/* We only write, so the expected result is zero */
			if (res) {
				d->err = res;
				d->syscall_data_len = i;
				return -1;
			}
			break;
		default:
			d->err = -95; /* EOPNOTSUPP */
			d->syscall_data_len = i;
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <asm/ldt.h>
#include <asm/unistd.h>
#include <init.h>
#include <os.h>
Loading