From nobody Sun Dec 05 03:03:26 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 BB0CB1837D45 for ; Sun, 5 Dec 2021 03:03:34 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J6BGG3mQmz3K05 for ; Sun, 5 Dec 2021 03:03:34 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f48.google.com with SMTP id j3so14579874wrp.1 for ; Sat, 04 Dec 2021 19:03:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=AwMzn6sUFdZpzEPrKC/RZmJVHLv0UzJFNKy6b+HHe88=; b=5tyiZFFYKAa/gbw4ID10RaoRO4PNTf4NO0orA6WmIifnr5KjdBtgMAfDslcEkwFO6N J8Gim7jwwks6T1A6f5vzce3DMt5CCercmbZoKc4YmgI8c8zsF/71r7D4azNz4ZYasoGn z4fXV0H5orbbKp2hAR7vxmF9WrQ5JfNaEjgE5QZdIpBSUKMog+lseA0hZwaYSx/Ciu1R noCJzDeNciGFf0dAnuBkyG1N35Ufa4sdnUcR0vot0NY5RHS05s9/E0VTNy7um3SOm5sE emzCfMasXdgCY8X4EkWrj7s6d/OuFBh9CAwfULtfKiRJiq2z+h7ld5qO0rMEMsljd2XL sUkQ== X-Gm-Message-State: AOAM533PtDkMI4s2zhmzh/cvcMNGo5F9e0q/D+pO5sysLyY/gin7zGTN NTF8gRNVD6gNl74MvDqKR6NYKg== X-Google-Smtp-Source: ABdhPJyKJylXbaRFIPI104yo/AV9/vAlBfZ2aDhyQyn6tpTu4JalYC//t4wxqERVRQ3t0T4rIXqD1Q== X-Received: by 2002:adf:8b1e:: with SMTP id n30mr32647104wra.75.1638673407382; Sat, 04 Dec 2021 19:03:27 -0800 (PST) Received: from smtpclient.apple (global-5-141.nat-2.net.cam.ac.uk. [131.111.5.141]) by smtp.gmail.com with ESMTPSA id l4sm6881366wrv.94.2021.12.04.19.03.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Dec 2021 19:03:27 -0800 (PST) Content-Type: text/plain; charset=utf-8 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 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: git: a4e4132fa3bf - main - swapoff(2): replace special device name argument with a structure From: Jessica Clarke In-Reply-To: <202112042221.1B4ML7Ov002151@gitrepo.freebsd.org> Date: Sun, 5 Dec 2021 03:03:26 +0000 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <202112042221.1B4ML7Ov002151@gitrepo.freebsd.org> To: Konstantin Belousov X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Rspamd-Queue-Id: 4J6BGG3mQmz3K05 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On 4 Dec 2021, at 22:21, Konstantin Belousov wrote: >=20 > The branch main has been updated by kib: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3Da4e4132fa3bfadb6047fc0fa5f399f46= 40460300 >=20 > commit a4e4132fa3bfadb6047fc0fa5f399f4640460300 > Author: Konstantin Belousov > AuthorDate: 2021-11-29 16:26:31 +0000 > Commit: Konstantin Belousov > CommitDate: 2021-12-04 22:20:58 +0000 >=20 > swapoff(2): replace special device name argument with a structure >=20 > 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. >=20 > 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(-) >=20 > 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; >=20 > error =3D priv_check(td, PRIV_SWAPOFF); > if (error) > return (error); >=20 > + /* > + * 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 =3D fubyte(uap->name); > + switch (probe_byte) { > + case -1: > + return (EFAULT); > + case 0: > + error =3D copyin(uap->name, &sa, sizeof(sa)); > + if (error !=3D 0) > + return (error); > + if (sa.flags !=3D 0) > + return (EINVAL); > + break; > + default: > + bzero(&sa, sizeof(sa)); > + sa.name =3D uap->name; > + break; > + } Doesn=E2=80=99t this change the semantics of swapoff("")? Previously it would fail deterministically, presumably with ENOENT or something, but now it reinterprets whatever follows that string in memory as the new argument structure. It probably doesn=E2=80=99t = matter, but this approach is ugly. Can we not just define a new syscall rather than this kind of bodge? Jess