From patchwork Mon Jan 27 13:28:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Heift X-Patchwork-Id: 3542261 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A4519F381 for ; Mon, 27 Jan 2014 13:29:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0E832013D for ; Mon, 27 Jan 2014 13:29:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4248820121 for ; Mon, 27 Jan 2014 13:29:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753837AbaA0N3E (ORCPT ); Mon, 27 Jan 2014 08:29:04 -0500 Received: from mail-ee0-f41.google.com ([74.125.83.41]:41034 "EHLO mail-ee0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753687AbaA0N3C (ORCPT ); Mon, 27 Jan 2014 08:29:02 -0500 Received: by mail-ee0-f41.google.com with SMTP id e49so2283719eek.28 for ; Mon, 27 Jan 2014 05:29:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=funsdIe0spT0c1U7LYV8J12CamdVcMvjVAMxkuQeWDE=; b=lGzKudZRiiCf1ndmOoJ//IBcEoEelYRGUKvyKXGEMqVhwkEeuU9kVta4Pu6U3jQ6qf VwoKyiAVKHBt2++/8Qjioy+70nFv81lLZ2LNYowBdpdlq7iPJ6XBv6RsZYut7Lt4xBum XvIA3M7xR2PlSVhPitdlIlP7OXiY3HpB92TADjpT1pvLBrNWMhNEw1luyxPF2MS2AHTa fuYXFZQZPUVOodyfD5TJdpQ3QeZtlT52p2ldFBoQCnkjdamQs0Yj0j2UCla15M9rvnJO QXrEYNWzd7LBUAVJweRfXhTzmPp/IjiA0R4mcyf6wAj/MrZmBAUnZphS2+q8vAj5jabC 1Ejw== X-Gm-Message-State: ALoCoQlPsVfzGboUl2RInCH9cCV6kvDCgdB7YSjawBIIp3KBGyre10lD6aMqUpBrbfnp7BGvMSC5 X-Received: by 10.14.173.129 with SMTP id v1mr21233903eel.60.1390829339671; Mon, 27 Jan 2014 05:28:59 -0800 (PST) Received: from localhost (host-115-115.kawo1.rwth-aachen.de. [134.130.115.115]) by mx.google.com with ESMTPSA id o13sm42495353eex.19.2014.01.27.05.28.58 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 27 Jan 2014 05:28:58 -0800 (PST) From: Gerhard Heift To: linux-btrfs@vger.kernel.org Subject: [PATCH RFCv2 2/6] btrfs: search_ioctl rejects unused setted values Date: Mon, 27 Jan 2014 14:28:28 +0100 Message-Id: <1390829312-814-3-git-send-email-Gerhard@Heift.Name> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1390829312-814-1-git-send-email-Gerhard@Heift.Name> References: <1390829312-814-1-git-send-email-Gerhard@Heift.Name> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To prevent unexpectet values in the unused fields of the search key fail early. Otherwise future extensions would break the behavior of the search if current implementations in userspace set them to values other than zero. Signed-off-by: Gerhard Heift --- fs/btrfs/ioctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index be4c780..919d928 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1947,6 +1947,9 @@ static noinline int search_ioctl(struct inode *inode, if (buf_size < sizeof(struct btrfs_ioctl_search_header)) return -EOVERFLOW; + if (sk->unused || sk->unused1 | sk->unused2 | sk->unused3 | sk->unused4) + return -EINVAL; + path = btrfs_alloc_path(); if (!path) return -ENOMEM;