Compare commits

...

13 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
782e8b7a14
version 3.2.7 2018-02-20 00:15:54 +01:00
Marek Marczykowski-Górecki
f88170ba6f
debian: adjust required version after adding new function 2018-02-20 00:15:32 +01:00
Marek Marczykowski-Górecki
5440e323aa
qrexec: provide common function for handling service call
Reduce code duplication by moving parsing of "QUBESRPC" magic command to
one place.
Call qubes-rpc-multiplexer directly with execve(), to avoid string
expansions in its parameters.

(cherry picked from commit 50412a8a8f)
2018-02-19 02:36:23 +01:00
Marek Marczykowski-Górecki
51f22438c9
version 3.2.6 2018-01-13 03:35:31 +01:00
HW42
7e6bee6281 u2mfn: get mfn via pte
Before this commit u2mfn got the address via kmap(get_user_pages(...)).
This has the problem that get_user_pages() does not work in some cases.
For example when qemu in a stubdom tries to get the mfn for a page which
is mapped from the target domain u2mfn fails because get_user_pages()
cannot be used for such mappings.

So get the address from the pte with apply_to_page_range(). Since we are
only interested in one page get_locked_pte() would be simpler but it's
not available to modules.
2018-01-08 04:17:32 +01:00
Marek Marczykowski-Górecki
7458893b8f
version 3.2.5 2017-09-24 21:54:29 +02:00
Marek Marczykowski-Górecki
dd2fce0e1b
travis: add fc25 and fc26 build targets 2017-09-24 21:24:28 +02:00
Paras Chetal
d81acf81d4
Fix include header syntax
(cherry picked from commit e9b8e5a4d1)
2017-09-24 21:18:12 +02:00
Marek Marczykowski-Górecki
5428ce06ee
initramfs: move qubes_cow_setup hook to pre-trigger
This hook require new device nodes to appear in /dev. If devtmpfs is
used, it's not a problem ("simple" initramfs case), but otherwise udevd
is needed - and it isn't running in pre-udev hook yet.

QubesOS/qubes-issues#2577

(cherry picked from commit 5c7c54adab)
2017-09-24 21:16:23 +02:00
Olivier MEDOC
ea0c714139 Fix gcc Werror because of a typo in a switch/case explicit fallthrough comment
GCC crash because of -Werror=implicit-fallthrough. However the fallthrough exists but has a typo.

Thanks for omac777 analysis (7d0b8155a3)

However the fallthrough exists but has a typo
2017-09-12 21:05:40 +02:00
Rusty Bird
0677fce533
Fall back to sync() if syncfs() is unavailable
It seems better to err on the side of safety (vs. performance).

(cherry picked from commit 90a1e6abbd)
2017-07-04 13:30:18 +02:00
Marek Marczykowski-Górecki
7e42fb5efd
rpm: add missing build requires
(cherry picked from commit ae56d597f3)
2017-04-21 16:55:41 +02:00
unman
d359d63fd6
Improve error message when file exists
(cherry picked from commit 1db0daea9c)
Notes from origin:
    Fixes QubesOS/qubes-issues#1240
2017-04-21 16:15:31 +02:00
14 changed files with 100 additions and 31 deletions

View File

@ -7,5 +7,7 @@ env:
- DIST_DOM0=fc23 USE_QUBES_REPO_VERSION=3.2 USE_QUBES_REPO_TESTING=1
- DISTS_VM=fc23 USE_QUBES_REPO_VERSION=3.2 USE_QUBES_REPO_TESTING=1
- DISTS_VM=fc24 USE_QUBES_REPO_VERSION=3.2 USE_QUBES_REPO_TESTING=1
- DISTS_VM=fc25 USE_QUBES_REPO_VERSION=3.2 USE_QUBES_REPO_TESTING=1
- DISTS_VM=fc26 USE_QUBES_REPO_VERSION=3.2 USE_QUBES_REPO_TESTING=1
- DISTS_VM=jessie USE_QUBES_REPO_VERSION=3.2 USE_QUBES_REPO_TESTING=1
- DISTS_VM=stretch USE_QUBES_REPO_VERSION=3.2 USE_QUBES_REPO_TESTING=1

40
debian/changelog vendored
View File

@ -1,3 +1,43 @@
qubes-utils (3.2.7) unstable; urgency=medium
* qrexec: provide common function for handling service call
* debian: adjust required version after adding new function
-- Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Tue, 20 Feb 2018 00:15:54 +0100
qubes-utils (3.2.6) unstable; urgency=medium
[ HW42 ]
* u2mfn: get mfn via pte
-- Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Sat, 13 Jan 2018 03:35:31 +0100
qubes-utils (3.2.5) unstable; urgency=medium
[ unman ]
* Improve error message when file exists
[ Marek Marczykowski-Górecki ]
* rpm: add missing build requires
[ Rusty Bird ]
* Fall back to sync() if syncfs() is unavailable
[ Olivier MEDOC ]
* Fix gcc Werror because of a typo in a switch/case explicit
fallthrough comment
[ Marek Marczykowski-Górecki ]
* initramfs: move qubes_cow_setup hook to pre-trigger
[ Paras Chetal ]
* Fix include header syntax
[ Marek Marczykowski-Górecki ]
* travis: add fc25 and fc26 build targets
-- Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Sun, 24 Sep 2017 21:54:29 +0200
qubes-utils (3.2.4) unstable; urgency=medium
[ Johanna A ]

View File

@ -1 +1 @@
libqrexec-utils 2 libqrexec-utils2 (>= 3.1.3)
libqrexec-utils 2 libqrexec-utils2 (>= 3.2.7)

View File

@ -14,7 +14,7 @@ depends() {
}
install() {
inst_hook pre-udev 90 $moddir/qubes_cow_setup.sh
inst_hook pre-trigger 90 $moddir/qubes_cow_setup.sh
inst_multiple \
sfdisk \
mkswap

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# This file should be placed in pre-mount directory in dracut's initramfs, or
# This file should be placed in pre-trigger directory in dracut's initramfs, or
# scripts/local-top in case of initramfs-tools
#

View File

@ -83,7 +83,6 @@ if ! [ -d "$NEWROOT/lib/modules/$kver/kernel" ]; then
rmdir /tmp/modules
fi
umount /dev /sys /proc
exec switch_root $NEWROOT /sbin/init

View File

@ -54,6 +54,11 @@ static inline unsigned long VIRT_TO_MFN(void *addr)
}
#endif
static int u2mfn_get_mfn(pte_t *pte, pgtable_t token, unsigned long addr, void *data) {
*((unsigned long *) data) = pfn_to_mfn(pte_pfn(*pte));
return 0;
}
/// User virtual address to mfn translator
/**
\param cmd ignored
@ -63,9 +68,8 @@ static inline unsigned long VIRT_TO_MFN(void *addr)
static long u2mfn_ioctl(struct file *f, unsigned int cmd,
unsigned long data)
{
struct page *user_page;
void *kaddr;
long ret;
unsigned long mfn;
if (_IOC_TYPE(cmd) != U2MFN_MAGIC) {
printk("Qubes u2mfn: wrong IOCTL magic");
@ -74,26 +78,15 @@ static long u2mfn_ioctl(struct file *f, unsigned int cmd,
switch (cmd) {
case U2MFN_GET_MFN_FOR_PAGE:
down_read(&current->mm->mmap_sem);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
ret = get_user_pages
(data, 1, (FOLL_WRITE | FOLL_FORCE), &user_page, 0);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
ret = get_user_pages
(data, 1, 1, 0, &user_page, 0);
#else
ret = get_user_pages
(current, current->mm, data, 1, 1, 0, &user_page, 0);
#endif
up_read(&current->mm->mmap_sem);
if (ret != 1) {
printk("U2MFN_GET_MFN_FOR_PAGE: get_user_pages failed, ret=0x%lx\n", ret);
ret = apply_to_page_range(current->mm, data, PAGE_SIZE, u2mfn_get_mfn, &mfn);
if (ret < 0 || mfn == INVALID_P2M_ENTRY) {
printk("U2MFN_GET_MFN_FOR_PAGE: failed to get mfn, "
"addr=0x%lx ret=0x%lx\n", data, ret);
return -1;
}
kaddr = kmap(user_page);
ret = VIRT_TO_MFN(kaddr);
kunmap(user_page);
put_page(user_page);
ret = mfn;
break;
case U2MFN_GET_LAST_MFN:

View File

@ -1,5 +1,5 @@
#include <unistd.h>
#include <ioall.h>
#include "ioall.h"
#include "libqubes-rpc-filecopy.h"
#include "crc32.h"

View File

@ -24,6 +24,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "qrexec.h"
#include "libqrexec-utils.h"
static do_exec_t *exec_func = NULL;
@ -31,6 +33,29 @@ void register_exec_func(do_exec_t *func) {
exec_func = func;
}
void exec_qubes_rpc_if_requested(char *prog, char *const envp[]) {
/* avoid calling qubes-rpc-multiplexer through shell */
if (strncmp(prog, RPC_REQUEST_COMMAND, RPC_REQUEST_COMMAND_LEN) == 0) {
char *tok;
char *argv[16]; // right now 6 are used, but allow future extensions
size_t i = 0;
tok=strtok(prog, " ");
do {
if (i >= sizeof(argv)/sizeof(argv[0])-1) {
fprintf(stderr, "To many arguments to %s\n", RPC_REQUEST_COMMAND);
exit(1);
}
argv[i++] = tok;
} while ((tok=strtok(NULL, " ")));
argv[i] = NULL;
argv[0] = QUBES_RPC_MULTIPLEXER_PATH;
execve(QUBES_RPC_MULTIPLEXER_PATH, argv, envp);
perror("exec qubes-rpc-multiplexer");
exit(1);
}
}
void fix_fds(int fdin, int fdout, int fderr)
{
int i;
@ -68,7 +93,7 @@ void do_fork_exec(const char *cmdline, int *pid, int *stdin_fd, int *stdout_fd,
fix_fds(inpipe[0], outpipe[1], 2);
if (exec_func != NULL)
exec_func(cmdline);
exec_func((char*)cmdline);
exit(-1);
default:;
}

View File

@ -33,8 +33,14 @@ struct buffer {
#define WRITE_STDIN_BUFFERED 1 /* something still in the buffer */
#define WRITE_STDIN_ERROR 2 /* write error, errno set */
typedef void (do_exec_t)(const char *);
typedef void (do_exec_t)(char *);
void register_exec_func(do_exec_t *func);
/*
* exec() qubes-rpc-multiplexer if *prog* starts with magic "QUBESRPC" keyword,
* do not return in that case; pass *envp* to execve() as en environment
* otherwise, return false without any action
*/
void exec_qubes_rpc_if_requested(char *prog, char *const envp[]);
void buffer_init(struct buffer *b);
void buffer_free(struct buffer *b);

View File

@ -89,7 +89,7 @@ void wait_for_result(void)
if (hdr.error_code != 0) {
switch (hdr.error_code) {
case EEXIST:
call_error_handler("File copy: not overwriting existing file. Clean QubesIncoming dir, and retry copy%s%s", last_filename_prefix, last_filename);
call_error_handler("A file named %s already exists in QubesIncoming dir", last_filename);
break;
case EINVAL:
call_error_handler("File copy: Corrupted data from packer%s%s", last_filename_prefix, last_filename);
@ -100,7 +100,7 @@ void wait_for_result(void)
* desynchronized in this case */
return;
}
/* fall though */
/* fallthrough */
default:
call_error_handler("File copy: %s%s%s",
strerror(hdr.error_code), last_filename_prefix, last_filename);

View File

@ -1,6 +1,5 @@
#define _GNU_SOURCE /* For O_NOFOLLOW. */
#include <errno.h>
#include <ioall.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/stat.h>
@ -10,6 +9,7 @@
#include <stdio.h>
#include <limits.h>
#include "libqubes-rpc-filecopy.h"
#include "ioall.h"
#include "crc32.h"
char untrusted_namebuf[MAX_PATH_LENGTH];
@ -237,6 +237,8 @@ int do_unpack(void)
cwd_fd = open(".", O_RDONLY);
if (cwd_fd >= 0 && syncfs(cwd_fd) == 0 && close(cwd_fd) == 0)
errno = saved_errno;
#else
sync();
#endif
send_status_and_crc(errno, untrusted_namebuf);

View File

@ -19,6 +19,8 @@ Requires: %{name}-libs
Requires: ImageMagick
Requires: pycairo
BuildRequires: qubes-libvchan-devel
# for meminfo-writer
BuildRequires: xen-devel
%description
Common Linux files for Qubes Dom0 and VM

View File

@ -1 +1 @@
3.2.4
3.2.7