Message ID | 20231122141559.4228-4-laoar.shao@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08C7BC61D9C for <linux-mm@archiver.kernel.org>; Wed, 22 Nov 2023 14:16:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CC376B0617; Wed, 22 Nov 2023 09:16:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 254C86B0618; Wed, 22 Nov 2023 09:16:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F25CA6B0619; Wed, 22 Nov 2023 09:16:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DCD546B0617 for <linux-mm@kvack.org>; Wed, 22 Nov 2023 09:16:25 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B59E08016F for <linux-mm@kvack.org>; Wed, 22 Nov 2023 14:16:25 +0000 (UTC) X-FDA: 81485790330.12.80AAF95 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) by imf28.hostedemail.com (Postfix) with ESMTP id C495CC0030 for <linux-mm@kvack.org>; Wed, 22 Nov 2023 14:16:23 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TDenbw4Q; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.170 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700662583; a=rsa-sha256; cv=none; b=r664JoEFMZ30PIoltnJN7hCQfcH1zPIY8uDQf1tH20OO4QC74NkrRgDiQCDWsx0LHD/C10 eoAuplkjl0f1uwKeFORSKfVO3EhDkR3Xk4xCJl6hwEozXO5LMeyg+dpvh0hSz9RC4F6pIC tx4AaPtPBvMwYwLZTa5CkEHKedLfIfg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TDenbw4Q; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.170 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700662583; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jCohkZOlhmClx79gxDRv3lIssVMr2jJPQS/93j1RD9I=; b=MZfK6ZO6q7an+D/ed2c4Mrijcm6OKLOMWsf5TZNI79GCui2ajMQyvj+Zd5nN5QAHgrQDCG teCY4u4UX4P1ZGGHF7f1ZAIyVE1t7FDqZgsJmWwSHWAvnKbSqAvVJt0R5vaGO+dqWuew0Z GgI/7Q5Hs9O5EoJJz8No3cucdR4xnzk= Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3b6d80daae8so4399306b6e.2 for <linux-mm@kvack.org>; Wed, 22 Nov 2023 06:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700662583; x=1701267383; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jCohkZOlhmClx79gxDRv3lIssVMr2jJPQS/93j1RD9I=; b=TDenbw4QcLu/22Cwet3m0s44NIFrhnVV40lQ0QXqt6ZRHF8xt4FmhRi3CenWIfZ1pP 97lG9BXWWZs0oFwaR/+xwShzeaU17XxIe4h2/TsXD5r0hg7jDdiDLKfnVlk+no1GfnpG Jv0fYA7keVnb/gLdzFMmNy6MxKcjbiLDFw+i2Hx5i2/X3rOmf0ll7nGuO/pf1BAupchh 8hvnY4S7BvuUjslz5nUi6k/kDPsnT5vucpodmJF96xmHxT0ZXCtgfHfPzxXYOczTBkRF 06mASav614pqF+CES60dAP3wlWZ7O640hF7Vzfubj0NxaV8JmKXfLP/DBgOEBSRPDTWH l2Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700662583; x=1701267383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jCohkZOlhmClx79gxDRv3lIssVMr2jJPQS/93j1RD9I=; b=mLbPe2uL0ks6jgSB0JIydhtkIuhXIRs1aMynHqphNPo80Dg9sMMFgT6VGlTefjDGVk htyCR1NS/IlZSsqqA4v2B3tdBxDQgyD13q5CHp1CK0vXMhdPoWyILBHqXRvsxDd6iPQU mtV3z8xRaZITdIjwKgBIv43+a2zJxfgzqnU7nm/s1NnibXSHw9R94qGEqfIPR5UaXTGt lCzL5+HgENozSy35/4YZrI8rP54hZ8GU0nin0CjNOoeyVIzHVKH5yPCm5SQ5qelXEYjg urG8V3m5+2lNw39HDxbtNX4Yp7E7wqPrFZ9WvQ+JtNOPDnz2ZQxA+4UUajtjYI6t2apL xE4g== X-Gm-Message-State: AOJu0YxVGCSkr1EAM4beISkd5ETW9j6rZJGKxO8OBvtx+hIQspk9nUUV MDcIc46zyEqo3Bg8wna2ENw= X-Google-Smtp-Source: AGHT+IFPQzNlhHQv85DvH7rICMBG6EPDsKSzKKxxrGWE7E6Dc9LlipZ3FkuurVVO/TYfDh7rCoO6nw== X-Received: by 2002:a05:6808:f87:b0:3b2:f54b:8b1f with SMTP id o7-20020a0568080f8700b003b2f54b8b1fmr2792746oiw.35.1700662582831; Wed, 22 Nov 2023 06:16:22 -0800 (PST) Received: from vultr.guest ([2001:19f0:ac01:a71:5400:4ff:fea8:5687]) by smtp.gmail.com with ESMTPSA id p18-20020a63fe12000000b0058988954686sm9356260pgh.90.2023.11.22.06.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 06:16:22 -0800 (PST) From: Yafang Shao <laoar.shao@gmail.com> To: akpm@linux-foundation.org, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, omosnace@redhat.com, mhocko@suse.com Cc: linux-mm@kvack.org, linux-security-module@vger.kernel.org, bpf@vger.kernel.org, ligang.bdlg@bytedance.com, Yafang Shao <laoar.shao@gmail.com> Subject: [RFC PATCH v2 3/6] mm, security: Fix missed security_task_movememory() in mbind(2) Date: Wed, 22 Nov 2023 14:15:56 +0000 Message-Id: <20231122141559.4228-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231122141559.4228-1-laoar.shao@gmail.com> References: <20231122141559.4228-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C495CC0030 X-Stat-Signature: 46eexah6ow7tmwcdesqqb3dqh6hssyoe X-Rspam-User: X-HE-Tag: 1700662583-568625 X-HE-Meta: U2FsdGVkX19cp0msk+bM1ENi1U8+GHshBbke0OwKuW01MAYkrk+/OZouZwmEnb92XpaAcQglMOQuvFA7QaRgt5mvqUAweJ6yALvU0NCuIAqhq5xvR3lGvFZduQ+jJhHaCU+FeHiRGXm+OHh0xDd8cTZUnb7p4V8N/Yya+wg2NYSVDQhOPm8PY4SsGbTpXboHhs6GNem6G4XUNphqglIICWb6ZF0E23R6I+W1xI8lzhwmLX/VqvadCblZ+HXITGxxBlahWfbG+JZjWdQxevoar8NnBNrtR0QDf8ANxN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+LxUVY3O6kNRPnwyHZK8aONPJNf2E9AaTT4sQINVNAF6hbgbpGNHDrXecVkbW4FfTIC4TUFhOykmoPGl03PRXyboiw8y+1DmQ/ksB0nLxhQlPa47lZgnRwKizMD+HKZhspGiz45o0RkCDiEgr3xzjzdcCMMD2+5DWFhBxajVaJtImzbBGGO7rQRFlk7dPdk4tcdOerlK5b43WnYs+mY9YD9oFqYcgfvAcBLp9jnW9GIYBbgwdsr2433VvU/sw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.002938, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm, security, bpf: Fine-grained control over memory policy adjustments with lsm bpf
|
expand
|
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 10a590ee1c89..ded2e0e62e24 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1259,8 +1259,15 @@ static long do_mbind(unsigned long start, unsigned long len, if (!new) flags |= MPOL_MF_DISCONTIG_OK; - if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) + if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { + err = security_task_movememory(current); + if (err) { + mpol_put(new); + return err; + } lru_cache_disable(); + } + { NODEMASK_SCRATCH(scratch); if (scratch) {
Considering that mbind(2) using either MPOL_MF_MOVE or MPOL_MF_MOVE_ALL is capable of memory movement, it's essential to include security_task_movememory() to cover this functionality as well. It was identified during a code review. Signed-off-by: Yafang Shao <laoar.shao@gmail.com> --- mm/mempolicy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)