From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f50.google.com ([74.125.83.50]:32882 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752316AbdARR3D (ORCPT ); Wed, 18 Jan 2017 12:29:03 -0500 Received: by mail-pg0-f50.google.com with SMTP id 204so6159424pge.0 for ; Wed, 18 Jan 2017 09:29:03 -0800 (PST) Message-ID: <1484760538.27533.37.camel@dubeyko.com> Subject: Re: [patch resend] hfs: fix fix hfs_readdir() From: Viacheslav Dubeyko To: Dan Carpenter , Al Viro , Andrew Morton Cc: Jan Kara , Miklos Szeredi , Bob Copeland , Boaz Harrosh , Deepa Dinamani , linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Wed, 18 Jan 2017 09:28:58 -0800 In-Reply-To: <20170118111320.GA23725@mwanda> References: <20170118111320.GA23725@mwanda> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, 2017-01-18 at 14:13 +0300, Dan Carpenter wrote: > I was looking through static analysis warnings and there is a bug > here > that goes all the way back to the start of git.  Basically we're > copying > the pointer and nearby garbage instead of the data the fd.key pointer > is > pointing to. > > Signed-off-by: Dan Carpenter > --- > I sent this a year ago, and we had a thread about it, but in the end > decided that the original patch was correct.  Not tested. > > diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c > index 5de5c48..75b2542 100644 > --- a/fs/hfs/dir.c > +++ b/fs/hfs/dir.c > @@ -169,7 +169,7 @@ static int hfs_readdir(struct file *file, struct > dir_context *ctx) >    * Can be done after the list insertion; exclusion with >    * hfs_delete_cat() is provided by directory lock. >    */ > - memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key)); > + memcpy(&rd->key, &fd.key->cat, sizeof(struct hfs_cat_key)); >  out: >   hfs_find_exit(&fd); >   return err; Looks good. Reviewed-by: Vyacheslav Dubeyko Thanks, Vyacheslav Dubeyko.