mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] staging: lustre: llite: fix potential missing-check bug when copying lumv
@ 2018-04-30 22:56 Wenwen Wang
  2018-05-01  4:06 ` Dilger, Andreas
  2018-05-01  8:46 ` Dan Carpenter
  0 siblings, 2 replies; 10+ messages in thread
From: Wenwen Wang @ 2018-04-30 22:56 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: open list:STAGING SUBSYSTEM, Aastha Gupta, Roman Storozhenko,
	Andreas Dilger, Jeff Layton, Greg Kroah-Hartman, Kangjie Lu,
	NeilBrown, open list, Oleg Drokin,
	moderated list:STAGING - LUSTRE PARALLEL FILESYSTEM

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_MAGIC_V3, lumv3 will be modified by the second copy from the user
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 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.

Signed-off-by: Wenwen Wang <wang6495@umn.edu>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
---
 drivers/staging/lustre/lustre/llite/dir.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index d10d272..80d44ca 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1185,6 +1185,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) {
 			if (copy_from_user(&lumv3, lumv3p, sizeof(lumv3)))
 				return -EFAULT;
+			if (lumv3.lmm_magic != LOV_USER_MAGIC_V3)
+				return -EINVAL;
 		}
 
 		if (is_root_inode(inode))
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCH v2] staging: lustre: llite: fix potential missing-check bug when copying lumv
@ 2018-05-04 15:01 Kangjie Lu
  2018-05-05  8:29 ` Dan Carpenter
  0 siblings, 1 reply; 10+ messages in thread
From: Kangjie Lu @ 2018-05-04 15:01 UTC (permalink / raw)
  To: Dilger, Andreas
  Cc: Wenwen Wang, Dan Carpenter, open list:STAGING SUBSYSTEM,
	Aastha Gupta, Roman Storozhenko, Jeff Layton, Greg Kroah-Hartman,
	NeilBrown, open list, Drokin, Oleg,
	moderated list:STAGING - LUSTRE PARALLEL FILESYSTEM

[-- Attachment #1: Type: text/plain, Size: 2511 bytes --]

On Fri, May 4, 2018 at 5:08 AM, Dilger, Andreas <andreas.dilger@intel.com>
wrote:

> On May 3, 2018, at 22:19, Wenwen Wang <wang6495@umn.edu> wrote:
> >
> > On Tue, May 1, 2018 at 3:46 AM, Dan Carpenter <dan.carpenter@oracle.com>
> wrote:
> >> On Mon, Apr 30, 2018 at 05:56:10PM -0500, Wenwen Wang wrote:
> >>> 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 part is misleading.  The fix is to improve readability and make
> >> static checkers happy.  You're over dramatizing it to make people think
> >> it has a security impact when it doesn't.
> >>
> >> If the user wants to specify v1 data they can just say that on the first
> >> read.  They don't need to do funny tricks and race between the two
> >> reads.  It's allowed.
> >>
> >> In other words this allows the user to do something in a very
> >> complicated way which they are already allowed to do in a very simple
> >> straight forward way.
> >>
> >> regards,
> >> dan carpenter
> >
> > Thanks for your comment, Dan! How about this:
> >
> > 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. The current kernel
> > can handle such inconsistent data. But, it may pose a potential
> > security risk for future implementations. Also, to improve code
> > readability and make static analysis tools happy, which will warn
> > about read-verify-re-read type bugs, this issue should be fixed.
>
> There is nothing preventing the user from using struct lov_mds_md_v3 but
> filling in lmm_magic = LOV_MAGIC_V1 from the beginning, no need for a race.
>

Right. No need for users to race. There might be a type confusion issue
though if V1
object is  used as V3 or the other way.


>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation
>
>
>
>
>
>
>
>


-- 
Kangjie Lu
Assistant Professor
Department of Computer Science and Engineering
University of Minnesota
kjlu@umn.edu
http://kangjie.lu

[-- Attachment #2: Type: text/html, Size: 3895 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-05-05  8:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-30 22:56 [PATCH v2] staging: lustre: llite: fix potential missing-check bug when copying lumv Wenwen Wang
2018-05-01  4:06 ` Dilger, Andreas
2018-05-01  8:46 ` Dan Carpenter
2018-05-04  4:19   ` Wenwen Wang
2018-05-04  5:27     ` Dan Carpenter
2018-05-04  5:33       ` Wenwen Wang
2018-05-04 10:08     ` Dilger, Andreas
2018-05-04 14:11       ` Wenwen Wang
2018-05-04 15:01 Kangjie Lu
2018-05-05  8:29 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®