From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (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 25CA83914FF for ; Wed, 27 May 2026 23:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779925357; cv=none; b=VH3Z6WvV5XuvsqLJ0OYw+Q/KDCTJbMoXsowYpPZWj181u3x8J8M5L006Cp8lscxrVj+6QDUoivn/IwbfT/Suht+gYnsI262Q0wUJdBss+N+dyt6mseZXtFQe17AsvuefXUqSpHRxU7tb7PlYsyPAe/PIDXgs3c5ijVmF0StBPwc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779925357; c=relaxed/simple; bh=bFhoZtKMfAkJEwxLgJ6/oZuzCLxHsvUxFVvVuDQhd20=; h=Date:Message-ID:MIME-Version:Content-Type:From:To:Cc:Subject: References:In-Reply-To; b=c99A8/QHal6AYLMzo3kgUNeowPxdRuywpV5e/INh/Nx8MBX2JY4ziG2uZnRftKMrpxlFGoMyrbTeNAko6UoCqjHCl5kF5aNSIn4vFS7IhKy42kNu+G7TX48HG/hrJ618lo3lIHUTgK6M1mmROJVy/HHUJuFc2/2QYIA61FiL2qI= 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=MDbxYhSU; arc=none smtp.client-ip=209.85.222.195 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="MDbxYhSU" Received: by mail-qk1-f195.google.com with SMTP id af79cd13be357-914ae4101b4so814133485a.2 for ; Wed, 27 May 2026 16:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1779925355; x=1780530155; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :mime-version:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=vWtSF+ZdJPKnDl6l0dlAcmnN+0WDS6LYwhPmb91DFEM=; b=MDbxYhSU8a1NXFKJ4BLckTioTxA6dz/9OKssB30bXmIC2aX9PwG3sb6SyK5dQhT378 eYEB4iLolxeC/kIUfeQxaujeoq4VG30rDG2P/wo8uAdSYLUIZSLoDM5y0TSoY5kJmNJx oHsdLuJ6DLJbjnq0DhSuvJgkgjhf5R0bYUXsmpq9Qd7K2Yy7LrjjTKeFpVW5AkstFf/F rbfkEzac9Ci0TFwoxMSQNKaXTrO/Fmekpng+MeiWgmgMzXqgTBYUxNEaocn8shyzyfWI 3+lb0W2OqCyTfZK9gT7QNFaGHXB2ZpFOP9lGyGUcwoBV7VEpf4vto10jc1qN7MYeK9tU CLNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779925355; x=1780530155; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :mime-version:message-id:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vWtSF+ZdJPKnDl6l0dlAcmnN+0WDS6LYwhPmb91DFEM=; b=CG/tZ1+V9WbWJY21kZ2Zuf+Azyjtb9IHbqIMeM5D9MsJ7CdCx0noA+rBb+pluaJ/Gx nZEZSDKexJIJSUezjDBgQngjjV0NJ1ohM/UGC79yOKgAm5/08qijvqVJA/2W8kOU1tXO PAb6l9jyJlgk9yfP4Pm6ePHKLnXrfyP8Uh1fKyEmpvoe3E3SH6JxRzDBpYN/AF1c2nn7 gSddEW3V8/gnjSKS5+tK7bBhrCuyk7mkrvHiTc/vHN63nqv/a4Gk6DZ+iYoEUG+ZfFwY xfTTdhJCI793I76fO0Ba0INumxwrLk+DPQUmrxd+ighOvGwF29HTZLMELQhUukSU/5yk XZMw== X-Forwarded-Encrypted: i=1; AFNElJ9BZIXC3jZMLkJeg6McMlstlVGxdV/vGxfc0sWDRyrrWTzN3/pRanF9/oxzt165MbiLYZBnD5YpW7WOiEg=@vger.kernel.org X-Gm-Message-State: AOJu0Yys9nWFh5An8GvmmVhBzWG4PxRuuM1VjDnGygPifMcuk5CKu4HI BQn9YPbXWGjkMzbHHSP7QWBOR5PK2u/sStx2Z+lERnw4Ql02JUo/L5jnekG36Zbm4Q== X-Gm-Gg: Acq92OEMyNGV+hq3eHHUR5hi/os53Hv5h/TOOxbbud50KmJXAOQQ8ULxWnkoRho4tLL YS6Dvf2t1lbtpEjEgyyMq4HNLgTAXroJCFNEzeQF9oYEEeeHnRic2rcvqDsRJkMKPSOXm44n2KE eEQvXyfCKKwQn0oYZchMlzuzqafHGePbkcImKw5gYwQfBzBvs6PZI4ArZQ69r+3gZuk3TNwPTpV yZajEvSJWRwGR30tckqIrFMonJ9pWIW76bGWreMUFmn+N9pHWsxhXUEhihcBQd0psds4BIbkubd yOqDAbFYT/+skKko4r+hTetYSeagnRIdGMCu/L7NVQNPuo1mrBwWeTpRtuYFOH1KJBmzPbnUiU2 WdMu7jHrdiL/J1/E0chDmX7WKOaMw8XZwzxjMtYI3Xqh2vPJlrctcNILCjr6cs2OWzkpP75LXVM qsbIj3Cp84YFVIDbiwftwBEMXmgWpymQ6AID2wsasMNcq8F9hC2T4x1gZAuut29UY4iRZT6hlwN N9y5gZupIY8inGgoQ== X-Received: by 2002:a05:620a:290b:b0:910:87f4:9a26 with SMTP id af79cd13be357-914b49937b6mr3695400885a.41.1779925354972; Wed, 27 May 2026 16:42:34 -0700 (PDT) Received: from localhost (pool-71-126-255-178.bstnma.fios.verizon.net. [71.126.255.178]) by smtp.gmail.com with ESMTPSA id af79cd13be357-914f8706968sm615403785a.17.2026.05.27.16.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2026 16:42:34 -0700 (PDT) Date: Wed, 27 May 2026 19:42:33 -0400 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: pstg-pwork:20260527_1931/pstg-lib:20260527_1608/pstg-pwork:20260527_1931 From: Paul Moore To: "Mike Rapoport (Microsoft)" , James Morris , John Johansen , Ondrej Mosnacek , "Serge E. Hallyn" , Stephen Smalley Cc: Mike Rapoport , apparmor@lists.ubuntu.com, selinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH 1/3] selinux: use k[mz]alloc() to allocate temporary buffers References: <20260520-security-v1-1-831bd8e21dd0@kernel.org> In-Reply-To: <20260520-security-v1-1-831bd8e21dd0@kernel.org> On May 20, 2026 "Mike Rapoport (Microsoft)" wrote: > > Several functions in selinuxfs.c allocate temporary buffers using > __get_free_page() or get_zeroed_page(). > > These buffers are used either to store a string generated by snprintf() (in > sel_make_bools()) or to copy data from user (sel_read_avc_hash_stats() and > sel_read_sidtab_hash_stats()). > > Such usage does not require struct page access and it is better to allocate > these buffers with kzalloc()/kmalloc() that provide better scalability and > more debugging possibilities. > > Replace use of get_zeroed_page() with kzalloc() and usage of > __get_free_page() with kmalloc(). > > Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com > Signed-off-by: Mike Rapoport (Microsoft) > --- > security/selinux/selinuxfs.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) I suspect if we look closer we can probably also trim some of those allocations to less then a page, but that can be work for another day. Merged into selinux/dev, thanks Mike. -- paul-moore.com