Received: by 10.192.165.148 with SMTP id m20csp3094585imm; Sun, 29 Apr 2018 14:00:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhVuGyVG4n5OiwpnA1TkgW9iprkzuGpwugPSwe/CzIILaIDv4XlKuPXcmnzdNPGmYN79Fd X-Received: by 2002:a17:902:6b47:: with SMTP id g7-v6mr10111613plt.251.1525035609200; Sun, 29 Apr 2018 14:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525035609; cv=none; d=google.com; s=arc-20160816; b=OeInRXEybtMjBB9bNBAkCaJss2Ff56d4zLzbAyzuufTejB67e/LB16jRQJ1Wj9DLUm Y0sRunIgzaqOMXEFnUQQV3VKo0boqYzk/XgQOPu9dypD8w6m0OeBQAamxVjFdc7e4R3m wo4O3pdXQ4cB3vI5E/lIrWIG/hu7OIzxA8A4S0IuyXOfKe4cLXj7aiCpJzmczdFnE7si j0mmygVKoUch2DyHpA7mGWWXNX13EINLM4ALd3airSuANLea41+JVwN44AmntHpsa1Lo p1btH+hrcu6qaUqnj9cEpiCbCeAXFNqMMlW9YeaowDC4NXB52G6gE5SIDPvMHwn+iYqD Q3mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=nPtlXiLP56vSijSDh6Wlq5XS+Of0MzvEKfmypTIddqE=; b=Ahc6nnqYEy4SRMlPTwj6X2qLeQMbQrc7SgBeSMqKQwakZndJucOnXK+tDxoqd42ZhU B5hx1OoEKMIY0v4u4E5cCsxhjqDa7KYMYTPQVWoN8Ue4YNARDOcK0Keb0o576OefEJ5A dySnDD+3553rq3fMAHEowgugUSe9FbhXqCPDDaqeNr3eUFVt2SUNC/Kqw9kbMnbY+Xgd 3P/D8/AeoUe05UDcTWE4iwdsZSRPTKXuvOLKBBluJlW2LgOdCrC57jTU4A0jFtAJ1etr TsD/fs323TwX1JTHC+5qRZpmP4+I94GcG/3H2aPHTHtJYmj4go2SI3rcuu4fquJWJAMS hLEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=20160920 header.b=dtcpUvhp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi5-v6si4224533plb.190.2018.04.29.13.59.53; Sun, 29 Apr 2018 14:00:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@umn.edu header.s=20160920 header.b=dtcpUvhp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754249AbeD2U7j (ORCPT + 99 others); Sun, 29 Apr 2018 16:59:39 -0400 Received: from mta-p3.oit.umn.edu ([134.84.196.203]:52698 "EHLO mta-p3.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750815AbeD2U7g (ORCPT ); Sun, 29 Apr 2018 16:59:36 -0400 Received: from localhost (localhost [127.0.0.1]) by mta-p3.oit.umn.edu (Postfix) with ESMTP id E32E0943 for ; Sun, 29 Apr 2018 20:59:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=umn.edu; h= content-type:content-type:subject:subject:message-id:date:date :from:from:references:in-reply-to:received:mime-version:received :received:received; s=20160920; t=1525035575; x=1526849976; bh=2 Q6LC6kZgysw3j1rWMfF5q1QAsY8cwUbV3Zjqi45tiU=; b=dtcpUvhplv/SQ3Ddy +0cHbJNGzjSTCkdMvL00AXGI2r+TcUB5HoEIN9/V0UEEkO0jtVnkCmMj5D2oGoli NJKPRg20dwOFr38lnY0ZXQvAzjBNiP6RXN1XKXSaxzjSqMJFMDdt3Y1D0PSWAKY4 MYxkuyJQDu6RHdyf7FOal0u1+PodYLMkmSNqIKILhxdQU0BK2KGjDp9cZzrL5j61 e/edKwB5ERkU1qpbwUPu17CX3b/iL/CVdnjGtBZgJcnCcApLf+1wOpwmSpeatMln n+MQmsJ3rmQLM+QuULG6hUry2g0EldDorZORe0UDR3JpLs8jEAPBWr5F5alLW32V LjIdw== X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p3.oit.umn.edu ([127.0.0.1]) by localhost (mta-p3.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XwuGW53rQuWB for ; Sun, 29 Apr 2018 15:59:35 -0500 (CDT) Received: from mail-io0-f175.google.com (mail-io0-f175.google.com [209.85.223.175]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: wang6495) by mta-p3.oit.umn.edu (Postfix) with ESMTPSA id AEBBB91E for ; Sun, 29 Apr 2018 15:59:35 -0500 (CDT) Received: by mail-io0-f175.google.com with SMTP id z4-v6so8193832iof.5 for ; Sun, 29 Apr 2018 13:59:35 -0700 (PDT) X-Gm-Message-State: ALQs6tCwYlM4sW0tys36PLwuYouBiN/OXBseIGbpHlCCNytapKZTOp+G 0XUYMx6uSVnQs0OwMWatR//ctVdTEXx5KHOXKsg= X-Received: by 2002:a6b:200e:: with SMTP id g14-v6mr11004364iog.161.1525035575414; Sun, 29 Apr 2018 13:59:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:6f07:0:0:0:0:0 with HTTP; Sun, 29 Apr 2018 13:58:55 -0700 (PDT) In-Reply-To: <20180429132058.GB5972@kroah.com> References: <1524872704-13391-1-git-send-email-wang6495@umn.edu> <8E6ADED8-592E-4794-8CAB-913A325B1971@intel.com> <20180429132058.GB5972@kroah.com> From: Wenwen Wang Date: Sun, 29 Apr 2018 15:58:55 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] staging: luster: llite: fix a potential missing-check bug when copying lumv To: Greg Kroah-Hartman Cc: "Dilger, Andreas" , "devel@driverdev.osuosl.org" , Ben Evans , Jeff Layton , Aastha Gupta , "kjlu@umn.edu" , NeilBrown , "linux-kernel@vger.kernel.org" , "Drokin, Oleg" , "lustre-devel@lists.lustre.org" , Wenwen Wang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 29, 2018 at 8:20 AM, Greg Kroah-Hartman wrote: > On Sat, Apr 28, 2018 at 04:04:25PM +0000, Dilger, Andreas wrote: >> On Apr 27, 2018, at 17:45, Wenwen Wang wrote: >> > [PATCH] staging: luster: llite: fix potential missing-check bug when copying lumv >> >> (typo) s/luster/lustre/ >> >> > In ll_dir_ioctl(), the object lumv3 is firstly copied from the user space >> > using Its address, i.e., lumv1 = &lumv3. If the lmm_magic field of lumv3 is >> > LOV_USER_MAGIV_V3, lumv3 will be modified by the second copy from the user >> >> (typo) s/MAGIV/MAGIC/ >> >> > space. The second copy is necessary, because the two versions (i.e., >> > lov_user_md_v1 and lov_user_md_v3) have different data formats and lengths. >> > However, given that the user data resides in the user space, a malicious >> > user-space process can race to change the data between the two copies. By >> > doing so, the attacker can provide a data with an inconsistent version, >> > e.g., v1 version + v3 data. This can lead to logical errors in the >> > following execution in ll_dir_setstripe(), which performs different actions >> > according to the version specified by the field lmm_magic. >> >> This isn't a serious bug in the end. The LOV_USER_MAGIC_V3 check just copies >> a bit more data from userspace (the lmm_pool field). It would be more of a >> problem if the reverse was possible (copy smaller V1 buffer, but change the >> magic to LOV_USER_MAGIC_V3 afterward), but this isn't possible since the second >> copy is not done if there is a V1 magic. If the user changes from V3 magic >> to V1 in a racy manner it means less data will be used than copied, which >> is harmless. >> >> > This patch rechecks the version field lmm_magic in the second copy. If the >> > version is not as expected, i.e., LOV_USER_MAGIC_V3, an error code will be >> > returned: -EINVAL. >> >> This isn't a bad idea in any case, since it verifies the data copied from >> userspace is still valid. > > So you agree with this patch? Or do not? > > confused, > > greg k-h It is worth fixing this bug, since it offers an opportunity for adversaries to provide inconsistent user data. In addition to the unwanted version LOV_USER_MAGIC_V1, a malicious user can also use the version LMV_USER_MAGIC, which is also unexpected but allowed in the function ll_dir_setstripe(). These inconsistent data can cause potential logical errors in the following execution. Hence it is necessary to re-verify the data copied from userspace. Thanks! Wenwen