Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp108271lqk; Wed, 13 Mar 2024 18:45:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIz0OMPH/RWVFPHNxfN2qiDH4uJ6F0dlrCBUDGUtsTv0cUXVF88E1zJshCVjlnsVMeK5ucQoSjvhQA42f2OuCG7XYd1GTaT94VwUnVwA== X-Google-Smtp-Source: AGHT+IEWDtkACtlfkVhtmM8CRyeDIb/Nhr2Y/8uj0/8Zdh+ViKROL9PXF9EI5WupHXOr0liN+Z0o X-Received: by 2002:a05:6808:1514:b0:3c3:54e2:c9b0 with SMTP id u20-20020a056808151400b003c354e2c9b0mr468706oiw.51.1710380709466; Wed, 13 Mar 2024 18:45:09 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 62-20020a630241000000b005dc48468987si499061pgc.754.2024.03.13.18.45.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 18:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102700-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@paul-moore.com header.s=google header.b=KzDvk5aH; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-102700-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0FB92285C4B for ; Thu, 14 Mar 2024 01:45:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C7584A1B; Thu, 14 Mar 2024 01:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="KzDvk5aH" Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (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 515F01C06 for ; Thu, 14 Mar 2024 01:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710380702; cv=none; b=hFJogs+2daIGUEfXH93tcD3gyKDrJszTCklZ+iQMv3/Gou2eqQPcP9NQhQ7oKEERY8OmVQaJL42W8mZOkONVPfHUoMyuko+HVFEtOUM5S7VMCVgeya54mKS1UpIEEqRKG29sdS0e0FOQ4p2hPMWX5fIgH0CQdCyPBugKnKbDrho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710380702; c=relaxed/simple; bh=8ocKQTgy4aVumKQ3t2ClwDsyVzBXXUVM2MJIlVz1qOg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=o+riKVIQu3Bvd9ukx6m3QtyvTsK9ZZB6aLvSXkojLLbWr6ESvHlz/CQ8GV1RzyDUsQ7CTDUcTTKKk4NImJPFq8RLxwzpA8xdfnwaYJcjGHb9/r6l2HXgQO8Ux5sqy3ZbK9WW1E1mnb1ZfiM6L2wS77Ekybdj6xTdjSkcBoKhtFQ= 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=KzDvk5aH; arc=none smtp.client-ip=209.85.128.175 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-yw1-f175.google.com with SMTP id 00721157ae682-609f4155b76so5113747b3.1 for ; Wed, 13 Mar 2024 18:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1710380699; x=1710985499; 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=OwpjwJbNEYd3LzOzuw0Mu9cmJt6mxKhJWAmaUDGQPhA=; b=KzDvk5aHRg/hC1XnLHtgiimJvIiPWtTAa3XC7PPZxpy3GE91fFPyvTB8bpUiFrJYxQ 9Ye0cgLpkW9nXC6p17C6tzl2l35EYdWbLI8tV/EfeK7EdNuBRyG6tA7lOjwa+BwIdjNi pL38mJK9PHGgOFYLMH2IWTw7tyHVZUmBZbROhqkFmchT0gKB6z3l5nvIlAnm5VKeCnuT /Vx+OHL/tatRqhVHc39tHBjNhrWSTgL+8G0f4KGl5S6JVsjKLUl7QuCV+eZLFNNptcNR /AWrZHVj0buV4I0aB8vTeurzV3K+iErNon5z7ktHu8CSr4py8HUbHPpuqpszcFdPj+we PTtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710380699; x=1710985499; 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=OwpjwJbNEYd3LzOzuw0Mu9cmJt6mxKhJWAmaUDGQPhA=; b=I2c13MNSwQA1ENgzz+StKxC3JAcHVeUZAkMug5g0qlWlyj+w6DH8e+2kZw9D4gYU1d Y3RJXh9xQr27u9LccwqjlB4yeAR8r/Rjx1bz4TxNwdRIfghei0+V4/trmP9y6WmM4j10 Qlq5WUk5Ma6QCDKLwLps4D47Z6/iR+DB2UutvZm7wH4qn+Kyb4idTyqQCfCrIh9jba7+ j4OQ7RkDpMfYSW13AORic+9DIz6Bdpj6eglQdb9dNoy0PieT6+laeF98KaGeKWc8N3Pi 0iP1T7uPGxZuMWTtWVIk0oxJD2cJVr7/JFYROOoqqnQf50KAtHKxN+0DT2+ecVMvmNyy HBJw== X-Forwarded-Encrypted: i=1; AJvYcCWnuDFpp7LYQ4ogrzPe6WuuNILl+lJxJOqs1OtqbYOVGVLJQa9LpkQdjIdDTmukYLy+m6GwU/ynOBq3iAzJQHOwN1UB03Oop8jbgC6c X-Gm-Message-State: AOJu0YwpWdgG8ZHReDxNyIlRKE5v5v+xfslIo7bqKM0btuEjE493vJQG toYE5aju9Ki7F/UT3DLUjEaDbvbQd1Hdr8DVgvMO9dFQ3d310GOhqR38GU2FdvUVIqzuccMYUxs gcFv2W2UBTr9/PCROfM7o353krFeR3eV3bPsJ X-Received: by 2002:a81:b408:0:b0:609:f49f:5949 with SMTP id h8-20020a81b408000000b00609f49f5949mr395125ywi.21.1710380699301; Wed, 13 Mar 2024 18:44:59 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Paul Moore Date: Wed, 13 Mar 2024 21:44:48 -0400 Message-ID: Subject: Re: [PATCH v3] LSM: use 32 bit compatible data types in LSM syscalls. To: Casey Schaufler Cc: "Dmitry V. Levin" , 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 Wed, Mar 13, 2024 at 6:48=E2=80=AFPM Casey Schaufler wrote: > On 3/13/2024 3:37 PM, 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. > >> > >> Thanks everyone! > > > > Unfortunately it looks like we have a kselftest failure (below). I'm > > pretty sure that this was working at some point, but it's possible I > > missed it when I ran the selftests previously. I've got to break for > > a personal appt right now, but I'll dig into this later tonight. > > In v2: > > diff --git a/security/security.c b/security/security.c > index 7035ee35a393..a0f9caf89ae1 100644 > --- a/security/security.c > +++ b/security/security.c > @@ -810,7 +810,7 @@ int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, si= ze_t *uctx_len, > nctx->ctx_len =3D val_len; > memcpy(nctx->ctx, val, val_len); > > - if (copy_to_user(uctx, nctx, nctx_len)) > + if (uctx && copy_to_user(uctx, nctx, nctx_len)) > rc =3D -EFAULT; > > out: > > This addresses the case where NULL is passed in the call to lsm_get_self_= attr() > to get the buffer size required. Yeah, thanks. I didn't get a chance to look at the failure before I had to leave, but now that I'm looking at it I agree. It looks like it used to work prior to d7cf3412a9f6c, but I broke things when I consolidated the processing into lsm_fill_user_ctx() - oops :/ I'll start working on the patch right now and post it as soon as it passes testing. --=20 paul-moore.com