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=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 8735EC433E0 for ; Wed, 23 Dec 2020 02:31:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58BAC2222A for ; Wed, 23 Dec 2020 02:31:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730541AbgLWCaJ (ORCPT ); Tue, 22 Dec 2020 21:30:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:54312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730540AbgLWCZf (ORCPT ); Tue, 22 Dec 2020 21:25:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2FAAB2313F; Wed, 23 Dec 2020 02:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690320; bh=dgoLXAAdcQbHhpRGNFEm//O45/57BGHrz1JH3GoEqEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ovb4JvWrX8AatjWXkD1fNRj6WQI5PaocxW9GQ1wAGXEVW4wzT9PUXXFmfh+4RC51P KoGEvol6pHtpcAYF589aO4W8gKISfF8Jte/7uuui9RWF/2uwFjcOZDyObpqUt0c6u4 E/R/MfuEi8EkU4qPvNW2hAeJ02lA551jG21VP15g5PDnklnY1pUhrlaI7t9i7xmJLH drpdfXqD8FQSxeYgFNU+NGQkwXzomtVVBQ72ydd6bklOV3zTtcqrVGNP7RQEcXA7q4 K4mvQlUr6kDbH0h/XomQe22CDFr3TjH4KtVqUjZ5p221lFn1ANFcRhmc/oHAcPPdQ/ twEwLGZQNuPQA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , Tetsuo Handa , Sasha Levin , linux-security-module@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 4.4 02/38] tomoyo: fix clang pointer arithmetic warning Date: Tue, 22 Dec 2020 21:24:40 -0500 Message-Id: <20201223022516.2794471-2-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022516.2794471-1-sashal@kernel.org> References: <20201223022516.2794471-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann [ Upstream commit d9594e0409651a237903a13c9718df889f43d43b ] clang warns about additions on NULL pointers being undefined in C: security/tomoyo/securityfs_if.c:226:59: warning: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic] securityfs_create_file(name, mode, parent, ((u8 *) NULL) + key, Change the code to instead use a cast through uintptr_t to avoid the warning. Signed-off-by: Arnd Bergmann Signed-off-by: Tetsuo Handa Signed-off-by: Sasha Levin --- security/tomoyo/securityfs_if.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/security/tomoyo/securityfs_if.c b/security/tomoyo/securityfs_if.c index 179a955b319df..1e6a4ed5ae54d 100644 --- a/security/tomoyo/securityfs_if.c +++ b/security/tomoyo/securityfs_if.c @@ -135,8 +135,8 @@ static const struct file_operations tomoyo_self_operations = { */ static int tomoyo_open(struct inode *inode, struct file *file) { - const int key = ((u8 *) file_inode(file)->i_private) - - ((u8 *) NULL); + const u8 key = (uintptr_t) file_inode(file)->i_private; + return tomoyo_open_control(key, file); } @@ -227,7 +227,7 @@ static const struct file_operations tomoyo_operations = { static void __init tomoyo_create_entry(const char *name, const umode_t mode, struct dentry *parent, const u8 key) { - securityfs_create_file(name, mode, parent, ((u8 *) NULL) + key, + securityfs_create_file(name, mode, parent, (void *) (uintptr_t) key, &tomoyo_operations); } -- 2.27.0