Skip to content

Commit

Permalink
Merge tag 'selinux-pr-20180130' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/pcmoore/selinux

Pull selinux updates from Paul Moore:
 "A small pull request this time, just three patches, and one of these
  is just a comment update (swap the FSF physical address for a URL).

  The other two patches are small bug fixes found by szybot/syzkaller;
  they individual patch descriptions should tell you all you ever wanted
  to know"

* tag 'selinux-pr-20180130' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
  selinux: skip bounded transition processing if the policy isn't loaded
  selinux: ensure the context is NUL terminated in security_context_to_sid_core()
  security: replace FSF address with web source in license notices
  • Loading branch information
torvalds committed Jan 31, 2018
2 parents 3dbc4f5 + 4b14752 commit 2cfa1cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions security/selinux/include/netlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

Expand Down
3 changes: 1 addition & 2 deletions security/selinux/netlabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

Expand Down
21 changes: 11 additions & 10 deletions security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,9 @@ int security_bounded_transition(u32 old_sid, u32 new_sid)
int index;
int rc;

if (!ss_initialized)
return 0;

read_lock(&policy_rwlock);

rc = -EINVAL;
Expand Down Expand Up @@ -1413,27 +1416,25 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len,
if (!scontext_len)
return -EINVAL;

/* Copy the string to allow changes and ensure a NUL terminator */
scontext2 = kmemdup_nul(scontext, scontext_len, gfp_flags);
if (!scontext2)
return -ENOMEM;

if (!ss_initialized) {
int i;

for (i = 1; i < SECINITSID_NUM; i++) {
if (!strcmp(initial_sid_to_string[i], scontext)) {
if (!strcmp(initial_sid_to_string[i], scontext2)) {
*sid = i;
return 0;
goto out;
}
}
*sid = SECINITSID_KERNEL;
return 0;
goto out;
}
*sid = SECSID_NULL;

/* Copy the string so that we can modify the copy as we parse it. */
scontext2 = kmalloc(scontext_len + 1, gfp_flags);
if (!scontext2)
return -ENOMEM;
memcpy(scontext2, scontext, scontext_len);
scontext2[scontext_len] = 0;

if (force) {
/* Save another copy for storing in uninterpreted form */
rc = -ENOMEM;
Expand Down

0 comments on commit 2cfa1cd

Please sign in to comment.