Skip to content

Commit 2cfa1cd

Browse files
committed
Merge tag 'selinux-pr-20180130' of git://git.kernel.org/pub/scm/linux/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
2 parents 3dbc4f5 + 4b14752 commit 2cfa1cd

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

security/selinux/include/netlabel.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
* the GNU General Public License for more details.
2020
*
2121
* You should have received a copy of the GNU General Public License
22-
* along with this program; if not, write to the Free Software
23-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2423
*
2524
*/
2625

security/selinux/netlabel.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
* the GNU General Public License for more details.
2323
*
2424
* You should have received a copy of the GNU General Public License
25-
* along with this program; if not, write to the Free Software
26-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2726
*
2827
*/
2928

security/selinux/ss/services.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,9 @@ int security_bounded_transition(u32 old_sid, u32 new_sid)
867867
int index;
868868
int rc;
869869

870+
if (!ss_initialized)
871+
return 0;
872+
870873
read_lock(&policy_rwlock);
871874

872875
rc = -EINVAL;
@@ -1413,27 +1416,25 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len,
14131416
if (!scontext_len)
14141417
return -EINVAL;
14151418

1419+
/* Copy the string to allow changes and ensure a NUL terminator */
1420+
scontext2 = kmemdup_nul(scontext, scontext_len, gfp_flags);
1421+
if (!scontext2)
1422+
return -ENOMEM;
1423+
14161424
if (!ss_initialized) {
14171425
int i;
14181426

14191427
for (i = 1; i < SECINITSID_NUM; i++) {
1420-
if (!strcmp(initial_sid_to_string[i], scontext)) {
1428+
if (!strcmp(initial_sid_to_string[i], scontext2)) {
14211429
*sid = i;
1422-
return 0;
1430+
goto out;
14231431
}
14241432
}
14251433
*sid = SECINITSID_KERNEL;
1426-
return 0;
1434+
goto out;
14271435
}
14281436
*sid = SECSID_NULL;
14291437

1430-
/* Copy the string so that we can modify the copy as we parse it. */
1431-
scontext2 = kmalloc(scontext_len + 1, gfp_flags);
1432-
if (!scontext2)
1433-
return -ENOMEM;
1434-
memcpy(scontext2, scontext, scontext_len);
1435-
scontext2[scontext_len] = 0;
1436-
14371438
if (force) {
14381439
/* Save another copy for storing in uninterpreted form */
14391440
rc = -ENOMEM;

0 commit comments

Comments
 (0)