Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1344919lqb; Thu, 30 May 2024 07:41:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFbjp+HCzkkNFjLAgm8To0BrntglAn8HMVyYbOPEN7pzwuAAJNHhuDBuEIavjPWBboQ+NNLMQqxvPrjyLn0evvCivAJKo7c5/4wZgX2Q== X-Google-Smtp-Source: AGHT+IH6J5RjCfuz7qs8y/HUFpeOcQEz2VoPDRT/ETmQQdJq12heeldr8fzWC+WldGjEm08pNh2K X-Received: by 2002:a17:90a:ba8b:b0:2c1:b92a:f385 with SMTP id 98e67ed59e1d1-2c1b92af540mr963740a91.46.1717080078969; Thu, 30 May 2024 07:41:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717080078; cv=pass; d=google.com; s=arc-20160816; b=GyBG9jzx+ahTnA+f0gkCL0ir98Sfq9zxg2+hP1RxkHme/KXw66YGIss1+nNM+D+EjF ip8nYqbfFf+HGD8sYOxjky7+/CFxct6zc5hFWpLRNEGVijt5XpcwGgU+asxBk6RZRAW3 1pGYH6xIzIH+1e7I7D6eq0M/RBQC2VGJaM1IGS9EMj0TFPaoggHA3R7f6e1W2ebd92ry 3V44bVqmhXgbIv3TuxPB8RPzoCvsL0NLY/lVC2UuNzKdhp3tVlBQ+w7u8GoFwodZpj2j upmtpMfHPtvnDDAhX4XsR3AmR+8SkMl0lyxiSZehAg3V2YZzR1iqYswp7DOeZahPs7cT 46wA== ARC-Message-Signature: i=2; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=MiUZAyRllirKKzsD89/yIKCX3SIy5qsFBAtFuiUEDms=; fh=4GHZG+AOVEigHh6r61FduoQ33y3pZOtvCAKp+jKDhF0=; b=Cyi5hC7i1QYgx7Yj4pQuK2jUhH0cxoffvkqNUeg4ilCD1l8uTbF2oUhNYFhIcA8K0T yI6EiGe5cPQB4yQ+eH2cRbYgxOAVmm44xNvX+5SRIF2vCU2Zz2iRu+c2y+4CJufWGmwN wHeft6dEra5mguylM+HqvhKsPVKFF1Ar2teMO1nE5x1jMWbTUwvR7YGYPLZyY+nv0s2v SWyXdlQM1oYSAXbexsBKmy6sXaFXbxCOs25peizD4bPRniIDpR8nYMwIKueEnaORzG5L QT0GHRlFvSM7ipXPHWAWm8a/0tT1w1wmo/FxGpGZGm9Oj867sFfL19CBezUuHzTWFhSI K4Rw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X7k4EgZF; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-195538-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195538-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1a7784ecasi1731511a91.76.2024.05.30.07.41.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 07:41:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195538-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=pass header.i=@gmail.com header.s=20230601 header.b=X7k4EgZF; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-195538-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195538-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 87961282A98 for ; Thu, 30 May 2024 14:41:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2DE617C223; Thu, 30 May 2024 14:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X7k4EgZF" Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 80F6F186E41; Thu, 30 May 2024 14:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717080051; cv=none; b=m5HylEPwVQJfLbaxA5PVNq1qqrZc9htSPJnkh+kzSuI+P+wwvJ0nRlmHuL9GWxdOnh7RXrXob2Gpa53Qae+PDT77AnYVslYyvzHxthozP7k7ijAfNkUD9TXyRP019WTZBJTNjEmIc/FOKeEHnYY47rwgn/pet7eP0TlR0QRTAN8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717080051; c=relaxed/simple; bh=XWlxAnuC/u9UwVSre4Bh7CKn2L/WZWSl+q4IsHzdHg0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=O+FwoD0hG46yW1cUgfWZ0coGCKP94Qhu6hOobfliBTlHvfH2AZKEcWegurMbrDBGwtsCs7FXA6Q3W96jSaOTvCVp0G5H3DPjmWMohquYLk0btWR0y0C4jfgltc9vfPBrAFH3XkBkLm/pPetRLilbBKx/dwQcWI3QP//jLXbe8Zo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X7k4EgZF; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-52b79447c58so1368664e87.1; Thu, 30 May 2024 07:40:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717080047; x=1717684847; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MiUZAyRllirKKzsD89/yIKCX3SIy5qsFBAtFuiUEDms=; b=X7k4EgZFA2ZOU1fNksV7NmNlzXAmfMbX8++wQQ3wxibs/OAJjhxNcfFxJJNU1oxaqn o118YyNLk5Q8E3InBOJPZH+s9sFjZxRkQqlm4LLEXI6grZ3++quj38w98KYdpsYT1Y8J K/jotjBrFV3TXCTyr9CBqhytGG4mT/TaLUj0eBx+ACWj2XyUuBPlMCZiM+hPW0Y6OzSu rMuLZMtJiv4zTVjlEaXAHCBY2nVfGaBKWKXOfccwI3P3aRSC6nbgAR2fxBKgBBUcwq/U 4phxfu9mXLb0dUC4oTY1klYLc7V/8RELWdFzxByAOeQ7TFIiY17u1LgZiqarGZ4Qc2HM wYsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717080047; x=1717684847; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MiUZAyRllirKKzsD89/yIKCX3SIy5qsFBAtFuiUEDms=; b=jBfqzpBT4HH0W2rq4Br2Zpvn+UHhngst+LCB74HK9xMyxbR+xxIIAmW5BD07/ZoSt1 Merl6qh3WgT8tA6TVRlECFbtxuvEkFa+mPhYTO97IgKggG1kFLell0gE5PC9uquHRDKL sIFUz2LYo0Dk4yO8jc/ypZqeLoVENkEc3kIYWAzQjGQtK6Al2BdoZoceJ5ucHqPnaTp/ wKqAfAf48YzegBa1Ph3WuHVOjScxdkOdDlVoGrWHvBUbwhJsB6Vcmz8xELUS0plZneIJ ik+Fywfje9TQX+s4gOEGXntXUSq4yaYCirWBVXQ/9SqbYzYTFHdWkW+U4ug5HXpF5lcz blSQ== X-Gm-Message-State: AOJu0YwTDpvykcwkz9PkG8jpw/X4iq8fFzsrpWdzgHV46singNoGknW0 jAYrVq8U1mhbRMJcrnlZZYLy92w+SYYlN27nhSWv/kbFP9f7Evh8jmUXoTk5 X-Received: by 2002:a19:430e:0:b0:52a:a91e:3f55 with SMTP id 2adb3069b0e04-52b7d499782mr1658316e87.47.1717080047196; Thu, 30 May 2024 07:40:47 -0700 (PDT) Received: from f.. (cst-prg-8-232.cust.vodafone.cz. [46.135.8.232]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a66dbfc4ca6sm27932366b.165.2024.05.30.07.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 07:40:46 -0700 (PDT) From: Mateusz Guzik To: linux-security-module@vger.kernel.org Cc: linux-kernel@vger.kernel.org, paul@paul-moore.com, Mateusz Guzik Subject: [PATCH] cred: plug a hole in struct cred Date: Thu, 30 May 2024 16:40:40 +0200 Message-ID: <20240530144041.569927-1-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit /* 40 | 4 */ unsigned int securebits; /* XXX 4-byte hole */ /* 48 | 8 */ kernel_cap_t cap_inheritable; [snip] /* 88 | 1 */ unsigned char jit_keyring; /* XXX 7-byte hole */ /* 96 | 8 */ struct key *session_keyring; jit_keyring can be moved up to the 4-byte hole. Size goes down from 184 to 176 bytes. Note total memory usage does not go down because the struct remains backed by 192-byte chunks, but space is made for future expansion. No functional changes. Signed-off-by: Mateusz Guzik --- I have some plans to hack up distributed reference counting for this struct, soon(tm). Should it land it is going to add at least 8 bytes. But even if nothing comes out of it this looks like a trivial clean up worth including. include/linux/cred.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/cred.h b/include/linux/cred.h index 2976f534a7a3..a936a291e9b1 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -107,6 +107,9 @@ static inline int groups_search(const struct group_info *group_info, kgid_t grp) * that task is going to act upon another object. This may be overridden * temporarily to point to another security context, but normally points to the * same context as task->real_cred. + * + * NOTE: some fields have placement picked to plug alignment gaps -- don't + * shuffle things around without looking at output of pahole(1). */ struct cred { atomic_long_t usage; @@ -119,14 +122,16 @@ struct cred { kuid_t fsuid; /* UID for VFS ops */ kgid_t fsgid; /* GID for VFS ops */ unsigned securebits; /* SUID-less security management */ +#ifdef CONFIG_KEYS + unsigned char jit_keyring; /* default keyring to attach requested + * keys to */ +#endif kernel_cap_t cap_inheritable; /* caps our children can inherit */ kernel_cap_t cap_permitted; /* caps we're permitted */ kernel_cap_t cap_effective; /* caps we can actually use */ kernel_cap_t cap_bset; /* capability bounding set */ kernel_cap_t cap_ambient; /* Ambient capability set */ #ifdef CONFIG_KEYS - unsigned char jit_keyring; /* default keyring to attach requested - * keys to */ struct key *session_keyring; /* keyring inherited over fork */ struct key *process_keyring; /* keyring private to this process */ struct key *thread_keyring; /* keyring private to this thread */ -- 2.39.2