Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp292929lqb; Thu, 14 Mar 2024 11:18:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjJiJtWwCYZ6XrCx0Obo3aT2VqdIcB+9bJkMOBZe4jjxd/ynSqs2cbS0BtZPT4cg2Ht5UgfJX1KsxpSuPG8O/DE25qg1pDX8JpnqLrnw== X-Google-Smtp-Source: AGHT+IHFB7moMs2FCA4uua69xygLDiM6NXkBlKEbH5xtu9Qq94n85rHjt6ZA87LcKXEb2KHmOoPA X-Received: by 2002:a05:6808:1389:b0:3c3:5e41:d168 with SMTP id c9-20020a056808138900b003c35e41d168mr2635890oiw.48.1710440327283; Thu, 14 Mar 2024 11:18:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710440327; cv=pass; d=google.com; s=arc-20160816; b=f8cYmBCID7yrpslcYwMdmF6EQToaRsfnbZcWvdUtnr4cEdjFc0awc7dLMKeRZoYmJy gtEZDQFXOJlXfZ0F5oQA4JqQx/4k1C/fMl1NNeSbO5H3WRU+XCF9rvOBZpgxm5kSpbq0 BTdVLe7SlEsi1qhze/+vI1BI69HzdRe5dQspBtLe7HOtasfAlkSCU4zbXHDkSld1cild dDQDd4Zoir8Q4vFkpXO/w4jUF08HM6ukUIO7IUnQ8GGr85MeTeUCPmbn45kIGncOwHUs uQSYIZ2j5kns5z45wfMM7k2+cCIVcv2nV4kLLPONUcI9vhfOc4q6B7rESp+74F9RFZd7 jWjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=B5EfQxrqLDqzJd0vO6EebJPZwf9AXezpn4SptHBp47A=; fh=ZEaWi4e6y4jicGaRO08JI/MhjIiMLWUlembqkBOuLBs=; b=aP3QoXwi/KpxQ5t1lXtMban/8t0BQ+Kbyh02isKNNlRoDR1iHYgtctM7TxBJaW3DGM DziVX991bMP6ZVVkqWdOuPqPHTT/u44AOYb/ffxpGRWV2PtvWXtkaJdjd4eNk019vhir U0eC4SrpFBYYgkOwLw0VKKIODgrmzYXTEeoOOVKvu1hW3hmq1hwEiPRyLjiQE+m8cQlZ /0fgQpzFcrQT+gt05p15WiAvhQ430wDtNQM/23fNmY6xAfoXArHWL1HLaEXmgQhOkU9I B9ub5k/xaWhfQTYEsqGqpIUyK+lRSDNCtlD1OlFiZKgmbmQO4a2jJqVV1Gw6kXYGGjIt ZwkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=HD0ESMK9; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-103649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t3-20020ad45bc3000000b0069160153bbesi875620qvt.133.2024.03.14.11.18.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 11:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103649-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=@paul-moore.com header.s=google header.b=HD0ESMK9; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-103649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com 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 D8B811C218F9 for ; Thu, 14 Mar 2024 18:18:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81CF574C14; Thu, 14 Mar 2024 18:18:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="HD0ESMK9" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (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 BCDA974C06 for ; Thu, 14 Mar 2024 18:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710440321; cv=none; b=B5Smszb3aJj7pE0GURk3Z7Pmp/XQwJrhSAuEbKT/uEl2g0k77eclPQ0D6EKDDMvJKyHRYgbxxb0SXdn8TGUTHKzh6A3uCsN0hkny421X2nbCTOD4fgVjufzKu2U2uNuwQgXa33kEjS3S/kWGvOlNgEDDQJVmTpJEvqyddFOEm9w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710440321; c=relaxed/simple; bh=XfvJ/gyEHsGOw8ctti1alr/Lsnygp4BfvBrNlOhNbYA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QivPtkABx4C7t2srPgkxv6tXnXnGww1o7pfNc4ZvWsge0lHfaKiRjmCaiPO0CtuU9fIA26ki1FkNYIb4Zj6ytek+tQCTkv1XHZbOFIGmSN44x1gj8E4UAyTUwE2boxXwg2DttNUainS/X2aweyTQen/wQ0/SxALz9vm6tB9be+g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=HD0ESMK9; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-dcd7c526cc0so1125945276.1 for ; Thu, 14 Mar 2024 11:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1710440319; x=1711045119; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=B5EfQxrqLDqzJd0vO6EebJPZwf9AXezpn4SptHBp47A=; b=HD0ESMK9wtAsHJzETO9qu+RqNUaCXz90qBF1y+yCSBl8TZv0rVE0XtHxl/bWJzRmPH onh2H5pzrjYm5XRjjKINoM8u2K8QBJfRMRPQogVcIbm7zj6s6mIBql22ob0VEQHeB8Be +RqllE8/ay2vIFful8WmH7G7gyxT//0igp7aKee+Ueohj6mU6H28Xv1+zabxSt54GMet AJl9y0kDW3Y8W94TmBJt+H0owhaisB1F1LSQUit7HYlMF9xTh3SVAhXvLVN3CGr2Y7gM YngCVx2Q+JMHHgGVWme+5UYfGX5qekOFAlRtUNkZVhP4M3I+wWPaAy3lYdYgdaNnHZg5 Noeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710440319; x=1711045119; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B5EfQxrqLDqzJd0vO6EebJPZwf9AXezpn4SptHBp47A=; b=CQ6oNwTEwct5AJ0lWsvc1mEmzVj+yKDNdAAfXabURY7Kw5oCrwmzdaszB6++//D918 OyPrRAtsMkSaNJ1+H/kPzSmNjocONcU3eWELowSapvWhnnzI1mi1OlKVoHmU/iHKSaJp 4Dpj434k32tz32PPTAUBKz2ffSW9hGQYwup9/2hfQySYxBWiptMvVF4T3Sq3UFocM3im 8U1fjWIn/fXnNmq6KwsbuiblVsbxQTnpTIqzROeTUVCa5bzOB6tFVJc15if5Y8iXc8x/ zHgYP5ymtMECKPny69pH0iLfhb2YO3LDfXDQi3GwvGmO+b7CWeJVkw3NzJJE63jVzpSL l+HA== X-Forwarded-Encrypted: i=1; AJvYcCUeRESYDNFNIRuGSBi8A6NvmwHkMnYwEojzP75bI9jvoLtFiywYYtmyqa8qbOSbFhAbzW0gQ0AT9vVVWlgKr1dxKKZSx5TwwXs+hz/I X-Gm-Message-State: AOJu0YzPpZ1m6Fro2tmjQJGNjAkVneVzETawGo/2adwax2c74JQIxj31 o7nFNctzec+mDOXrPOe1c7xPYNAX+6Z9uAmL5fBN1OTRfTuDSC+GhsEUpTDptngUbb58dUOeYBC yGbh9K0vVrhUfgoSjZeHJ1qI/N5WtOYdKVtGZJyfcHm8LFL8= X-Received: by 2002:a25:9c46:0:b0:dd1:55b6:e671 with SMTP id x6-20020a259c46000000b00dd155b6e671mr2620728ybo.21.1710440318187; Thu, 14 Mar 2024 11:18:38 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240314180143.GA26431@altlinux.org> In-Reply-To: <20240314180143.GA26431@altlinux.org> From: Paul Moore Date: Thu, 14 Mar 2024 14:18:27 -0400 Message-ID: Subject: Re: [PATCH v3] LSM: use 32 bit compatible data types in LSM syscalls. To: "Dmitry V. Levin" Cc: Casey Schaufler , LSM List , Linux kernel mailing list , linux-api@vger.kernel.org, =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , James Morris , Serge Hallyn , John Johansen , Tetsuo Handa , Stephen Smalley Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 14, 2024 at 2:01=E2=80=AFPM Dmitry V. Levin wro= te: > On Thu, Mar 14, 2024 at 11:30:53AM -0400, Paul Moore wrote: > > On Wed, Mar 13, 2024 at 4:07=E2=80=AFPM Paul Moore wrote: > > > On Mar 13, 2024 Casey Schaufler wrote: > > > > > > > > LSM: use 32 bit compatible data types in LSM syscalls. > > > > > > > > Change the size parameters in lsm_list_modules(), lsm_set_self_attr= () > > > > and lsm_get_self_attr() from size_t to u32. This avoids the need to > > > > have different interfaces for 32 and 64 bit systems. > > > > > > > > Cc: stable@vger.kernel.org > > > > Fixes: a04a1198088a: ("LSM: syscalls for current process attributes= ") > > > > Fixes: ad4aff9ec25f: ("LSM: Create lsm_list_modules system call") > > > > Signed-off-by: Casey Schaufler > > > > Reported-and-reviewed-by: Dmitry V. Levin > > > > --- > > > > include/linux/lsm_hook_defs.h | 4 ++-- > > > > include/linux/security.h | 8 ++++---- > > > > security/apparmor/lsm.c | 4 ++-- > > > > security/lsm_syscalls.c | 10 +++++---= -- > > > > security/security.c | 12 ++++++--= ---- > > > > security/selinux/hooks.c | 4 ++-- > > > > security/smack/smack_lsm.c | 4 ++-- > > > > tools/testing/selftests/lsm/common.h | 6 +++--- > > > > tools/testing/selftests/lsm/lsm_get_self_attr_test.c | 10 +++++---= -- > > > > tools/testing/selftests/lsm/lsm_list_modules_test.c | 8 ++++---- > > > > tools/testing/selftests/lsm/lsm_set_self_attr_test.c | 6 +++--- > > > > 11 files changed, 38 insertions(+), 38 deletions(-) > > > > > > Okay, this looks better, I'm going to merge this into lsm/stable-6.9 > > > and put it through the usual automated testing as well as a kselftest > > > run to make sure everything there is still okay. Assuming all goes > > > well and no one raises any objections, I'll likely send this up to > > > Linus tomorrow. > > > > I had to squash the code snippet below into the patch to address a > > build problem identified by the kernel build robot. I'm going to keep > > Casey's sign-off and Dmitry's reported-reviewed tag as I feel this > > change is minor, but if anyone has any objections please let me know > > soon. > > > > [NOTE: cut-n-paste'd into email, likely whitespace damage, but you get = the idea] > > > > diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h > > index 77eb9b0e7685..e619ac10cd23 100644 > > --- a/include/linux/syscalls.h > > +++ b/include/linux/syscalls.h > > @@ -960,10 +960,10 @@ asmlinkage long sys_cachestat(unsigned int fd, > > struct cachestat __user *cstat, unsigned int flags); > > asmlinkage long sys_map_shadow_stack(unsigned long addr, unsigned long = size, un > > signed int flags); > > asmlinkage long sys_lsm_get_self_attr(unsigned int attr, struct lsm_ctx= *ctx, > > - size_t *size, __u32 flags); > > + u32 *size, u32 flags); > > asmlinkage long sys_lsm_set_self_attr(unsigned int attr, struct lsm_ctx= *ctx, > > - size_t size, __u32 flags); > > -asmlinkage long sys_lsm_list_modules(u64 *ids, size_t *size, u32 flags= ); > > + u32 size, u32 flags); > > +asmlinkage long sys_lsm_list_modules(u64 *ids, u32 *size, u32 flags); > > Fine with me, thanks. > > btw, with the change above, u32 will become about twice more popular > in include/linux/syscalls.h than __u32. I was looking at that when I was putting the patch together this morning, trying to decide which was the "correct" choice between 'u32' and '__u32' and wasn't able to find a good explanation of which is the "right" option in this file. Ultimately I went with 'u32' as I tend to follow some old guidance of: '__u32' for userspace headers, 'u32' for kernel headers. If it should be the other way, please let me know. I just want to keep it consistent across the LSM syscalls. --=20 paul-moore.com