From patchwork Sat Jan 18 00:15:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Heift X-Patchwork-Id: 3507661 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 B2AAD9F390 for ; Sat, 18 Jan 2014 00:16:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD9782017E for ; Sat, 18 Jan 2014 00:16:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1ACEA2017B for ; Sat, 18 Jan 2014 00:16:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752762AbaARAQV (ORCPT ); Fri, 17 Jan 2014 19:16:21 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:50993 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144AbaARAQS (ORCPT ); Fri, 17 Jan 2014 19:16:18 -0500 Received: by mail-ee0-f53.google.com with SMTP id t10so2411573eei.12 for ; Fri, 17 Jan 2014 16:16:17 -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=PDzJFgaY2/MPNNcq+nPo7DNNjZPoiBza2ZeUDAcmmuq9Ri/qPJeu+qO4gTld3vzLEF iVn4pq4Hs0XbT9bQKnWf3gqM52YULqCB2geQeCR4TtgzkUStRsmxeuN5GUcfrfteJEza QCs1HHU3c65aHAIz339y6vikMdn4Mx08qMLnnpzZ1OLCnS3fifRDB+ZjKx7bMPzLo/rE jTjGhErlajX7wKZPbsC2GEU/l0SFMZ196z/X0RJUPNrSda8RI4EjLN+gN4opMFC4fobc xpcjEcqgYwSK840BAzwb+B6FMhLUyiY9qwTgFtX5mOQhNZXqAHgCxRAnqYOJKu4Khx6B lzDw== X-Gm-Message-State: ALoCoQlyrnVNxRXFsv/GZhjm4LLkEeBl5BPZGYSQCagc0p3ulnKpWuApxNwOVQwTh+YGZAH5jeOI X-Received: by 10.15.48.201 with SMTP id h49mr5275355eew.43.1390004177812; Fri, 17 Jan 2014 16:16:17 -0800 (PST) Received: from localhost (host-115-115.kawo1.rwth-aachen.de. [134.130.115.115]) by mx.google.com with ESMTPSA id 4sm30848872eed.14.2014.01.17.16.16.16 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 17 Jan 2014 16:16:17 -0800 (PST) From: Gerhard Heift To: linux-btrfs@vger.kernel.org Subject: [PATCH RFC 2/5] btrfs: search_ioctl rejects unused setted values Date: Sat, 18 Jan 2014 01:15:50 +0100 Message-Id: <1390004153-4228-3-git-send-email-Gerhard@Heift.Name> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1390004153-4228-1-git-send-email-Gerhard@Heift.Name> References: <20140116150710.GL6498@suse.cz> <1390004153-4228-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.2 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;