From nobody Thu Jan 04 17:03:10 2024 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 4T5XwG41Lkz56nF8; Thu, 4 Jan 2024 17:03:10 +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 4T5XwG37pjz4dWR; Thu, 4 Jan 2024 17:03:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704387790; 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=V+aCKuCGht4rmh2yhbQf0gaa4oxd+UtYTqLcsfm+rDg=; b=P4uRiO8FsBrzcHHtkOakxGSJGQuKFdQYEcs5WUT4MTGnFty7kZPnkRT5/5iRkwVozbhyQ9 kiN5FO+3j29pteJN/fvlYKByGX2lq7uR5FXyKhj5mcihsYYflpC+LYYHh7LegsCjnU/C3R EmMqwUfvEvAyHsPPVWVrjgPP7rAkUNI21RfXa/V3sxiNxBQA9L3F/Ih5bFWaF8fn31OT5q nicptxWRqQIMtw3crCF6rOn1XyDASyNZvKgg2JwW6CMzzcAZZtA3Iu/Iwx9S2KCOJVirH8 fDA/TolqyjQr+XNJk/TPXeNf5GdNXp0lxFEHlzHyw4gi86XjfDTLzZlLOO3wHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704387790; 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=V+aCKuCGht4rmh2yhbQf0gaa4oxd+UtYTqLcsfm+rDg=; b=pNrnK5KVJWzdHiGYtzvXtBwrdaj7sG+RV+o4X2IqqhhHyVPALKQbQWEVC4/vT1XNAArynl VRxJwpGlWEf5WYOMk8cOxpfQXk8HJ0J9kCSaNFjEgB+fCvBQ1B1RqiRJF4ncX+W0KZ5sai 2ISernQH53Lr+qi+6432jbQKSLGruaNrRPOBO/3M7tWvV2DNMlXHMRkl1NLhMWmDcnOv9I azaqDOJVAVSPupyaHtlMCTnz18HVNHUKoNv5k9rozmplSmzxRq0kcOqXTTZ5tVBatbdIdP BY/8FrmVCL6xJODl8XV2Cz4tIYckGuXd7mefjlolUzRx5eJvpYaQaEOGAog67g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704387790; a=rsa-sha256; cv=none; b=Th4VQALAqBQBjbN5lG92HcZ79/HB+DxvsWWWjPUKreCSWugWB5d20nSfiqz+MRa2HHLflx pN7qR6s+d6dCwmZ9JVGefL/j9X+82/W31fPtAXLl6bdpa/l/jdZlNhBAeIEWxBBmIc6dfn HG1QohuIJwLTZQSN2iW3YEhsupiP5KD8Ibsk1FQD1crvukRZNeZ1K7GuwJUvwsx+BzdybZ 2IvcxAHakv2oUFWDGlPoPncNtyCAxSwBsJk55E0i0oCVDfqY59TE2gsYYZ1DrwYfFzXW0J ofeLqt84iW8NUdp5QOSMvmpT5DADTTtdNxm7sLmCBiQpfJJl6IzfwDGmcupO9A== 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 4T5XwG2CqyzM4X; Thu, 4 Jan 2024 17:03:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 404H3Ah3085522; Thu, 4 Jan 2024 17:03:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 404H3ABw085519; Thu, 4 Jan 2024 17:03:10 GMT (envelope-from git) Date: Thu, 4 Jan 2024 17:03:10 GMT Message-Id: <202401041703.404H3ABw085519@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 8e36732e6eb5 - main - systm: Annotate copyin() and related functions with __result_use_check 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e36732e6eb50976ecc139a9c499f1396d340d1a Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8e36732e6eb50976ecc139a9c499f1396d340d1a commit 8e36732e6eb50976ecc139a9c499f1396d340d1a Author: Mark Johnston AuthorDate: 2024-01-04 17:02:04 +0000 Commit: Mark Johnston CommitDate: 2024-01-04 17:02:04 +0000 systm: Annotate copyin() and related functions with __result_use_check Now that all in-tree callers check for errors (or cast them away), we can ask the compiler to check that new code does the same. This was prompted by SA-23:18.nfsclient, which was caused by missing error handling. This change is a weak mitigation since code can easily fail to propagate error handling to the right place, but it's better than nothing. Reviewed by: kib, jhb MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D43223 --- sys/sys/systm.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 06d40481375f..2da177af91f0 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -282,17 +282,17 @@ void *memmove_early(void * _Nonnull dest, const void * _Nonnull src, size_t n); ((__r >= __len) ? ENAMETOOLONG : 0); \ }) -int copyinstr(const void * __restrict udaddr, - void * _Nonnull __restrict kaddr, size_t len, - size_t * __restrict lencopied); -int copyin(const void * __restrict udaddr, - void * _Nonnull __restrict kaddr, size_t len); -int copyin_nofault(const void * __restrict udaddr, - void * _Nonnull __restrict kaddr, size_t len); -int copyout(const void * _Nonnull __restrict kaddr, - void * __restrict udaddr, size_t len); -int copyout_nofault(const void * _Nonnull __restrict kaddr, - void * __restrict udaddr, size_t len); +int __result_use_check copyinstr(const void * __restrict udaddr, + void * _Nonnull __restrict kaddr, size_t len, + size_t * __restrict lencopied); +int __result_use_check copyin(const void * __restrict udaddr, + void * _Nonnull __restrict kaddr, size_t len); +int __result_use_check copyin_nofault(const void * __restrict udaddr, + void * _Nonnull __restrict kaddr, size_t len); +int __result_use_check copyout(const void * _Nonnull __restrict kaddr, + void * __restrict udaddr, size_t len); +int __result_use_check copyout_nofault(const void * _Nonnull __restrict kaddr, + void * __restrict udaddr, size_t len); #ifdef SAN_NEEDS_INTERCEPTORS int SAN_INTERCEPTOR(copyin)(const void *, void *, size_t); @@ -310,14 +310,14 @@ long fuword(volatile const void *base); int fuword16(volatile const void *base); int32_t fuword32(volatile const void *base); int64_t fuword64(volatile const void *base); -int fueword(volatile const void *base, long *val); -int fueword32(volatile const void *base, int32_t *val); -int fueword64(volatile const void *base, int64_t *val); -int subyte(volatile void *base, int byte); -int suword(volatile void *base, long word); -int suword16(volatile void *base, int word); -int suword32(volatile void *base, int32_t word); -int suword64(volatile void *base, int64_t word); +int __result_use_check fueword(volatile const void *base, long *val); +int __result_use_check fueword32(volatile const void *base, int32_t *val); +int __result_use_check fueword64(volatile const void *base, int64_t *val); +int __result_use_check subyte(volatile void *base, int byte); +int __result_use_check suword(volatile void *base, long word); +int __result_use_check suword16(volatile void *base, int word); +int __result_use_check suword32(volatile void *base, int32_t word); +int __result_use_check suword64(volatile void *base, int64_t word); uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval); u_long casuword(volatile u_long *p, u_long oldval, u_long newval); int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp,