From nobody Wed Feb 08 22:14:09 2023 X-Original-To: dev-commits-src-all@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 4PBvRS1yPBz3n0H1; Wed, 8 Feb 2023 22:14:12 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) (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 4PBvRR3JMGz3tFl; Wed, 8 Feb 2023 22:14:11 +0000 (UTC) (envelope-from mjguzik@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b="bX5/piS7"; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2001:4860:4864:20::2f as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-15f97c478a8so262355fac.13; Wed, 08 Feb 2023 14:14:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=QJ5renevzOhfLmniBce04Dfa3D6OqSrg0QDPyUrFEJ8=; b=bX5/piS79juoCoubyj5dIdzV1NodT7rTd/95yHXdpR+DfpytriWufvwiMSx7gMMPP5 sMdfrYTNjfO23upxKsbek26VAIt/gx//FtwqpzsvDw2HkyfSLf+U01u/+m4eyAjT/U+x hMtmVBBGI8hR/D4PBjRIiFks1i0EoyqyG0iQw6gudPiE8Xeb/UauJl80Ue67LfQnHTy9 EQixPwWfAnjDcW8ivQ+8+gA8qQcTlwtRuFRIvIXh7nAx4KLEj2jL3M6dISTtUp6tOlyp 9Skx3lBxKrlSD1QXKRJfv/Envdl+5CBGEPnjyl8mJ6cEap3F5YRrykk2hag0qCnIOn53 AUpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QJ5renevzOhfLmniBce04Dfa3D6OqSrg0QDPyUrFEJ8=; b=N6/o6XWkhLLNyZXf7ie9ns8aFBR/Dds7MbxeUjYbDfs7sKROaYZfbxwIIIdKDZg34o rLTgVapPSYuO6nKtP4MnZq01R31C8CKnv4hEYyJD4epLFfDK6ll8Cpr1Q587HNK99/Gd Ueai5Q4/4Eg1/OjdL7MqHdos20x2G3pmGu7CMN59l2pmpCdd9k8AThEXBrevDA+4DDQ6 2JxG0TrT9R9EdItd8H8cyDcNcQPbKahA2Zu4f194vRqYXhAVYZcyz16MiqHyxtYvn3Od MmbsSjcovke+KPgQgBMvi0l4XtqBL0Ry2LL2bbWskf/bYWks3r2+uzpBZSO4+vHgQnbm xlIw== X-Gm-Message-State: AO0yUKXSwYfzcM42WBqqqhPoGRL6quJGiSAOAM21zl51H/2SEjSt0Lre mq7Anpx0L7ruaherk/2XHw5UqRRdDJWBycxUbVp8vA/2 X-Google-Smtp-Source: AK7set8+q+miB61WrmwySgRyaZXJN9GEIoY9+vl4x9R3K4aWzzAecT3Cof8sUwFBcCescGfNCnA0bImviCJhQIO3Szw= X-Received: by 2002:a05:6870:1257:b0:16a:9099:3868 with SMTP id 23-20020a056870125700b0016a90993868mr406490oao.81.1675894450145; Wed, 08 Feb 2023 14:14:10 -0800 (PST) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Received: by 2002:ac9:6c92:0:b0:4b3:d953:974c with HTTP; Wed, 8 Feb 2023 14:14:09 -0800 (PST) In-Reply-To: <202302072011.317KBmsS036242@gitrepo.freebsd.org> References: <202302072011.317KBmsS036242@gitrepo.freebsd.org> From: Mateusz Guzik Date: Wed, 8 Feb 2023 23:14:09 +0100 Message-ID: Subject: Re: git: 27202b98dc2d - main - jail: Use atomic(9) instead of CK atomics To: Mark Johnston Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Spamd-Result: default: False [-3.26 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-0.26)[-0.256]; R_SPF_ALLOW(-0.20)[+ip6:2001:4860:4000::/36:c]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2001:4860:4864::/48, country:US]; RCVD_IN_DNSWL_NONE(0.00)[2001:4860:4864:20::2f:from]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-Rspamd-Queue-Id: 4PBvRR3JMGz3tFl X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N On 2/7/23, Mark Johnston wrote: > The branch main has been updated by markj: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=27202b98dc2d3361f4b5395a93488fc60c3f9af9 > > commit 27202b98dc2d3361f4b5395a93488fc60c3f9af9 > Author: Mark Johnston > AuthorDate: 2023-02-07 19:35:44 +0000 > Commit: Mark Johnston > CommitDate: 2023-02-07 20:10:24 +0000 > > jail: Use atomic(9) instead of CK atomics > > There's no reason to use one over the other here, let's prefer the > interface that's used elsewhere in the kernel. > > No functional change intended. > > Reviewed by: mjg > Sponsored by: Klara, Inc. > Differential Revision: https://reviews.freebsd.org/D38360 > --- > sys/kern/kern_jail.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c > index 4c1e3ff40c58..75be0df85448 100644 > --- a/sys/kern/kern_jail.c > +++ b/sys/kern/kern_jail.c > @@ -771,7 +771,7 @@ prison_ip_set(struct prison *pr, const pr_family_t af, > struct prison_ip *new) > mem = &pr->pr_addrs[af]; > > old = *mem; > - ck_pr_store_ptr(mem, new); > + atomic_store_ptr(mem, new); > prison_ip_free(old); > } > > @@ -897,7 +897,7 @@ prison_ip_check(const struct prison *pr, const > pr_family_t af, > in_epoch(net_epoch_preempt) || > sx_xlocked(&allprison_lock)); > > - pip = ck_pr_load_ptr(&pr->pr_addrs[af]); > + pip = atomic_load_ptr(&pr->pr_addrs[af]); > if (__predict_false(pip == NULL)) > return (EAFNOSUPPORT); > > so apparently this breaks kasan builds: /usr/src/sys/kern/kern_jail.c:900:8: error: cast from 'struct prison_ip *const *' to 'volatile unsigned long *' drops const qualifier [-Werror,-Wcast-qual] pip = atomic_load_ptr(&pr->pr_addrs[af]); ^ /usr/src/sys/sys/atomic_san.h:272:64: note: expanded from macro 'atomic_load_ptr' __retptr = (void *)ATOMIC_SAN(load_ptr)((volatile uintptr_t *)(x)); \ ^ /usr/src/sys/kern/kern_jail.c:900:8: error: cannot assign to variable '__retptr' with const-qualified type 'typeof (*&pr->pr_addrs[af])' (aka 'struct prison_ip *const') pip = atomic_load_ptr(&pr->pr_addrs[af]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/src/sys/sys/atomic_san.h:272:11: note: expanded from macro 'atomic_load_ptr' __retptr = (void *)ATOMIC_SAN(load_ptr)((volatile uintptr_t *)(x)); \ ~~~~~~~~ ^ /usr/src/sys/kern/kern_jail.c:900:8: note: variable '__retptr' declared const here pip = atomic_load_ptr(&pr->pr_addrs[af]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/src/sys/sys/atomic_san.h:271:15: note: expanded from macro 'atomic_load_ptr' __typeof(*x) __retptr; \ ~~~~~~~~~~~~~^~~~~~~~ 2 errors generated. -- Mateusz Guzik