From nobody Sat Dec 04 22:21:07 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 32820189D426; Sat, 4 Dec 2021 22:21:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J640M54kyz3tXl; Sat, 4 Dec 2021 22:21:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F4944825; Sat, 4 Dec 2021 22:21:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B4ML7pF002152; Sat, 4 Dec 2021 22:21:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B4ML7Ov002151; Sat, 4 Dec 2021 22:21:07 GMT (envelope-from git) Date: Sat, 4 Dec 2021 22:21:07 GMT Message-Id: <202112042221.1B4ML7Ov002151@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a4e4132fa3bf - main - swapoff(2): replace special device name argument with a structure List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a4e4132fa3bfadb6047fc0fa5f399f4640460300 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638656467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yQF7ZdHVO5vVgoe+vAdMgBelJCrk0ea2pPlnT98v7oo=; b=wDxpIu8edLqdMdyNYm9WQCA2qXdlUslppXTo+RmnVJTFZQiJBRZdubKBCcywkQVhQxU8Xg 5L5KgSyuuwc8P3EAK+tPgJrvNnglkhn2dqv7zSsXLEpSDTUrb3n9BaxYyzr7imGIxXavw3 cszfJT8SbVjg5hNMGdqcoDdpE/p7M+lrFPQBNX9uQi1wFcztiIGshT1+uUkbvpba5Yvxom +hqqTE8zfRhpDXMqlle02CEjh098cLtGGufZgy76LX8Ul0DeKpuEGIOi4xtQEWMSF3r359 X+6oNUBPPHBzbctr26n6TK0QvSAcLtUfWphAQMjEQS1KoVpN1CGC8MJ7tZ45Ew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638656467; a=rsa-sha256; cv=none; b=pDNL74Aq1OXv5NS6Maz3nkzpvmozTzBNvRu8TZbbMg6DSTxulXhpereyqAPKJtd+3K+0uh vZjQhsNJTYuV9xngeYkJHHRktbKJbBsMqq4mVNnxQnlcmeim+MQzhHIQ76fB14SEWwm5QJ Uluo/H5hiG9cM+/GfI+boa/ASLZUw0TCIVgCC1g2fQ7hFjAlkUPmxgzj1j9T5rpDhOqslW 0VUkSOuXUO9/Z+J5kZhTBcQVOA8J9SxMHicYdDLMFNNWypfPY+oKIxQjOHbRcax+nATOAw LnxGaBNNV05zmVaMqEz8NaUbD11wT4fHS3AS5fajmVwvP4mLK9AFkWCdJLBXJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a4e4132fa3bfadb6047fc0fa5f399f4640460300 commit a4e4132fa3bfadb6047fc0fa5f399f4640460300 Author: Konstantin Belousov AuthorDate: 2021-11-29 16:26:31 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-04 22:20:58 +0000 swapoff(2): replace special device name argument with a structure For compatibility, add a placeholder pointer to the start of the added struct swapoff_new_args, and use it to distinguish old vs. new style of syscall invocation. Reviewed by: markj Discussed with: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33165 --- sys/vm/swap_pager.c | 27 +++++++++++++++++++++++++-- sys/vm/swap_pager.h | 8 ++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 165373d1b527..dc1df79f4fcd 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -2491,15 +2491,38 @@ sys_swapoff(struct thread *td, struct swapoff_args *uap) struct vnode *vp; struct nameidata nd; struct swdevt *sp; - int error; + struct swapoff_new_args sa; + int error, probe_byte; error = priv_check(td, PRIV_SWAPOFF); if (error) return (error); + /* + * Detect old vs. new-style swapoff(2) syscall. The first + * pointer in the memory pointed to by uap->name is NULL for + * the new variant. + */ + probe_byte = fubyte(uap->name); + switch (probe_byte) { + case -1: + return (EFAULT); + case 0: + error = copyin(uap->name, &sa, sizeof(sa)); + if (error != 0) + return (error); + if (sa.flags != 0) + return (EINVAL); + break; + default: + bzero(&sa, sizeof(sa)); + sa.name = uap->name; + break; + } + sx_xlock(&swdev_syscall_lock); - NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->name); + NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, sa.name); error = namei(&nd); if (error) goto done; diff --git a/sys/vm/swap_pager.h b/sys/vm/swap_pager.h index 395fbc9957c4..469de3e8eaf4 100644 --- a/sys/vm/swap_pager.h +++ b/sys/vm/swap_pager.h @@ -69,6 +69,14 @@ struct swdevt { #define SW_UNMAPPED 0x01 #define SW_CLOSING 0x04 +struct swapoff_new_args { + const char *name_old_syscall; + const char *name; + u_int flags; + u_int pad0; + uintptr_t pad1[8]; +}; + #ifdef _KERNEL extern int swap_pager_avail;