Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6998212rdb; Fri, 15 Dec 2023 14:39:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEf+2Cg3zWvAwL/cxndiQFsrCGgPT+VfxWwmQVCqco1kw8tIWYPY80Txwo6faqUIRwlm45p X-Received: by 2002:a05:6214:226a:b0:67f:2195:81aa with SMTP id gs10-20020a056214226a00b0067f219581aamr1241668qvb.100.1702679950974; Fri, 15 Dec 2023 14:39:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702679950; cv=none; d=google.com; s=arc-20160816; b=kvpQIk8LURk9/3DfLQPybcPzjxc97yh/gMJAp8o4wkzbs/ZDrmL0zW/lrG8HTKRxwj 0UD3ddGKQRB05RUIXSLTD6rFOMYClscHGk6kapfDLZLxyLDP4tYNtno8zYm360tlbAd6 UytERD714ZdsKCYYmq2dnf/3fDxp4wT9FJ9HXuswhUPiQJynDabwTdjzJ2MlL0PaepsC 7UxGUrEZzfIvRz8A5WurV5K0D/ORZZpwZICHtlsKAJQvOw0GlhOemiGI/BXTJ6oTGtUI TDAD9QaXjLh4Q+kzIhwCZAsDkjL1ZTFcIYFUbVjN75S5HC0kSPDSTeyVg6GmU99+tTl+ Ql2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vw4D+BEaDQJfSHAGsDrE6ropoXZ857wJv+qK1Uq2Fhw=; fh=h2bDMbVXI6PjfOxzpopfvZAv/tOu3aSdaym9FM2iu6M=; b=0nQhHbbvO9N+15IUTlp3nqrOUhGCGNN3XU2iCg1MXQ9ZrMRmh/VfOQpue3rVrnUf1S ZFNu/zopaLxiSxZ2l7ro+FAaRiLdpYO2H5G0BpHSOfJj1pKn+UAQRmpLWzx1GCw2AHsU c1aCql3JyuKlOVPZDloLhOPUjsbJ+n9x/QU+IgEgTuJqfBblipt0WjU6KnAuVCD/0ay7 G31XIjvVHkevtWIdE9Bx8ks22Oi+rt6OUYuxEYmJscGbG61F3vt6c9YGJRV7EgkZRtzG sBn6RpJAR7sqbf0i+B0nL7G7BPJes7LFxHsl2g7ol/PSIdIwNrxkSwGYjUL1FYyYy4x/ WeNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=s8E7a9Ht; spf=pass (google.com: domain of linux-kernel+bounces-1776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1776-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c3-20020a05621401e300b0067ed8808b24si11672597qvu.370.2023.12.15.14.39.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 14:39:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=s8E7a9Ht; spf=pass (google.com: domain of linux-kernel+bounces-1776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1776-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B99151C24667 for ; Fri, 15 Dec 2023 22:39:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A117318EC2; Fri, 15 Dec 2023 22:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b="s8E7a9Ht" X-Original-To: linux-kernel@vger.kernel.org Received: from sonic302-28.consmr.mail.ne1.yahoo.com (sonic302-28.consmr.mail.ne1.yahoo.com [66.163.186.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3B1418EAF for ; Fri, 15 Dec 2023 22:38:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=schaufler-ca.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1702679938; bh=vw4D+BEaDQJfSHAGsDrE6ropoXZ857wJv+qK1Uq2Fhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=s8E7a9HtnwBj2iiRElPv7y2OTlbx0dCRAAA6Or5I/05O5N4cr6J1nrWYTkW6kVIbRI2i/KYtGGPGF6pH0JQ4Gzx6xHG62xwnWN4SxNrYpR2OZKP1lUykR2lPd/javdaj3N+znlS1+3IO8z+1JzCIy/hC9M7sjLwGrb6X1UfXBDoaG3EzcErxgWfioyVoTkjesWsKFyRuqrwbmNM3p99JfS02u/U7za4IJb1FyIKF4EXBsS7Q4tk2KYk2uwgqU57CoQLAGG1CLBtYhVqCgnfo7fNHrnzbwCyNVfnpXwlTUwMpgnSY5rfDppPAFNvYnQF/sx+3TY7rK1eQhK4bS7PNyw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1702679938; bh=2LzbYmbZES/Rx27hObskEXduuG+XqU8pv+hZKjvn5r7=;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plsnE8idnnKDZx8MmD.TIvFtxof98bJu_kz8ypvBBkrEC7EjsiYD6y0SUlc_05p eu_MuDcrn0WCZSOh7RZ_ATZZfE40kf6qfK2FycR0E.WGcRsK.F2v4wFHr3bxWtQMXo.bxZ2euJ02 zSzJuUQBYgzaSa47VXlM9cDmKtIR7ijgfS_Uwc.7pLea66fkbptD2vW4mw1FqnB_2l.iC1udenJk C_vAz5oYhBvgytwh16qeHZHGo49D08N9bEYLMD7.QVfCrUbORu1cJJT3zbjv9IxJw8AFBhnHwzcj DAYhTxAFcNQiZU6edrIBJD5EOQVlowYurYtjo7ZMQbBy75lbIK0bKvpNZ8dkoygMlzA5z5qybYxa 1Idac7UNmr3RwZLOZWzDc0frBzJNlA4vYkKMbSBBgn0jusSM8mdJxwaYZBpIbnf3URPT2oPwHdf5 xiFFMMiLXbSY7GczQ6F5Z.0SD6jLkjoZ2wQDct2FMI1QjVeuV85YI68Fugh5s6kEV59svyA0UXoM JSXGtfKEd1LTAU8pJmUNVuhIwUJiyhpsqPlQeHnLHufJhjHA4vNFm_EjPy3OznnLQHNTjQ4ii8ia zXrMrUIikzIyzmeMacTEuWMl78iM- X-Sonic-MF: X-Sonic-ID: e49cc921-3fa7-4678-8a0e-ca413b7682da Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Fri, 15 Dec 2023 22:38:58 +0000 Received: by hermes--production-gq1-6949d6d8f9-q7525 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 522caf1ff66b851381e701962a25c33e; Fri, 15 Dec 2023 22:38:54 +0000 (UTC) From: Casey Schaufler To: casey@schaufler-ca.com, paul@paul-moore.com, linux-security-module@vger.kernel.org Cc: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org, mic@digikod.net Subject: [PATCH v39 28/42] LSM: Improve logic in security_getprocattr Date: Fri, 15 Dec 2023 14:16:22 -0800 Message-ID: <20231215221636.105680-29-casey@schaufler-ca.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231215221636.105680-1-casey@schaufler-ca.com> References: <20231215221636.105680-1-casey@schaufler-ca.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The conditional in security_getprocattr() can be simplified and made clearer. This change does that. Signed-off-by: Casey Schaufler --- security/security.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/security/security.c b/security/security.c index 8ff6cef26e6c..f2ef6032a925 100644 --- a/security/security.c +++ b/security/security.c @@ -4107,11 +4107,10 @@ int security_getprocattr(struct task_struct *p, int lsmid, const char *name, { struct security_hook_list *hp; - hlist_for_each_entry(hp, &security_hook_heads.getprocattr, list) { - if (lsmid != 0 && lsmid != hp->lsmid->id) - continue; - return hp->hook.getprocattr(p, name, value); - } + hlist_for_each_entry(hp, &security_hook_heads.getprocattr, list) + if (lsmid == LSM_ID_UNDEF || lsmid == hp->lsmid->id) + return hp->hook.getprocattr(p, name, value); + return LSM_RET_DEFAULT(getprocattr); } -- 2.41.0