Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2737968rdb; Mon, 12 Feb 2024 15:14:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX4HWTgazkqZPdql9b3vwz2nhR6JWPoy6q0W12J6ZSsg5fSMp0SC3m49eXFDntOO0YI3fpMr7anRibHO4SMpMsB41ydbXEeb9Qdwr6qyg== X-Google-Smtp-Source: AGHT+IHhcnULUK3ruW1qChfyKcrie4chCJzehqrP8ZsHNC+cjb8Y8TsQ+MPAR5nTimCUQlRjmWNl X-Received: by 2002:a05:690c:2c88:b0:607:57b5:95bb with SMTP id ep8-20020a05690c2c8800b0060757b595bbmr3146985ywb.45.1707779697892; Mon, 12 Feb 2024 15:14:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707779697; cv=pass; d=google.com; s=arc-20160816; b=Kie0P+d3QETnuzpsb6wCLdlapTNGg/adz4oQnDsxVe1f5+BzpklyqD2MCC9V6J8A74 HYgPd/2RZR3Dasgd8h7NC0Hlrt367E3OqKtgjFp7r4KmC2geR2LGYHj1WkRVRtVDjfHR uyQiPkvVlrmEGa+a6bEpXYBk6leAu3boCnkwqvVEkyIxW/kyLyy+vSmyWkeY5MX+Tlgm Tz/qlAswOnvFjP8INlHBGP5tqoaB85bnLpC7ZpwT60jxEBCUbzvzG49sOnlChSwuDynI m4yrsyz94EIp2jRtxiasoPCigf+scGB2z4hxHUbOWJV//G9+KToZE1nHvKmPYL+SosN4 flSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=QyGuhjRy2CAhPp7km2OtYzK7OMbyUKD1K9kuodelDyc=; fh=eps29CgaLsxTsc3cGvO68UFILjElFTqwqplz713UpfM=; b=qgOC6xr9WHy6DXJWeMyaZf4agm6RXUb4b0uGmSayRMI8GVWZKzRznR951fhXElCmZc m98rw6Db3wtSFK/MmiFwyHI78IcTF2jjPhOUlQsuQe80C2qhATSUYBVA8wx+uOvgUYdf WFOe4HfalsC1J92Pg/860YehkZfRwPIxX+PmKXYpmm9A5C+WRfWpMYIroRYn5seJdInS smuwn4wW5Gbz2DDN5tojmhZ+1EtyMTbCiWov2vbuO4fDaO3naV5gYdRzSEW/BMdvCOdM OSXvIVsU8iH1S+iB/J2kjSGlrjhuPm/Ah4sceRnyn4aMytjrmRZlnn0bElsOod9711qf /xPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm2 header.b=E8hi6jKG; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=lV0RyuQI; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-62524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62524-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXAOh4gxeS8eXw1z1VqdvRoSqlJo6wz9WNwNMs+0vTGU8VxEW01GRcQyjjemZOIjlYXjWvBmvH9UWMKBNzFri+2cB/+Ezet/pt4yt8ONg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b21-20020a05620a04f500b00785c39859b5si6455044qkh.746.2024.02.12.15.14.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 15:14:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm2 header.b=E8hi6jKG; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=lV0RyuQI; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-62524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62524-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A1A8B1C21E50 for ; Mon, 12 Feb 2024 23:14:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B0C84F5F2; Mon, 12 Feb 2024 23:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b="E8hi6jKG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="lV0RyuQI" Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61DAF4EB49 for ; Mon, 12 Feb 2024 23:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.156 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707779690; cv=none; b=u3QgsOfyhqWu36pDRVArINUca0Vpb/wLjGCsnia7HgTcttmiyvobKPYWQmZ1lG2SIE7jX7FAPV4et4C7W4hv/oXTaApZKb+sS4e3gDBZpddRyZvCQ2DSuAmlLL5At/IESbZ14BiFctKUwubdD2GWWWp3W+qDhr6uHvQ4poovZnQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707779690; c=relaxed/simple; bh=9nl15u7EBzbTLxafb5O8ds33OrCIC2ZYVzALBf14jdg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kqG0vxtKqdekJjnRaa7J93MuCcVQbDbX38koj4nkTTUfqPl9yoXtgj/x8abW9JwNGTUvZQ++tkJ/Ww0Zt9hg50cfqTQMvpVj1RFCyZkPv7LGw3i3azeVlEyP208w4Akfllvs0/fg3YXoF+MK9T9Sp5k9Mevc6hJDiW8OmzYVrIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza; spf=pass smtp.mailfrom=tycho.pizza; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b=E8hi6jKG; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=lV0RyuQI; arc=none smtp.client-ip=103.168.172.156 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tycho.pizza Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 234B511400BF; Mon, 12 Feb 2024 18:14:47 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 12 Feb 2024 18:14:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.pizza; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1707779687; x=1707866087; bh=QyGuhjRy2C AhPp7km2OtYzK7OMbyUKD1K9kuodelDyc=; b=E8hi6jKGC7rA0SsgSYRIHuVqRE IHWA3Wt/M2fbKg4GYN0xgmSMbTAEryvAN+aWjmxGCeeY6dID6tVAAM++UaaTG3I4 A4qWcQl2mVq+2SvO4j2c7+3Gm98a9M2tRH1DX9xrr/E0vqd5X9JGc7UqFCMpi+sK t7htY3MBi5aPSALoKCvaMbAiEJfoDFE3lWcA7t+WmLC9bs+iLRYRHU8LAFfOEKvf YSlr+92GTQhZWrNFlPa54FbUi3jZJPz6DQyTWPgOTP/k/MCbMajTVz0KBGJNN2CG CMMsvolSfhnZ5b35+isqdvDSmnje4oK5Rd0s+OQVNy2tKi/gtxn2yDkR1CWA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1707779687; x=1707866087; bh=QyGuhjRy2CAhPp7km2OtYzK7OMby UKD1K9kuodelDyc=; b=lV0RyuQIiNznM5Xqt+T/9on7PaP5RtvH2+3ytxGoEAFQ 4qusYD55GaO8fKcA2Py1QGjcx5Kr0ZtfxxA74CTdbxzuMAb168vOeEAlK0WhmKkS Ez2J2d241wfWw8wtEIUT6PnCI9EHviSjHOljJ8fWKGfHjfxetvCh5y0HdT51KHkj lvj7ElnBTJou78t/oonwNjzXPaOvVEwV1TrgYXx6MZReyBbvbFc/Hwk8VBTDUmj3 Aeyz4/zUjTlMCxEZvL98Wsbks9XMKfdlDunfz78Mcwzzu+VKRHqFiOqIpXS6mfdm 53+euS3cnDtFeYPGsGvFYYjXIADC97QxA4c7P80j3A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeggddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefvhigthhho ucetnhguvghrshgvnhcuoehthigthhhosehthigthhhordhpihiiiigrqeenucggtffrrg htthgvrhhnpeelveduteeghfehkeeukefhudfftefhheetfedthfevgfetleevvdduveet ueefheenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepthihtghhohesthihtghhohdrphhiiiii rg X-ME-Proxy: Feedback-ID: i21f147d5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Feb 2024 18:14:46 -0500 (EST) Date: Mon, 12 Feb 2024 16:14:45 -0700 From: Tycho Andersen To: Kees Cook Cc: Arnd Bergmann , Arnd Bergmann , linux-kernel@vger.kernel.org Subject: Re: [PATCH] samples: user-trap: fix strict-aliasing warning Message-ID: References: <20240212111737.917428-1-arnd@kernel.org> <170776334482.2557794.95461406898503535.b4-ty@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <170776334482.2557794.95461406898503535.b4-ty@chromium.org> On Mon, Feb 12, 2024 at 10:42:27AM -0800, Kees Cook wrote: > On Mon, 12 Feb 2024 12:17:31 +0100, Arnd Bergmann wrote: > > I started getting warnings for this one file, though I can't see what changed > > since it was originally introduced in commit fec7b6690541 ("samples: add an > > example of seccomp user trap"). > > > > samples/seccomp/user-trap.c: In function 'send_fd': > > samples/seccomp/user-trap.c:50:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] > > 50 | *((int *)CMSG_DATA(cmsg)) = fd; > > | ~^~~~~~~~~~~~~~~~~~~~~~~ > > samples/seccomp/user-trap.c: In function 'recv_fd': > > samples/seccomp/user-trap.c:83:18: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] > > 83 | return *((int *)CMSG_DATA(cmsg)); > > | ~^~~~~~~~~~~~~~~~~~~~~~~ > > > > [...] > > Applied to for-next/seccomp, thanks! > > [1/1] samples: user-trap: fix strict-aliasing warning > https://git.kernel.org/kees/c/9ad28ca5238d > > Take care, If you happen to update the trailers, looks good to me too: Acked-by: Tycho Andersen I also don't understand what changed, or why this really fixes it. We're still "violating" strict aliasing as far as I can tell, since we just introduce `int *fd_ptr` insted of memcpy()-ing out the fd into an int? But whatever shuts the compiler up works for me. Tycho