Message ID | 20230807123323.020870574@infradead.org (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 2236CC04A6A for <linux-mm@archiver.kernel.org>; Mon, 7 Aug 2023 12:37:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3A08900004; Mon, 7 Aug 2023 08:37:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B49A46B007D; Mon, 7 Aug 2023 08:37:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79FD18E0005; Mon, 7 Aug 2023 08:37:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2CB188E0002 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 08:37:10 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DF46A140A14 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 12:37:09 +0000 (UTC) X-FDA: 81097258578.10.95D7C8C Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf30.hostedemail.com (Postfix) with ESMTP id 087F280016 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 12:37:07 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Co5btgZE; dmarc=none; spf=none (imf30.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691411828; a=rsa-sha256; cv=none; b=oLZzVXGafNw069f8YD2+61WOGMeLF8PmJd5IDKDD1/48YgdaahhM5m1uTnaxcrQwS+wTM4 ypjuLUNg2Cq4eGgiV0o/APN42jHglZPRJ2g+2MWjIpA7+uCZKFflXVd+5A0xs95zbJpSHR 745a6NWu3aohoQi9Mqh8p6lppjXqxWY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Co5btgZE; dmarc=none; spf=none (imf30.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691411828; 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-type:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=1Epi3uPitQ1on7D3YBD3uiLy0TLxJfWf5bL2Vyq95Dw=; b=VHM2XS05fHSWgZVEoJcLpghyfjNCXw5bzoq/UL1cv739kNeSPr6YpZx9/pdpUOnL9wmPu9 e5Aik6Nb99ZRQ6s2xs3ExWGBxeN4k5G/uNQtsID8P2W/6Lhz/GFHTtS8oEwEEpwhGZ3TfR WW5qI5mD4+PMOp8mMripFGPmOvbwuqA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=1Epi3uPitQ1on7D3YBD3uiLy0TLxJfWf5bL2Vyq95Dw=; b=Co5btgZE3bcLd6z8lfAD2yNF2L ng1KYKs/j+LRyQXyEVivIfQ47vWvqix6Wv8uRYB11Zf6YAPWQ2Kzx6ArCzkOTTWGT+8XCPQ7uXuEW vDAkp51vggTuX10agZQ0yg3W576dARN+M8hwxlyoPwRGjE1XOB0MhUIjhFWN9aJ7vL1eea62cfgP6 NvnVZop5Z9+vAD7rvcXJhH1RecuHIqRh/u8NJKUmTnog33pDpfH/OHUZ4xTe7JYu2pvydxZvXodvi 2IHrCULJhmfjc6eogA90H7UhlDF3UynqeHLBuojaS/A/nCPh7Z4kvOMBaOLWLDVm17tOL1bQyvxXM L0ZUXWwQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qSzTk-003oSd-1J; Mon, 07 Aug 2023 12:36:56 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D1BF4300473; Mon, 7 Aug 2023 14:36:54 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 986A62021C3D7; Mon, 7 Aug 2023 14:36:54 +0200 (CEST) Message-ID: <20230807123323.020870574@infradead.org> User-Agent: quilt/0.66 Date: Mon, 07 Aug 2023 14:18:47 +0200 From: Peter Zijlstra <peterz@infradead.org> To: tglx@linutronix.de, axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, dvhart@infradead.org, dave@stgolabs.net, andrealmeid@igalia.com, Andrew Morton <akpm@linux-foundation.org>, urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com, Arnd Bergmann <arnd@arndb.de>, linux-api@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, malteskarupke@web.de Subject: [PATCH v2 04/14] futex: Validate futex value against futex size References: <20230807121843.710612856@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 087F280016 X-Stat-Signature: b4x3hiby6hqw3517j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MAMTciAPcnY0m5JOZoDf8BC+QPodYutBGVRK/iq+laVhJaTVTYPyfJC+vt3pjn7Nil0w/74tFpQbtfbE6/vEYCiEMvAsbwVbdhKpkZwokqO4Rl6XBXgGb5+T00IxLJO/w9c1lqcqgmh5RvH764TJxx4JNeb2a4IUW4QmK0A+fX4lmST1XHzYO6T125vicstOWGp5qr0q/0qPL6deMymAA7T7VuHvWHyBRnMSlMy4ng== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
futex: More futex2 bits
|
expand
|
--- a/kernel/futex/futex.h +++ b/kernel/futex/futex.h @@ -85,6 +85,16 @@ static inline unsigned int futex_size(un return 1 << (flags & FLAGS_SIZE_MASK); } +static inline bool futex_validate_input(unsigned int flags, u64 val) +{ + int bits = 8 * futex_size(flags); + + if (bits < 64 && (val >> bits)) + return false; + + return true; +} + #ifdef CONFIG_FAIL_FUTEX extern bool should_fail_futex(bool fshared); #else --- a/kernel/futex/syscalls.c +++ b/kernel/futex/syscalls.c @@ -209,6 +209,9 @@ static int futex_parse_waitv(struct fute if (!futex_flags_valid(flags)) return -EINVAL; + if (!futex_validate_input(flags, aux.val)) + return -EINVAL; + futexv[i].w.flags = flags; futexv[i].w.val = aux.val; futexv[i].w.uaddr = aux.uaddr;