Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5459618pxu; Tue, 22 Dec 2020 18:44:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzN8tUAYh0rI3JCrlMWTem+2ZeU6z6I1Zuqe/U0NRa4mn8oG52y0DlnRXF6KEdi0zNHmX2 X-Received: by 2002:a17:906:4146:: with SMTP id l6mr22602410ejk.341.1608691444009; Tue, 22 Dec 2020 18:44:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691444; cv=none; d=google.com; s=arc-20160816; b=dV6AngoBWnZZdIJ1iLp+qXvyB8fPUaaRGNahtoFcKhyVoJUsNmggaitWEO7tUS8FVw s03Bp0hOrEwcX8UyfXou3klHm3wmMxy6NgUgXKQFhn6JaSugFeX8xJhL+Fqs0rNv12ty P6nyjQr+DjAEntSptmhkr8XvZcSod+lR4h51JgC7Ro8e/dHMkdifJfMfIy/eJ69hZhmk rCplJ7WpbyOiNitCL4NKOBPTDuefUop+Q9aTNf1Bw/fsp83ygHEoPjqJ9xnWgYsc3inl msB2zw4/ZwprnIK/6mJEugSVjgyACosn/AFupthovvCJgvgWCbMkVPR7NxgXz7l6ZLlJ wwGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Yr5YS8DpGBGjPrQ7xInHH8xK8LfiUL9xvx9W2HrMnho=; b=azVUUadt8AHaQEHT5Kl4VB1KOOKqBqvjxiV/8qlCUtzlWfj4ze68ltuy4Pgmuvj82F hA1zZAafy0IcXMrUUU4pwtxH9apKtY9YOsGn5kG1NL8uH3ZiJbCXScP/G3OjW7GcgCIk +paX6lXV0vuoy5d2OGRqPg7aJtvSJuOZfQXxAaOKq9NE8jZWypQ+DsqtWmzF0EAAkDpe 7yKSLC4oY5u2kioqa1bQcKhs59AxXNGPf2gAa5eFjJPR16fQMiYdJrT38Y5fZJgWBZIr SO+EonmgnDwAzjG6ZZ0b0RNNXKwYsVYSiR63XsvldthHkVfWpwZGl7vbPyDfO6xN3sGN RWVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kdRKUsQY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e14si12872249edy.505.2020.12.22.18.43.42; Tue, 22 Dec 2020 18:44:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kdRKUsQY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730691AbgLWCmS (ORCPT + 99 others); Tue, 22 Dec 2020 21:42:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:50890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728850AbgLWCXS (ORCPT ); Tue, 22 Dec 2020 21:23:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5701122573; Wed, 23 Dec 2020 02:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690176; bh=Nn9LclMCcw0UUENslgl/frSUmzlmcUtrLKpSJTmK2Ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kdRKUsQYkFbr3yI1F8xU5Q/5SEgo3mjQgCmpVDe8w+9yJxdpzb8rR68Waful2DVu7 xV5yxQFRynMSg0ueQf/fVEgbNlD1vXQz4BBmezrB9IAHy7OQA/AKdgcC3SCxOTVLjt eGVrvxr8HmZ9U20V8OpFyUzfsRZDxN4SacPcFM9Vut7U4XSy1UQrq6F74VA4R8HSQ8 c422cb+S0XWZKq7lZq11Af5w8PG/NkP0sHscE11iULhpDwBFVPkCJl+nh8LV6iL0oz SmQDrvEEZ75c/uJSyXYjr5Bb0wJ2awfv39MuT5IdbOr7Zvhps+oQCbBlXFbeeac1Jd cN5Sqshn06GeQ== 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.14 02/66] tomoyo: fix clang pointer arithmetic warning Date: Tue, 22 Dec 2020 21:21:48 -0500 Message-Id: <20201223022253.2793452-2-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-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: linux-kernel@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 49393c2a3f8bc..9c7c8ec87de2a 100644 --- a/security/tomoyo/securityfs_if.c +++ b/security/tomoyo/securityfs_if.c @@ -131,8 +131,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); } @@ -223,7 +223,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