Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422944AbbD2MYh (ORCPT ); Wed, 29 Apr 2015 08:24:37 -0400 Received: from plane.gmane.org ([80.91.229.3]:34409 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422838AbbD2MYf (ORCPT ); Wed, 29 Apr 2015 08:24:35 -0400 X-Injected-Via-Gmane: http://gmane.org/ To: linux-kernel@vger.kernel.org From: Gobinda Charan Maji Subject: Re: [PATCH 9/9] sysfs: disallow world-writable files. Date: Wed, 29 Apr 2015 12:24:20 +0000 (UTC) Message-ID: References: <1398137612-9714-1-git-send-email-rusty@rustcorp.com.au> <1398137612-9714-10-git-send-email-rusty@rustcorp.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 182.74.215.94 (Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2308 Lines: 54 Rusty Russell rustcorp.com.au> writes: > > This check was introduced in 2006 by Alexey Dobriyan (9774a1f54f173) > for module parameters; we removed it when we unified the check into > VERIFY_OCTAL_PERMISSIONS() as sysfs didn't have the same requirement. > Now all those users are fixed, reintroduce it. > > Cc: Alexey Dobriyan gmail.com> > Cc: Dave Jones redhat.com> > Cc: Joe Perches perches.com> > Signed-off-by: Rusty Russell rustcorp.com.au> > --- > include/linux/kernel.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index 4c52907a6d8b..43e1c6a9683e 100644 > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > -849,5 +849,7 static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } > /* User perms >= group perms >= other perms */ \ > BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \ > BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \ > + /* Other writable? Generally considered a bad idea. */ \ > + BUILD_BUG_ON_ZERO((perms) & 2) + \ > (perms)) > #endif Hi Rusty, I have a small doubt about the permission restriction (User perms >= group perms >= other perms) in VERIFY_OCTAL_PERMISSIONS(). Please Note that permission field of User, Group or Other consists of three bits. LSB is EXECUTE permission, MSB is READ permission and the middle bit is WRITE permission. Say for example, permission value is "0431". Here User has only READ permission whereas Group has both WRITE and EXECUTE permission and Other has EXECUTE permission. I guess, it is not good to give Group the WRITE permission whereas User itself has no WRITE permission. May be, it's better to check those three permissions bit wise rather than as a whole. I already had posted my query at: http://thread.gmane.org/gmane.linux.kernel/1667095/focus=1737833 But could get any reply. Please rethink about my point and let me know your opinion. Thanks, Gobinda -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/