From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD54DC433FE for ; Fri, 18 Nov 2022 19:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tJ45l41v19fBi73LeZCF5gDy5MnwERRDLheCzdntWuE=; b=r27B9iqT4+fPcN Pbt7S7nnOEFbjzYO8+dkJjmunFJliF69fYuvKMAwp8nuOxwYZ4luqczhTPW2fuP4jlKYYTl1L9N1p Nx/R330ywggDfSzI+r1cIrghPBSJ879dr9cr3KX9E+CVdQ6vi4jTS8PkdUpIf3BgeZeYvJG2X2z+J LNhAg0FauWLty/kEjcdZr4EvAgHH6jpZaZEOfs/SNUXg6sZpg7UZl2ysmxMUUnJ3udhwhA+sNQ/Sa kJckivyVrxmPvzHoPm8VGxIOIhknIYJJPpy941bH+InUjAj83kJulJsEUaISrsvELAmS6crg1NdbI 6d/IeKbTAukTo2UgNs8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ow6vO-007Xxh-LU; Fri, 18 Nov 2022 19:21:18 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ow6ko-007SVZ-Cu for linux-arm-kernel@lists.infradead.org; Fri, 18 Nov 2022 19:10:24 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8125F62723; Fri, 18 Nov 2022 19:10:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDA0CC433D6; Fri, 18 Nov 2022 19:10:19 +0000 (UTC) Date: Fri, 18 Nov 2022 19:10:16 +0000 From: Catalin Marinas To: Will Deacon Cc: Mark Brown , Shuah Khan , Shuah Khan , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 2/4] arm64/signal: Include TPIDR2 in the signal context Message-ID: References: <20221031201736.894374-1-broonie@kernel.org> <20221031201736.894374-3-broonie@kernel.org> <20221114161005.GB31141@willie-the-truck> <20221115122225.GG32523@willie-the-truck> <20221118135552.GD4046@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221118135552.GD4046@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221118_111022_548156_EF08824F X-CRM114-Status: GOOD ( 36.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 18, 2022 at 01:55:53PM +0000, Will Deacon wrote: > On Tue, Nov 15, 2022 at 04:42:14PM +0000, Mark Brown wrote: > > On Tue, Nov 15, 2022 at 12:22:26PM +0000, Will Deacon wrote: > > > On Tue, Nov 15, 2022 at 12:08:44PM +0000, Mark Brown wrote: > > > > On Mon, Nov 14, 2022 at 04:10:06PM +0000, Will Deacon wrote: > > > > > On Mon, Oct 31, 2022 at 08:17:34PM +0000, Mark Brown wrote: > > > > > > > > + if (user->tpidr2) > > > > > > + goto invalid; > > > > > > > > + if (size != sizeof(*user->tpidr2)) > > > > > > > Why are you requiring an exact match here? Won't that hinder any future > > > > > extension of the structure? > > > > > > It will but since the structure is explicitly for a single sysreg > > > > that's intentional - the thinking was to just continue to model > > > > any more sysregs we want to report in the signal context in the > > > > same format with their own contexts. It felt like it fit better > > > > into how everything else in the signal context is extended. > > > > > I see, but having the usual '<' check wouldn't preclude us from doing > > > what you suggest above, whilst also giving us some flexibility in case > > > things turn out differently from how we expected. > > > > This actually also how we validate the base fpsimd_context - > > while there is a < check in the switch statement in > > parse_user_sigframe() but we also have an exact size check > > near the top of restore_fpsimd_context() which gets called from > > there, meaning that the check in parse_user_sigframe() is a bit > > redundant. We do however allow the varibly sized frames to have > > an oversized allocation, though those have internal sizing > > information whereas fpsimd_context doesn't. My take was that we > > were erroring out here because if userspace thinks it's supplying > > some state that we're ignoring and not restoring then things > > might go badly. I'm not super wedded to this approach but it is > > consistent with the fpsimd_context handling and I can see some > > justificaton for it being done the way it is. > > Hmm, good point about fpsimd, it looks at magic/size twice which is > definitely wrong (userspace could even change those values in between!). > > So I'd vote for removing the checks from restore_fpsimd_context() which > raises the same question we were discussing initially: should the check > in parse_user_sigframe() require an exact size match or instead truncate > the structure on the stack by only copying a prefix into the kernel? > > I'm actually warming more towards an exact check now that we've spoken > about it a bit... What do you think? I'd go for an exact match as well. I don't think we can expand these structures in the future safely without an additional magic number. I tend to agree with Mark here that parse_user_sigframe() should only check the magic numbers and set the corresponding user_ctxs members. We leave the exact size check to the restore_fpsimd_context() etc. (can skip the magic check here). Well, not a strong view either way but we should definitely remove the duplicate checks. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel