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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C660AC433EA for ; Tue, 28 Jul 2020 06:37:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9354C207E8 for ; Tue, 28 Jul 2020 06:37:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="RraZofKt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728051AbgG1GhB (ORCPT ); Tue, 28 Jul 2020 02:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbgG1GhA (ORCPT ); Tue, 28 Jul 2020 02:37:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD3DC0619D4 for ; Mon, 27 Jul 2020 23:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=eVLgf6mf7XoEoaPERsg4sJOLSfAN6Omqo9f1ggAtEtw=; b=RraZofKtydVvZhbmY+dJhxKGsk EV6dxs/jgAPg+BwpdkDjLRHmlX6RCYLTiujPWhnqBaf3UmukvR88jdhnRZzP3wDG1/wEUfjafzJTL yS8CJo5U/z3L0bb8aRRoziF3FGywUKdPoovpECk19SP09Id2c0RGBoIVt38GpuvzZxAA65eTsDqtp e5+HVvFfL9suL/VKggTLrURmRjz4syQvGyngekkXBYyktZO5GuLNm9xorI3xx0sZZzpYir6D1P7er /6BQx9J66vsr0TdeeRX2w3M25TSTNstQ+V1NcJbR5U8WRiawPm3Zo9k9TNC9iA3rsgiGoFckYao1q BYXD0QzA==; Received: from [2001:4bb8:180:6102:7902:553b:654a:8555] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0JEH-0006jl-6n; Tue, 28 Jul 2020 06:36:50 +0000 From: Christoph Hellwig To: "David S. Miller" Cc: Jan Engelhardt , Ido Schimmel , "Jason A. Donenfeld" , David Laight , netdev@vger.kernel.org Subject: [PATCH 2/4] net: make sockptr_is_null strict aliasing safe Date: Tue, 28 Jul 2020 08:36:41 +0200 Message-Id: <20200728063643.396100-3-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200728063643.396100-1-hch@lst.de> References: <20200728063643.396100-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org While the kernel in general is not strict aliasing safe we can trivially do that in sockptr_is_null without affecting code generation, so always check the actually assigned union member. Reported-by: Jan Engelhardt Signed-off-by: Christoph Hellwig --- include/linux/sockptr.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h index 7d5cdb2b30b5f0..b13ea1422f93a5 100644 --- a/include/linux/sockptr.h +++ b/include/linux/sockptr.h @@ -64,7 +64,9 @@ static inline int __must_check init_user_sockptr(sockptr_t *sp, void __user *p) static inline bool sockptr_is_null(sockptr_t sockptr) { - return !sockptr.user && !sockptr.kernel; + if (sockptr_is_kernel(sockptr)) + return !sockptr.kernel; + return !sockptr.user; } static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size) -- 2.27.0