From nobody Tue Oct 06 18:36:15 2026 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 4hzlMN5GFTz6Z1vs; Tue, 06 Oct 2026 18:36:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hzlMN4m1Dz4DQr; Tue, 06 Oct 2026 18:36:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791311776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L7cBEwQ8vmrUqDiFWOFNjcZaMURgefAzeVcaYQydXWI=; b=lhP+YQUwPrFEi7n09h4dxwYrcsg3i+s68SLKbJ4IBDc3X2ejCetjsomVJC2p3EC4pAe93m Pt/W6b2f8TrqfMN+btQpirK6Mli8b/lRJesWIQiruBoG2oy6UJlOV6VTuqTL4VKJwaD+YU bQSfL8qcGeuvO7lH/jVJc9RRmAL/ksr59lTgsYLeSOHeMQS8Y9TOvR/z8q79LNjAnaly17 3+taTW+V/L9yDAASfSWylN36jlzWyzLjlahLmxP/svWHkx6Bt00ZWBzGrorZwU8dokePJ9 bPYc5LBmz8EmXEE25R2CTWCJE2oVIH3hlyjLQVZlX4O+6DQOAgUl9nwjgrNeMA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791311776; b=pDP0gLNWyftKGNNGNPDRajJvixIUCqquFDgc2mDOfABYQiHkMB4eaRRPvq8LpJkoncycP2 1lMpbyIav3J9CKogRl3BTbDdygdEqOC4bB4PccXG+BR90XhO12O2I0/xl86JWpglopcOYn 9pUINWyApm1B5A5PUzaEvBnGvjmwXiovEKIUNMAHndhvhltblULasfzfVKEAO3xWi+BoGu ykEmf+J41YVnv3EXjsKEN+fe+yDHlLnjv+Pnga5DNuTCA1w2ySPd/493UoK9HQK+pQtXD+ lYwT38ns6cDEVDLE61wu26CasFMCifQ15M7JqjGZZwvaEkJpPg2zBGUswacXSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791311776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L7cBEwQ8vmrUqDiFWOFNjcZaMURgefAzeVcaYQydXWI=; b=SET/a+jagWN2p75uZmj/do+7/GPFFwGLpp8ux/0r2ST9KEgwDk0SEW8DFDwPOd93HHLQs9 zOwQP6l1vEVqOWcztaU0ZxhBsKbgvyAOB8ooP44hl+e9q4ebgUXwPfLN1x+znZm9lFcA6M XjaWIchcMoPys4AZWHmxXhJnpkcLA0BLDCYmBGYwVeYhqKFmgazdWQcTdCr2OOm4lccV1F leycufp/gAWjPwitedojPyqpwZGL20groV7Ec/fFpWez+KylaFANPLVE3IiI3cS8Hf8Tz/ Re44TT2sSeykyl/5PayWHoxSuBYL5lUmsYo8Ee/wB4byvfRrzdGINl/84Y14/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from [IPV6:2601:5cc:4480:1036:3129:49c9:2e6c:45d7] (unknown [IPv6:2601:5cc:4480:1036:3129:49c9:2e6c:45d7]) (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 did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4hzlMN27rSz1Byp; Tue, 06 Oct 2026 18:36:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <05459a0a-8b33-410b-a391-af94384e84b7@FreeBSD.org> Date: Tue, 6 Oct 2026 14:36:15 -0400 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: git: bb5f10e51bd5 - main - linux: implement sched_getattr() Content-Language: en-US To: "Enji Cooper (yaneurabeya)" , Mark Johnston Cc: Enji Cooper , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <6ac42979.2608d.d368a5e@gitrepo.freebsd.org> From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 10/6/26 10:42, Enji Cooper (yaneurabeya) wrote: > > ... > >>> + attr.size = MIN(args->size, sizeof(attr)); > > … > >>> + return (copyout(&attr, args->attr, args->size)); >> >> So, this lets the caller decide how much stack data they want to copy >> out, independent of sizeof(attr). The only constraint is the >> `args->size > PAGE_SIZE` check at the beginning of the function. > > I eliminated a duplicate calculation in the copyout which contradicted the [Linux] documented interface [1]. .. and introduced a kernel stack disclosure (the kind of thing we normally have to ship an SA for). Using attr.size for the length here is the correct solution. &attr is on the stack, and it is only sizeof(attr) bytes in size. If you copy out _more_ bytes than sizeof(attr), you don't magically copy out zeroes, you copy out _RANDOM KERNEL STACK DATA_. > The interface documented by Linux allows the user to specify the amount of data to copy out (https://www.man7.org/linux/man-pages/man2/sched_getattr.2.html): > >> The fields of the sched_attr structure are as follows: >> >> size This field should be set to the size of the structure in > bytes, as in sizeof(struct sched_attr). If the provided > structure is smaller than the kernel structure, any > additional fields are assumed to be '0'. If the provided > structure is larger than the kernel structure, the kernel > verifies that all additional fields are 0; if they are not, > sched_setattr() fails with the error E2BIG and updates size > to contain the size of the kernel structure. Right, so the extra bytes in the case that args->size is > sizeof(attr) are supposed to be all zeroes already (and you are supposed to check that in the syscall if you aren't already) so you don't need to copy them back out again, only the sizeof(attr) bytes including the updated size. This is not all that weird, and is similar to how we handle cpuset masks which also can be differently sized than the kernel's representation. -- John Baldwin