Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5450140pxu; Tue, 22 Dec 2020 18:21:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRAYherdNFuMTdNjYTvwGvQIcXieiEmihyodUJ+4cjL3RMdE+/37OUhUsskkrvedWEXeYa X-Received: by 2002:a17:906:314f:: with SMTP id e15mr22091916eje.496.1608690069707; Tue, 22 Dec 2020 18:21:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608690069; cv=none; d=google.com; s=arc-20160816; b=mNmvNFFNaWlsOXOiG+ps0ir7/2saGcDO8/ioilDWF1GpQzxBGbYnA2aufPDLbghyKj 8qq2itxdHq78Skv1QWe96TZoaIMTM1GjEToJeDPVhtaN3ofCFA2kUh9kJGH9HIfE9iRM x1wVdbgllnAwFYy47+NsBT5yh7QI89v60MuzWIfoA6GWFKaJ4mIY/4q7xPrpYf71+NjB aU4gbi7PJAG1dL7jJkZ+/oCIbbzhnP2Xj+ILiwzV4xwJOSuMD46GEt3p01sBCkQJ7ufQ 9wsVV9XAS0sJV0RgUEke76wvHmy02vrnB2S7VB8CYyw1+TQT2W+/5uNxJC6wqoDK+r3f lK7g== 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=cDHOOZ0RDdB6sRTU3W8x7SM06RAaTgZUhr60yNkY+Jo=; b=rQeRTsvfrciQ9Qu47imeY2afjUpN1Lk45HBZNTa8qtSfWW3uGzlnnOAOvqNgYq7CXS eRUgY1JTCjN9WC9pvOaoy+omoUcetERqszAHAhxX/J5sZ+cyxdhP+TVNUBNE7IgolqqY mr9zIqlLjZOEF4gr9pYGoOvr9GBchdquyMU88kdxmsBAEQlf3QRvVv3tnTliW13u0/J/ VWs+zavOem62i52RE+um9fS9HYsT1PQw4avGJkBT/wrZErD+fodnX8JmRSeXjkMhRW6Y FIXec/pPplQ95CzUW7dYPF3RTfo4gAsGeizeZP/AArT7H6RhtctS/Uie5Ql+1lDY+oey 39eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pc2gFmd1; 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 d8si13491160edo.441.2020.12.22.18.20.47; Tue, 22 Dec 2020 18:21:09 -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=Pc2gFmd1; 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 S1728550AbgLWCTO (ORCPT + 99 others); Tue, 22 Dec 2020 21:19:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:46336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728489AbgLWCTG (ORCPT ); Tue, 22 Dec 2020 21:19:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 04301229CA; Wed, 23 Dec 2020 02:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608689897; bh=x5PIUwxH5WbhePd4i2PbNKAofydYlihwur288ZNn9Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pc2gFmd18ziJuepaThbh9nWTJVK7eX1iGNC/jdGD2D0jqgH1aVlNY1/gWCyBbFTIa TZ7gQ3TI1Fiun5AI5StCyvGZnFT5YL3p+gGDAjfwfuFTCam5TsP+nOyuBE+diKGHJQ QLbdjbm/4Qp6YmTpHPtsDn5zwz/pVDddtTiitOcRivThkSSgYiniV0UlBBw64ATmOW XVPHndXGy99/3U3SVmAhqWKjSfcMXRWJEaAK9GjZPuUX7rCcIe3oFYrMtz8nZUBvp/ LZ7Jvj4pAXZKIKg8H+wFCVVTVu/5qEd5o+Zj/+sexSV1SPQ2rh5EJvyhCU2ysNGjgA tUk0Cmr6ZElJA== 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 5.4 003/130] tomoyo: fix clang pointer arithmetic warning Date: Tue, 22 Dec 2020 21:16:06 -0500 Message-Id: <20201223021813.2791612-3-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223021813.2791612-1-sashal@kernel.org> References: <20201223021813.2791612-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 546281c5b233a..065f4941c4d8c 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