Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3673032pxb; Wed, 13 Oct 2021 10:32:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8XdRtRhphXJWMHaH1wPtlpt32fTXlRtIvTSH1PUp3yk16GL/lGxXLBblfzZws24aLmV0m X-Received: by 2002:a17:902:db01:b0:13e:d9ac:b8ff with SMTP id m1-20020a170902db0100b0013ed9acb8ffmr545815plx.46.1634146368163; Wed, 13 Oct 2021 10:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634146368; cv=none; d=google.com; s=arc-20160816; b=L6zPGzAmWEBSlPX6in0eUzDJfuLVmdReWRvrxsV6SbTOvlBY4H1rdp5eOSKmNSc7gJ vPmelk3kYs/4b4kXajPk69gCZaI9u6jv09rVH3gpDQv6fVRbSZUByCl/xGkvzRuLPcU2 5sJRdkLg9/XuhdRKx3CP5kfPXZLtPylbUqTC3TPVuhP5DiA0X17qsYzURHu3z1RJPbbN WqIKGJQ91bJyvNFcCQ/NrS6xq1q6ZseH0oXV7Hf1/lc7V9Jrw3gGs3PW12Of0zDYjdan B7Sm1hR1kXLmK6wsdXezSQlotlim12OIu/W9G+KwSHRzY9RzX4dSYTSeyb/AkFP4LCfu ZJ8g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=stHyXTiMOoD7piHsq5gSpAvQZs8ZLbpI4dQLsTzc/s8=; b=ChIS9WzxDMl7mGxF91yFJBUIV82a/oH+Y4YdRm941ZfOJHmp8LD7Flc+w6BVVuDQat qcJEP+SQ65Ja0wdnRddsidlONNcUFABzWegDYyNOFmv4cpZFAntYPhxy7p9eg3kLCF+p uLrq7k935oX7Bpmupy0KM0APcX7yrzPHnkv5yIzBmRaxj+I/1tKoff2kNmFx/jJtiJ8G wi4DylgAr9fFc7SMUl9Y1r2rqHcvHYvVQw5+mZpR/4hHO4PbrcU6mhz9oOfruryC2zWW E7m2Nd3NS7esCM8Yt3hObaA23dZUqPjRsdG0GrWASWPFgJkNoKc7gJfzcR+u4Ze5rrj1 CpIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DQyccFak; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h63si139027pge.250.2021.10.13.10.32.34; Wed, 13 Oct 2021 10:32:48 -0700 (PDT) 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=@chromium.org header.s=google header.b=DQyccFak; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231231AbhJMRdU (ORCPT + 99 others); Wed, 13 Oct 2021 13:33:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238203AbhJMRdT (ORCPT ); Wed, 13 Oct 2021 13:33:19 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6A3FC061749 for ; Wed, 13 Oct 2021 10:31:15 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id x8so2315370plv.8 for ; Wed, 13 Oct 2021 10:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=stHyXTiMOoD7piHsq5gSpAvQZs8ZLbpI4dQLsTzc/s8=; b=DQyccFak9W+HHVS0jN3SNFAcP9nmOiYmmATMBRZTJ+JuzbOgEOcr1ttcYIBSAfRiqn Lz4JUkAmI842pKVjUcAR65yzW1Q2Bqa7rMxpcuZWWK/deSzwtgD2ABIVN79sLsh1xrLY L4N6hqUD1rBTVAYU9+wkk1BSrfKWne8+sim5g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=stHyXTiMOoD7piHsq5gSpAvQZs8ZLbpI4dQLsTzc/s8=; b=gpRByPqJ6Ng7zEuyqr2WEqXhT1+ut8UNFDjz6icP/eOmdLJrGaCkLCJQwEg3lmJyYc UW0gdQpcC4V5drUDIAVq431+qdVovQCnAwNeHah9MsrMuDfSGHoH5tSgFzwT0Qbj/Tq8 UMSwma5PC9QE0z+ARsLHy1x6vt46cAsPFnhzOTAiN580aNwgtHpO6CA3u1sGOjqsZkBi NIBQG17yNFbEkIfY+sNUkTO8Uw58y2loUrLarLeOgymAFbTK+fO7VQuF2wz1gHBSSh8H Q1xGuNouS7qjc+L5uVw2Vtnhpnm7Y8jWJVbHFNthoxCyOLOn75YcAo/gx47qsuCcwuWQ jneg== X-Gm-Message-State: AOAM531C4F6v6hifDxqlBCYv0W+bhFfo3EF8YW4ROEMNOvxE8y3QUfCV AY6T5pl6eJ2ZQJOxgBAIgvDKqQ== X-Received: by 2002:a17:90b:4d09:: with SMTP id mw9mr667890pjb.100.1634146275121; Wed, 13 Oct 2021 10:31:15 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x35sm161664pfh.52.2021.10.13.10.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 10:31:14 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , James Morris , "Serge E. Hallyn" , Paul Moore , Casey Schaufler , KP Singh , linux-security-module@vger.kernel.org, kernel test robot , linux-hardening@vger.kernel.org Subject: [PATCH] LSM: Avoid warnings about potentially unused hook variables Date: Wed, 13 Oct 2021 10:28:48 -0700 Message-Id: <20211013172847.1196305-1-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2126; h=from:subject; bh=LcQThCv4yG6dBsiN2R0V8pX78rE7KrdD224PvV6t8ac=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBhZxfMASF8Im7S+/H7DmFA5FYXENvqZbCwPV4BosIK 3hO2hZyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYWcXzAAKCRCJcvTf3G3AJtRcD/ 46Wah2rQa6Cz9vARcUj3izpenVsSBEaeuEyoKQZAGD8czXxlEtI8ovV46ySz2lD7T4/br/4QgtfLrh 4T8woNw3ybe6zKEQay2uI4IX2U58EBtnxkwygQpvq+ZN04ZcC9nsubw+RMAvSbkNOvMOqh/ttpS90P y7cRP5ZXSzZ7Vi+a3Cq2DGAiPCkbupTl/PcbpS73gj60T6mzLEajMez3ll+Ic3z3aB61Ivu1ASziWQ 5u/ZytW6WHTyOaNhnQ98hxjMgkeQPGjOy8KPwnUJF/qQXowvatt1HpydQXxz/4lNrESxWseW0pQk8n 5N5daJ35C6xe09ETUj7SaWrvBT7TyH/NnaTl4ZWZuknhZTZNURiS1QGf6DNtaupnLtVcVuLCjkrTL+ 5/u7xcsgQQwtY0qRNKtvb4m18WCyurYESc5Ih9S5BxFTla3tzPPLQwr+TXxg/JPtkuJXcqp/WULiXh /oHYuLJutOT4Zprn/MjieN4+hoXgOQg9OpuKQvMCqbY5ho06Glff2f364W0bYLiKj0H3q0EMymLaqU R/WMCi84e9KmmPQclpPwXLOD3qUsW95L1Q3lYDjZTLLCPgr8nH12UW4E/EhOp9MSOE6kbh40wnJgoU +HHb6nQfH4unwy1QeA54wlOGbYNAjI4NjtFCtTWAjgjU6h37OMc5t+YetnDg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Building with W=1 shows many unused const variable warnings. These can be silenced, as we're well aware of their being potentially unused: ./include/linux/lsm_hook_defs.h:36:18: error: 'ptrace_access_check_default' defined but not used [-Werror=unused-const-variable=] 36 | LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child, | ^~~~~~~~~~~~~~~~~~~ security/security.c:706:32: note: in definition of macro 'LSM_RET_DEFAULT' 706 | #define LSM_RET_DEFAULT(NAME) (NAME##_default) | ^~~~ security/security.c:711:9: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int' 711 | DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME) | ^~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/lsm_hook_defs.h:36:1: note: in expansion of macro 'LSM_HOOK' 36 | LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child, | ^~~~~~~~ Cc: James Morris Cc: "Serge E. Hallyn" Cc: Paul Moore Cc: Casey Schaufler Cc: KP Singh Cc: linux-security-module@vger.kernel.org Reported-by: kernel test robot Link: https://lore.kernel.org/linux-mm/202110131608.zms53FPR-lkp@intel.com/ Fixes: 98e828a0650f ("security: Refactor declaration of LSM hooks") Signed-off-by: Kees Cook --- security/security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/security.c b/security/security.c index 9ffa9e9c5c55..462f14354c2c 100644 --- a/security/security.c +++ b/security/security.c @@ -706,7 +706,7 @@ static int lsm_superblock_alloc(struct super_block *sb) #define LSM_RET_DEFAULT(NAME) (NAME##_default) #define DECLARE_LSM_RET_DEFAULT_void(DEFAULT, NAME) #define DECLARE_LSM_RET_DEFAULT_int(DEFAULT, NAME) \ - static const int LSM_RET_DEFAULT(NAME) = (DEFAULT); + static const int __maybe_unused LSM_RET_DEFAULT(NAME) = (DEFAULT); #define LSM_HOOK(RET, DEFAULT, NAME, ...) \ DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME) -- 2.30.2