Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752426AbZL0QW5 (ORCPT ); Sun, 27 Dec 2009 11:22:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752216AbZL0QW4 (ORCPT ); Sun, 27 Dec 2009 11:22:56 -0500 Received: from lists.laptop.org ([18.85.2.145]:50988 "EHLO mail.laptop.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752005AbZL0QWz (ORCPT ); Sun, 27 Dec 2009 11:22:55 -0500 Date: Sun, 27 Dec 2009 11:25:03 -0500 From: Michael Stone To: Tetsuo Handa Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-security-module@vger.kernel.org, Andi Kleen , David Lang , Oliver Hartkopp , Alan Cox , Herbert Xu , Valdis Kletnieks , Bryan Donlan , Evgeniy Polyakov , "C. Scott Ananian" , James Morris , "Eric W. Biederman" , Bernie Innocenti , Mark Seaborn , Randy Dunlap , =?iso-8859-1?Q?Am=E9rico?= Wang , Samir Bellabes , Casey Schaufler , "Serge E. Hallyn" , Pavel Machek , Michael Stone Subject: Re: [PATCH 3/3] Security: Document disablenetwork. (v4) Message-ID: <20091227162502.GC12645@heat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <200912271039.DHG51586.FMFFHOJSLVQtOO@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2008 Lines: 52 Tetsuo Handa wrote: > Michael Stone wrote: >> +Exceptions are made for >> + * processes calling sendmsg() on a previously connected socket >> + (i.e. one with msg.msg_name == NULL && msg.msg_namelen == 0) or > > What should we do for non connection oriented protocols (e.g. UDP) > but destination is already configured by previous connect() request? > > struct sockaddr_in addr = { ... }; > int fd2 = socket(PF_INET, SOCK_DGRAM, 0); > connect(fd2, (struct sockadr *) &addr, sizeof(addr)); > prctl( ... ); > sendto(fd2, buffer, len, 0, NULL, 0); /* Should we allow this? */ This call should be allowed. man 2 send states that this call is equivalent to send(fd2, buffer, len, 0) and, since the flags field is 0, to write(fd2, buffer, len) which are both clearly permitted. > sendto(fd2, buffer, len, 0, (struct sockadr *) &addr, sizeof(addr)); /* Should we reject this? */ It is reasonable to reject this call because it is not required to be equivalent to a send() or write() call. (In fact, the current UDP implementation unconditionally uses the addr argument passed to sendmsg in favor of the socket addr whenever it exists.) However, it might also be reasonable to permit the send when the call would be equivalent to a permitted send() or write() call: for example, when the socket destination address exists and matches the message destination address. Unfortunately, I don't think that we have an appropriate generic address comparison function for deciding this equivalence. Am I mistaken? Regards, and thanks for your questions, Michael P.S. - I would be happy to include a brief explanatory comment in the code defining this test since this is by far the most complex test in the patch. Any suggestions on what it might say? -- 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/