From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754761AbcLaRgi (ORCPT ); Sat, 31 Dec 2016 12:36:38 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:40802 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754633AbcLaRgh (ORCPT ); Sat, 31 Dec 2016 12:36:37 -0500 Date: Sat, 31 Dec 2016 12:36:35 -0500 (EST) Message-Id: <20161231.123635.849464145094515334.davem@davemloft.net> To: ebiggers3@gmail.com Cc: netdev@vger.kernel.org, lorenzo@google.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, ebiggers@google.com Subject: Re: [PATCH] net: socket: don't set sk_uid to garbage value in ->setattr() From: David Miller In-Reply-To: <20161230234232.4221-1-ebiggers3@gmail.com> References: <20161230234232.4221-1-ebiggers3@gmail.com> X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sat, 31 Dec 2016 08:37:23 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers Date: Fri, 30 Dec 2016 17:42:32 -0600 > From: Eric Biggers > > ->setattr() was recently implemented for socket files to sync the socket > inode's uid to the new 'sk_uid' member of struct sock. It does this by > copying over the ia_uid member of struct iattr. However, ia_uid is > actually only valid when ATTR_UID is set in ia_valid, indicating that > the uid is being changed, e.g. by chown. Other metadata operations such > as chmod or utimes leave ia_uid uninitialized. Therefore, sk_uid could > be set to a "garbage" value from the stack. > > Fix this by only copying the uid over when ATTR_UID is set. > > Fixes: 86741ec25462 ("net: core: Add a UID field to struct sock.") > Signed-off-by: Eric Biggers Lorenzo, please review.