Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2008420rdb; Sun, 24 Dec 2023 11:58:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5gLFPH8ASXIWM0PZkqeW0ptAbnIaS4buCVCOJYDwSymmlOqjJFOcFDt0w6s0mW7CqkdnE X-Received: by 2002:a17:902:6548:b0:1d4:810:613c with SMTP id d8-20020a170902654800b001d40810613cmr2241622pln.63.1703447935344; Sun, 24 Dec 2023 11:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703447935; cv=none; d=google.com; s=arc-20160816; b=WPVjbBWLkl+y4upxroVGA6VIrm65B0jLGQuSe+73O2A2NmBn4FW0jhsJ8mzYNBdj3+ QLWeB4AG4MYmeVT4JhkFdjdx04IwrBnIXZSHXlrDIsRvOhiLZVc4dA6/k16imwLodoOk 1XRWs04CCC33xvDCWV7Jf/FdlhmAuxNPafvc1RZsSTLZaUSas5nh5Z0blmH6WpEtTxNO qyDRIfxkAYW9IndIipu0XJTWp66Nng2vknxIOIwT0kSdJFPHhD4L1ALXidPMXv6qlV+h 28OLs5gDrbVFoNt/7VObxEtDi8290tHJXOp3dhFGkej1Ew+djuML1bpaqejExNXC63aA i8rg== ARC-Message-Signature: i=1; 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=tmcVQPwGjjUY9XTbKfzg3lbGQPvGiD0vLAjWo8rnhBQ=; fh=f9xJy/gVC1UCyWVpW1gu/8SbHCm3+EqBCvMC+il82Gk=; b=kAuJvGgMwI+EqMQYJGWjt8DGSXNPyQk7NkmghQISlYgEdRbK9ghyQj5U+Y2IaR+KUF ieAppNtV9cRskgscAOQmDMuCf5DS4ZPzAFverAaPUnyRHQxygPiPnnIMrELTeCTwAt3v 0VV41xvkZwG1IE/z4nhzXBaVQFldThn2TySgiX9pVTyOo3wpYq3K/57Xnyw2Miro7g8l KZE1EDWRNCaXVuPlzQR53X06k8N3NpFLWAYQBR2D0h+tVLztrgfZ5UhNXglNzPtuRii2 zXrXba5yaQc6CHMrAy0g71Ugu9WpAZSzzeLMrzOp2ykpUW5rosjtNqNZhCkHbPAMYjj6 LeFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=SRl0W3cY; spf=pass (google.com: domain of linux-kernel+bounces-10817-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10817-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 sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t24-20020a170902b21800b001cfa17ec332si6580705plr.616.2023.12.24.11.58.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 11:58:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10817-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=SRl0W3cY; spf=pass (google.com: domain of linux-kernel+bounces-10817-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10817-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 97E1EB21051 for ; Sun, 24 Dec 2023 19:58:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0122E574; Sun, 24 Dec 2023 19:58:39 +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="SRl0W3cY" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 99CFBDDA6 for ; Sun, 24 Dec 2023 19:58:37 +0000 (UTC) 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-f178.google.com with SMTP id 00721157ae682-5d2d0661a8dso30872287b3.2 for ; Sun, 24 Dec 2023 11:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1703447916; x=1704052716; 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=tmcVQPwGjjUY9XTbKfzg3lbGQPvGiD0vLAjWo8rnhBQ=; b=SRl0W3cYZDpisUjwm9Cdsa5lL22PatpdQ1lwN4L8rsdgijB8cm/dJRZMmfCaBe+N9P oJIkvul5DqxNyOHh9ak3C12NnVpe7xqUrtAWeWN1G4GVCcW8uraoy9vcSpfH8HcLycGO gLqltSTLnvE3R/U8J4VpmmOXa3x15YDr/Y9XQn4q2ykOv7K/tZjbkM0dqLe2MzPYquq2 bBhrArobc+R0uTCOry+7ysLAccGJy0lwsjX4/TxqepAwvBGNbViV2a3kamrLsIcJR1B2 IoiMRK3DY3reIO+GfvglV0armuw8uFdrfvOL4H4sM9kS5PQ7kvp9Q6FBjlQPubHhF/Aa vTUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703447916; x=1704052716; 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=tmcVQPwGjjUY9XTbKfzg3lbGQPvGiD0vLAjWo8rnhBQ=; b=WIpYUaL34jlZg9leKdLCbn6/TM4fhg+fmdsBGZNOtf/RV24Uc7N0BzHwj8GwBAAJ7l rSIK0pl1vogyf6xZxftJsxGx5ilZvYRZ9+Ysn2uJVNfuBwZonmZJBwRuOpcLvslEq89Z eGhcvhOeniwY/6qECGZ2ZUIWnNTaXUT7jyH4uW8N1aNH2lYaDbwzBCAwzTOxo8rISpLT LW4QzH7dH1Q+o09EBIPx69+6sLB4MkKIkF64m2BAjtyE57COOlSwCvOZzxzBJBy6Hjj+ OeCNqh6OwMQ2P26Ut/lZmv0sjq9R4XTnt/VlVd2Feh/0jBCLoTKdt9YnPW4nsbFmZv3p vGIQ== X-Gm-Message-State: AOJu0YwhGrij5JadML8r2eb4URrjtcn/QEgs/MEEpF56HO8A9bJ7kd0R L3MVrGz6uHT8XbVZgycSPpM3XHMxXasI53sWntEFbiJTuZze X-Received: by 2002:a0d:df91:0:b0:5e5:7254:2c2d with SMTP id i139-20020a0ddf91000000b005e572542c2dmr3160011ywe.53.1703447916657; Sun, 24 Dec 2023 11:58:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20230906102557.3432236-1-alpic@google.com> <20231219090909.2827497-1-alpic@google.com> <57ce7089-37c7-44c5-a9da-5a6f02794c42@I-love.SAKURA.ne.jp> In-Reply-To: <57ce7089-37c7-44c5-a9da-5a6f02794c42@I-love.SAKURA.ne.jp> From: Paul Moore Date: Sun, 24 Dec 2023 14:58:25 -0500 Message-ID: Subject: Re: [PATCH] security: new security_file_ioctl_compat() hook To: Tetsuo Handa Cc: Alfred Piccioni , Stephen Smalley , Eric Paris , linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, stable@vger.kernel.org, selinux@vger.kernel.org, linux-kernel@vger.kernel.org, Casey Schaufler Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Dec 23, 2023 at 5:49=E2=80=AFAM Tetsuo Handa wrote: > On 2023/12/23 10:23, Paul Moore wrote: > >> - /* RED-PEN how should LSM module know it's handling 32bit? */ > >> - error =3D security_file_ioctl(f.file, cmd, arg); > >> + error =3D security_file_ioctl_compat(f.file, cmd, arg); > >> if (error) > >> goto out; > > > > This is interesting ... if you look at the normal ioctl() syscall > > definition in the kernel you see 'ioctl(unsigned int fd, unsigned int > > cmd, unsigned long arg)' and if you look at the compat definition you > > see 'ioctl(unsigned int fd, unsigned int cmd, compat_ulong_t arg)'. I > > was expecting the second parameter, @cmd, to be a long type in the > > normal definition, but it is an int type in both cases. It looks like > > it has been that way long enough that it is correct, but I'm a little > > lost ... > > Since @arg might be a pointer to some struct, @arg needs to use a long ty= pe. > But @cmd can remain 32bits for both 32bits/64bits kernels because @cmd is= not > a pointer, can't it? I'm not worried about @arg, I'm worried about @cmd, the second parameter to the syscall. I was looking at the manpage and it is specified as an unsigned long, which would be a size mismatch on a 64-bit system, although now that I'm reading further into the manpage I see that the command is specified as a 32-bit value so an int shouldn't be a problem. I'm guessing the unsigned long type persists from the days before 64-bit systems. > > I agree that it looks like Smack and TOMOYO should be fine, but I > > would like to hear from Casey and Tetsuo to confirm. > > Fine for TOMOYO part, for TOMOYO treats @cmd as an integer. Great, thank you. --=20 paul-moore.com